[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7190JRK8G73JNBFEVTYJMD1":3,"skill-same:01M7190JRK8G73JNBFEVTYJMD1":122},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":37,"publishedAt":58,"linkOnly":59,"markdownContent":60,"markdownBody":61,"frontMatter":62,"refName":100,"commitSha":101,"skillDirectory":102,"forksCount":103,"repositoryHtmlUrl":104,"repositoryHomepageUrl":6,"ownerHtmlUrl":105,"ownerBlogUrl":106,"ownerDescription":6,"updatedAt":107,"install":108,"resources":121},"01M7190JRK8G73JNBFEVTYJMD1","slopgate-intelligent-coding-patterns",null,"Pattern-selection playbook for agents editing code with complex branching, stateful parsers\u002Fworkflows, duplicated skeletons, policy checks, or ordered transforms. Load before refactoring if\u002Felif dispatch chains, boolean-flag state machines, repeated validation predicates, parallel provider\u002Flanguage implementations, or regex\u002Fcontent transformation pipelines. Also load when asked to \"apply a design pattern\", \"which pattern should I use here\", \"refactor this switch statement\", \"replace if-elif chain\", \"state machine pattern\", \"strategy pattern\", \"template method\", \"pipeline pattern\", \"specification pattern\", \"dispatch table\", \"guard clause refactor\", \"reduce cyclomatic complexity\", or when Slopgate fires PY-CODE-014, PY-CODE-017, PY-CODE-018, QUALITY-LINT-001, or PY-QUALITY-010. Use with behavior-locking tests and avoid pattern theater for simple one-off code.","vasceannie\u002Fslopgate","vasceannie","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F20271133?v=4","01M718RGA8VV2EF22XJEMXVQ0Q","Travis Vasceannie","01M718RGB0GWSXBBZBN67Q6NHQ",1,"MIT","https:\u002F\u002Fgithub.com\u002Fvasceannie\u002Fslopgate\u002Fblob\u002Fmaster\u002F.codex\u002Fskills\u002Fslopgate-intelligent-coding-patterns\u002FSKILL.md",[18,23,26,29,34],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000007","代码审查","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000015","视觉设计",{"categoryNo":27,"categoryName":28,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",{"categoryNo":30,"categoryName":31,"taxonomyType":32,"taxonomyTypeDesc":33},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",{"categoryNo":35,"categoryName":36,"taxonomyType":32,"taxonomyTypeDesc":33},"01JBSEEDCAT000000000000032","设计师",[38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57],"slopgate intelligent coding patterns","patterns","coding","coding patterns","code","reduce","when","workflows","utility","cleanup","only","design","selection","pipeline","parsers","chain","which","branch","complexity","stateful","2026-11-10 10:12:30",false,"---\nname: slopgate-intelligent-coding-patterns\ndescription: |\n  Pattern-selection playbook for agents editing code with complex branching, stateful parsers\u002Fworkflows, duplicated skeletons, policy checks, or ordered transforms. Load before refactoring if\u002Felif dispatch chains, boolean-flag state machines, repeated validation predicates, parallel provider\u002Flanguage implementations, or regex\u002Fcontent transformation pipelines. Also load when asked to \"apply a design pattern\", \"which pattern should I use here\", \"refactor this switch statement\", \"replace if-elif chain\", \"state machine pattern\", \"strategy pattern\", \"template method\", \"pipeline pattern\", \"specification pattern\", \"dispatch table\", \"guard clause refactor\", \"reduce cyclomatic complexity\", or when Slopgate fires PY-CODE-014, PY-CODE-017, PY-CODE-018, QUALITY-LINT-001, or PY-QUALITY-010. Use with behavior-locking tests and avoid pattern theater for simple one-off code.\nversion: 1.0.0\nauthor: Slopgate\nlicense: MIT\ncompatibility: claude-code, opencode, codex, hermes, slopgate\nmetadata:\n  hermes:\n    tags: [slopgate,design-patterns,dispatch,state-machines,refactor]\n    related_skills: [slopgate-code-hygiene-refactor,slopgate-code-smell-utility-locator,slopgate-test-extender]\n  slopgate:\n    rule_ids: [PY-CODE-012,PY-CODE-013,PY-CODE-014,PY-CODE-017,PY-CODE-018,PY-QUALITY-010,QUALITY-LINT-001,QUALITY-PATTERN-002]\n    activation:\n      primary: [pattern selection,dispatch chains,state machines,policy predicates,pipelines]\n      avoid: [two-branch cleanup,style-only edits,speculative abstraction]\n---\n\n# Intelligent Coding Patterns\n\nUse this skill when a code edit touches branching, dispatch, parser state, validation policies, duplicated extraction\u002Fprovider logic, or ordered content\u002Fdata transforms. The goal is not to add fashionable abstractions. The goal is to pick the smallest proven structure that makes the code easier to change, easier to test, and harder to break silently.\n\n## When to Use\n\nUse when the next edit requires choosing a design pattern rather than simply moving code.\n\n- Code has three or more branches, dispatch by key\u002Ftype\u002Fprovider\u002Fevent, boolean-flag parser\u002Fworkflow state, repeated policy predicates, or ordered transforms.\n- User asks which pattern to use, or mentions strategy\u002Fstate\u002Fspecification\u002Ftemplate-method\u002Fpipeline\u002Fdispatch-table refactors.\n- Pair with behavior-locking tests before the pattern change.\n\n## When Not to Use\n\nDo not use for simple two-branch cleanup, renames, formatting, or speculative future extensibility.\n\nDo not use merely because a Slopgate quality rule fired; use `slopgate-code-hygiene-refactor` first unless the repair genuinely requires choosing among patterns.\n\nDo not introduce a pattern that makes the happy path harder to read.\n\n## Non-negotiables\n\n1. Lock behavior before refactoring. Add or identify focused tests for the current behavior before changing the shape.\n2. Prefer the smallest useful pattern. Two simple branches do not need a framework.\n3. Preserve public APIs unless the task explicitly includes a migration.\n4. Do not weaken hooks, tests, baselines, type checks, lint config, or rule thresholds to make a pattern refactor pass.\n5. Keep the happy path readable. A pattern that makes the main flow harder to understand is probably the wrong pattern.\n6. Verify with the narrowest relevant test first, then the broader gate if the touched project requires it.\n\n## Pattern scout: classify the code before editing\n\nBefore editing a complex function, answer these shape questions:\n\n1. Is this selecting behavior by key, protocol, type, command, provider, model, file extension, language, or event name?\n   - Prefer Dispatch Table \u002F Registry.\n2. Is this code nested because edge cases wrap the happy path?\n   - Prefer Guard Clauses.\n3. Are boolean flags modeling parser\u002Fworkflow state across a loop?\n   - Prefer explicit State Pattern with enums and transitions.\n4. Are repeated booleans enforcing named policy, validation, or eligibility checks?\n   - Prefer Specification Pattern.\n5. Do two or more functions\u002Fclasses share the same skeleton but vary by parser\u002Fprovider\u002Flanguage\u002Fstorage implementation?\n   - Prefer Template Method plus Strategy.\n6. Are several transforms applied in order to the same content\u002Fobject?\n   - Prefer Pipeline \u002F Chain of Responsibility.\n7. Is the apparent pattern only one branch, one call site, or speculative future growth?\n   - Skip the pattern and keep direct code.\n\n## Dispatch Table \u002F Registry\n\nUse when behavior is selected by a stable key and there are three or more branches, or when new keys are expected.\n\nReplaces:\n\n```python\nif protocol == \"rest\":\n    return handle_rest(request)\nelif protocol == \"grpc\":\n    return handle_grpc(request)\nelif protocol == \"graphql\":\n    return handle_graphql(request)\nraise UnsupportedProtocolError(protocol)\n```\n\nPrefer:\n\n```python\nPROTOCOL_HANDLERS: dict[str, Callable[[Request], Response]] = {\n    \"rest\": handle_rest,\n    \"grpc\": handle_grpc,\n    \"graphql\": handle_graphql,\n}\n\nhandler = PROTOCOL_HANDLERS.get(protocol)\nif handler is None:\n    raise UnsupportedProtocolError(protocol)\nreturn handler(request)\n```\n\nWhen to use:\n\n- command routers;\n- provider\u002Fmodel handlers;\n- protocol handlers;\n- extension-to-parser maps;\n- event name to hook handler maps.\n\nAvoid when:\n\n- the branches are fewer than three and unlikely to grow;\n- each branch has deeply different control flow and shared dispatch would hide important behavior;\n- the selected behavior depends on complex ordered predicates rather than exact keys.\n\nVerification:\n\n- one test per registered key;\n- one unsupported-key test;\n- one test that proves registration does not change existing behavior.\n\n## Guard Clauses\n\nUse when validation, missing dependencies, empty input, or safety checks force the happy path into nested indentation.\n\nReplaces:\n\n```python\ndef get_models() -> list[dict[str, str]]:\n    if api_key:\n        try:\n            return fetch_models(api_key)\n        except ProviderError:\n            return []\n    else:\n        return []\n```\n\nPrefer:\n\n```python\ndef get_models() -> list[dict[str, str]]:\n    if not api_key:\n        return []\n\n    try:\n        return fetch_models(api_key)\n    except ProviderError:\n        return []\n```\n\nWhen to use:\n\n- missing config \u002F missing credentials returns;\n- invalid inputs;\n- no-op cases;\n- permission\u002Fsafety preconditions;\n- unsupported platform checks.\n\nAvoid when:\n\n- many early returns make cleanup\u002Fresource handling unclear;\n- a context manager or transaction boundary needs one obvious exit path;\n- error reporting needs accumulated failures rather than immediate return.\n\nVerification:\n\n- test each guard condition;\n- test the happy path stays top-level and unchanged.\n\n## State Pattern\n\nUse when a loop carries boolean flags such as `in_string`, `escape_next`, `seen_header`, `pending_tool`, `inside_block`, or `awaiting_response`.\n\nReplaces boolean flag mazes:\n\n```python\nin_string = False\nescape_next = False\nfor char in text:\n    if escape_next:\n        ...\n    elif in_string and char == \"\\\\\":\n        ...\n    elif in_string and char == \"'\":\n        ...\n    elif not in_string and char == \",\":\n        ...\n```\n\nPrefer an explicit state enum:\n\n```python\nfrom enum import Enum, auto\n\nclass ParserState(Enum):\n    NORMAL = auto()\n    IN_STRING = auto()\n    ESCAPING = auto()\n\nstate = ParserState.NORMAL\nfor char in text:\n    match state:\n        case ParserState.ESCAPING:\n            current.append(char)\n            state = ParserState.IN_STRING\n        case ParserState.IN_STRING:\n            if char == \"\\\\\":\n                current.append(char)\n                state = ParserState.ESCAPING\n            elif char == \"'\":\n                current.append(char)\n                state = ParserState.NORMAL\n            else:\n                current.append(char)\n        case ParserState.NORMAL:\n            if char == \"'\":\n                current.append(char)\n                state = ParserState.IN_STRING\n            elif char == \",\":\n                emit_value()\n            else:\n                current.append(char)\n```\n\nWhen to use:\n\n- parsers;\n- streaming protocol readers;\n- tool-call\u002Fsession lifecycle handling;\n- retry\u002Fbackoff lifecycle code;\n- multiline text scanners.\n\nAvoid when:\n\n- the state is truly binary and local;\n- a standard parser\u002Flibrary exists and should be used instead;\n- a table-driven parser would be clearer than match\u002Fcase.\n\nVerification:\n\n- table-driven tests for each transition;\n- boundary cases for empty input, escaped delimiters, delimiters inside strings, malformed\u002Fincomplete state, and final flush behavior;\n- regression tests from real bug examples if available.\n\n## Specification Pattern\n\nUse when named checks, policies, or eligibility predicates are scattered as booleans or repeated if-statements.\n\nReplaces scattered predicates:\n\n```python\nif not searched_context:\n    failures.append(\"search context\")\nif not tools_ready:\n    failures.append(\"tools ready\")\nif unsafe_target:\n    failures.append(\"safe target\")\n```\n\nPrefer named specs:\n\n```python\n@dataclass(frozen=True)\nclass CheckSpec:\n    id: str\n    description: str\n    check: Callable[[TaskContext], bool]\n    repair_hint: str\n\nPRETASK_CHECKS = [\n    CheckSpec(\"context-search\", \"Context search completed\", lambda ctx: ctx.searched_context, \"Search existing implementations first.\"),\n    CheckSpec(\"tools-ready\", \"Required tools are available\", lambda ctx: ctx.tools_ready, \"Verify tool availability before editing.\"),\n    CheckSpec(\"safe-target\", \"Target path is safe to edit\", lambda ctx: not ctx.unsafe_target, \"Stop and ask before mutating protected config.\"),\n]\n\ndef evaluate_specs(ctx: TaskContext) -> list[CheckSpec]:\n    return [spec for spec in PRETASK_CHECKS if not spec.check(ctx)]\n```\n\nWhen to use:\n\n- pre-task checklists;\n- policy gates;\n- validation rules;\n- eligibility filters;\n- reusable rule explanations.\n\nAvoid when:\n\n- checks need one-off local context and will not be reused;\n- a simple validation function is clearer;\n- check order has side effects that should be explicit.\n\nVerification:\n\n- one test per spec;\n- one aggregate test for multiple failures;\n- one test proving descriptions\u002Fhints are stable if user-facing.\n\n## Template Method plus Strategy\n\nUse when two functions share a skeleton but differ in provider, parser, storage, language, or platform behavior.\n\nShape:\n\n```python\nclass FunctionExtractor(ABC):\n    def extract(self, path: Path) -> list[FunctionInfo]:\n        source = self._read_source(path)\n        raw = self._parse_signatures(source, path)\n        calls = self._count_calls(source)\n        return self._enrich(raw, calls)\n\n    @abstractmethod\n    def _parse_signatures(self, source: str, path: Path) -> list[FunctionInfo]: ...\n\n    @abstractmethod\n    def _count_calls(self, source: str) -> dict[str, int]: ...\n\nclass PythonExtractor(FunctionExtractor): ...\nclass TypeScriptExtractor(FunctionExtractor): ...\n\nEXTRACTORS: dict[str, FunctionExtractor] = {\n    \".py\": PythonExtractor(),\n    \".ts\": TypeScriptExtractor(),\n    \".tsx\": TypeScriptExtractor(),\n}\n```\n\nWhen to use:\n\n- Python vs TypeScript extraction;\n- provider-specific request builders with shared validation\u002Fresponse handling;\n- platform adapters with shared envelope behavior;\n- storage backends with shared orchestration.\n\nAvoid when:\n\n- duplication is superficial and names differ but logic does not;\n- composition with small functions is enough;\n- inheritance would obscure data flow or make tests harder.\n\nVerification:\n\n- shared skeleton test using a fake strategy;\n- concrete strategy tests for each variant;\n- registry test for extension\u002Fprovider\u002Fplatform routing.\n\n## Pipeline \u002F Chain of Responsibility\n\nUse when content or data is transformed by a sequence of independent steps.\n\nReplaces long in-function transform chains:\n\n```python\ncontent = normalize_links(content)\ncontent = convert_captions(content)\ncontent = rewrite_youtube_embeds(content)\ncontent = sanitize_html(content)\nreturn content\n```\n\nPrefer explicit pipeline composition when the chain is growing:\n\n```python\nclass Transform(Protocol):\n    name: str\n    def apply(self, content: str) -> str: ...\n\nclass ContentPipeline:\n    def __init__(self, transforms: Sequence[Transform]) -> None:\n        self._transforms = list(transforms)\n\n    def process(self, content: str) -> str:\n        for transform in self._transforms:\n            content = transform.apply(content)\n        return content\n```\n\nWhen to use:\n\n- regex\u002Fcontent conversion;\n- AST or lint collector passes;\n- data cleaning stages;\n- request\u002Fresponse middleware;\n- hook enrichment\u002Frendering steps.\n\nAvoid when:\n\n- the order is fixed and only two simple lines;\n- transforms share hidden mutable state;\n- failure handling needs transaction semantics rather than a linear chain.\n\nVerification:\n\n- unit test each transform;\n- integration test the ordered pipeline;\n- test that order-sensitive transforms stay in the documented order.\n\n## Testing playbook for pattern refactors\n\n1. Characterize the existing behavior with narrow tests before changing code.\n2. Include edge cases that motivated the pattern, not only the happy path.\n3. Refactor in the smallest slice that preserves public behavior.\n4. Run focused tests after each slice.\n5. Run the local project quality gate only after the focused tests pass.\n6. If a hook\u002Flint backstop denies the refactor, repair the design. Do not suppress the rule.\n\nGood test shapes:\n\n- Dispatch tables: registered key, unsupported key, handler exception path.\n- Guard clauses: missing input\u002Fconfig, invalid input, happy path.\n- State machines: each transition, final flush, malformed\u002Fincomplete input.\n- Specs: individual pass\u002Ffail, aggregated failures, user-facing hint text.\n- Strategy\u002Ftemplate: fake strategy for skeleton, concrete strategy for variants.\n- Pipelines: individual transforms, ordered integration, idempotency where expected.\n\n## Anti-patterns this skill should prevent\n\n- Pattern theater: adding abstract base classes for one local if statement.\n- Registry without tests: moving branches into a dict but not proving each key works.\n- State enum cosplay: enum exists but boolean flags still drive the real behavior.\n- Over-shared template: forcing different flows into one inheritance tree until each override is a workaround.\n- Pipeline opacity: transforms mutate hidden global state or silently depend on undocumented order.\n- Refactor without behavior lock: \"cleaner\" code with no test proving equivalence.\n\n## Slopgate rule-to-pattern trigger map\n\nLoad this skill when Slopgate fires these rules:\n\n| Slopgate Rule | Pattern to Apply | Section |\n|---------------|------------------|---------|\n| `PY-CODE-014` god class | Extract collaborator by data + responsibility | State Pattern \u002F Template Method |\n| `PY-CODE-017` flat siblings | Package split with `__init__.py` facade | Dispatch Table (for package API) |\n| `PY-CODE-018` oversized module | Identify seams → package split | Pipeline \u002F Template Method |\n| `QUALITY-LINT-001` long-method | Extract helpers by phase | Pipeline \u002F Guard Clauses |\n| `QUALITY-LINT-001` repeated-code-block | Extract shared helper\u002Fservice | Template Method + Strategy |\n| `PY-QUALITY-010` magic numbers | Specification Pattern for policy constants | Specification Pattern |\n| `PY-CODE-012` thin wrappers | Inline or add real boundary | Guard Clauses \u002F Specification |\n| `PY-CODE-013` feature envy | Move behavior to envied owner | State Pattern \u002F direct method |\n\n## Agent prompt\u002Frule integration snippet\n\nUse this as thin routing text in Claude, OpenCode, Codex, or Cursor markdown; keep this full skill as the canonical playbook:\n\n```text\nWhen editing code with branching or duplicated control flow, check for these refactor opportunities before writing:\n- 3+ if\u002Felif branches selecting behavior by key\u002Ftype\u002Fprotocol\u002Fprovider\u002Fevent -> dispatch table\u002Fregistry.\n- nested happy path -> guard clauses.\n- boolean flags modeling parser\u002Fworkflow state -> enum state machine.\n- repeated validation\u002Fpolicy booleans -> specification objects.\n- duplicated skeleton with variant parsing\u002Fprovider\u002Fplatform behavior -> template method + strategy.\n- ordered regex\u002Fcontent\u002Fdata transforms -> pipeline\u002Fchain.\n\nIf two or more triggers appear, load skill intelligent-coding-patterns before editing. Do not introduce these patterns for single-use or obviously simpler code. Add or identify behavior-locking tests before refactoring.\n```\n\n## Slopgate hook guidance\n\nFor advisory hook responses, prefer solution-first language:\n\n```text\n[QUALITY-PATTERN-002 | ADVISORY | PRE-WRITE]\nThis looks like behavior dispatch by protocol with 5 branches. Prefer a registry mapping protocol -> handler. Load intelligent-coding-patterns, section Dispatch Table. If this is intentionally local\u002Fsimple, keep the direct branch and document why.\n```\n\nStart advisory-first for these pattern smells. Promote to blocking only for high-confidence cases such as new boolean-flag parser loops without tests, new 5+ branch key dispatch chains, or repeated ignored advisories on the same file\u002Frule.\n","# Intelligent Coding Patterns\n\nUse this skill when a code edit touches branching, dispatch, parser state, validation policies, duplicated extraction\u002Fprovider logic, or ordered content\u002Fdata transforms. The goal is not to add fashionable abstractions. The goal is to pick the smallest proven structure that makes the code easier to change, easier to test, and harder to break silently.\n\n## When to Use\n\nUse when the next edit requires choosing a design pattern rather than simply moving code.\n\n- Code has three or more branches, dispatch by key\u002Ftype\u002Fprovider\u002Fevent, boolean-flag parser\u002Fworkflow state, repeated policy predicates, or ordered transforms.\n- User asks which pattern to use, or mentions strategy\u002Fstate\u002Fspecification\u002Ftemplate-method\u002Fpipeline\u002Fdispatch-table refactors.\n- Pair with behavior-locking tests before the pattern change.\n\n## When Not to Use\n\nDo not use for simple two-branch cleanup, renames, formatting, or speculative future extensibility.\n\nDo not use merely because a Slopgate quality rule fired; use `slopgate-code-hygiene-refactor` first unless the repair genuinely requires choosing among patterns.\n\nDo not introduce a pattern that makes the happy path harder to read.\n\n## Non-negotiables\n\n1. Lock behavior before refactoring. Add or identify focused tests for the current behavior before changing the shape.\n2. Prefer the smallest useful pattern. Two simple branches do not need a framework.\n3. Preserve public APIs unless the task explicitly includes a migration.\n4. Do not weaken hooks, tests, baselines, type checks, lint config, or rule thresholds to make a pattern refactor pass.\n5. Keep the happy path readable. A pattern that makes the main flow harder to understand is probably the wrong pattern.\n6. Verify with the narrowest relevant test first, then the broader gate if the touched project requires it.\n\n## Pattern scout: classify the code before editing\n\nBefore editing a complex function, answer these shape questions:\n\n1. Is this selecting behavior by key, protocol, type, command, provider, model, file extension, language, or event name?\n   - Prefer Dispatch Table \u002F Registry.\n2. Is this code nested because edge cases wrap the happy path?\n   - Prefer Guard Clauses.\n3. Are boolean flags modeling parser\u002Fworkflow state across a loop?\n   - Prefer explicit State Pattern with enums and transitions.\n4. Are repeated booleans enforcing named policy, validation, or eligibility checks?\n   - Prefer Specification Pattern.\n5. Do two or more functions\u002Fclasses share the same skeleton but vary by parser\u002Fprovider\u002Flanguage\u002Fstorage implementation?\n   - Prefer Template Method plus Strategy.\n6. Are several transforms applied in order to the same content\u002Fobject?\n   - Prefer Pipeline \u002F Chain of Responsibility.\n7. Is the apparent pattern only one branch, one call site, or speculative future growth?\n   - Skip the pattern and keep direct code.\n\n## Dispatch Table \u002F Registry\n\nUse when behavior is selected by a stable key and there are three or more branches, or when new keys are expected.\n\nReplaces:\n\n```python\nif protocol == \"rest\":\n    return handle_rest(request)\nelif protocol == \"grpc\":\n    return handle_grpc(request)\nelif protocol == \"graphql\":\n    return handle_graphql(request)\nraise UnsupportedProtocolError(protocol)\n```\n\nPrefer:\n\n```python\nPROTOCOL_HANDLERS: dict[str, Callable[[Request], Response]] = {\n    \"rest\": handle_rest,\n    \"grpc\": handle_grpc,\n    \"graphql\": handle_graphql,\n}\n\nhandler = PROTOCOL_HANDLERS.get(protocol)\nif handler is None:\n    raise UnsupportedProtocolError(protocol)\nreturn handler(request)\n```\n\nWhen to use:\n\n- command routers;\n- provider\u002Fmodel handlers;\n- protocol handlers;\n- extension-to-parser maps;\n- event name to hook handler maps.\n\nAvoid when:\n\n- the branches are fewer than three and unlikely to grow;\n- each branch has deeply different control flow and shared dispatch would hide important behavior;\n- the selected behavior depends on complex ordered predicates rather than exact keys.\n\nVerification:\n\n- one test per registered key;\n- one unsupported-key test;\n- one test that proves registration does not change existing behavior.\n\n## Guard Clauses\n\nUse when validation, missing dependencies, empty input, or safety checks force the happy path into nested indentation.\n\nReplaces:\n\n```python\ndef get_models() -> list[dict[str, str]]:\n    if api_key:\n        try:\n            return fetch_models(api_key)\n        except ProviderError:\n            return []\n    else:\n        return []\n```\n\nPrefer:\n\n```python\ndef get_models() -> list[dict[str, str]]:\n    if not api_key:\n        return []\n\n    try:\n        return fetch_models(api_key)\n    except ProviderError:\n        return []\n```\n\nWhen to use:\n\n- missing config \u002F missing credentials returns;\n- invalid inputs;\n- no-op cases;\n- permission\u002Fsafety preconditions;\n- unsupported platform checks.\n\nAvoid when:\n\n- many early returns make cleanup\u002Fresource handling unclear;\n- a context manager or transaction boundary needs one obvious exit path;\n- error reporting needs accumulated failures rather than immediate return.\n\nVerification:\n\n- test each guard condition;\n- test the happy path stays top-level and unchanged.\n\n## State Pattern\n\nUse when a loop carries boolean flags such as `in_string`, `escape_next`, `seen_header`, `pending_tool`, `inside_block`, or `awaiting_response`.\n\nReplaces boolean flag mazes:\n\n```python\nin_string = False\nescape_next = False\nfor char in text:\n    if escape_next:\n        ...\n    elif in_string and char == \"\\\\\":\n        ...\n    elif in_string and char == \"'\":\n        ...\n    elif not in_string and char == \",\":\n        ...\n```\n\nPrefer an explicit state enum:\n\n```python\nfrom enum import Enum, auto\n\nclass ParserState(Enum):\n    NORMAL = auto()\n    IN_STRING = auto()\n    ESCAPING = auto()\n\nstate = ParserState.NORMAL\nfor char in text:\n    match state:\n        case ParserState.ESCAPING:\n            current.append(char)\n            state = ParserState.IN_STRING\n        case ParserState.IN_STRING:\n            if char == \"\\\\\":\n                current.append(char)\n                state = ParserState.ESCAPING\n            elif char == \"'\":\n                current.append(char)\n                state = ParserState.NORMAL\n            else:\n                current.append(char)\n        case ParserState.NORMAL:\n            if char == \"'\":\n                current.append(char)\n                state = ParserState.IN_STRING\n            elif char == \",\":\n                emit_value()\n            else:\n                current.append(char)\n```\n\nWhen to use:\n\n- parsers;\n- streaming protocol readers;\n- tool-call\u002Fsession lifecycle handling;\n- retry\u002Fbackoff lifecycle code;\n- multiline text scanners.\n\nAvoid when:\n\n- the state is truly binary and local;\n- a standard parser\u002Flibrary exists and should be used instead;\n- a table-driven parser would be clearer than match\u002Fcase.\n\nVerification:\n\n- table-driven tests for each transition;\n- boundary cases for empty input, escaped delimiters, delimiters inside strings, malformed\u002Fincomplete state, and final flush behavior;\n- regression tests from real bug examples if available.\n\n## Specification Pattern\n\nUse when named checks, policies, or eligibility predicates are scattered as booleans or repeated if-statements.\n\nReplaces scattered predicates:\n\n```python\nif not searched_context:\n    failures.append(\"search context\")\nif not tools_ready:\n    failures.append(\"tools ready\")\nif unsafe_target:\n    failures.append(\"safe target\")\n```\n\nPrefer named specs:\n\n```python\n@dataclass(frozen=True)\nclass CheckSpec:\n    id: str\n    description: str\n    check: Callable[[TaskContext], bool]\n    repair_hint: str\n\nPRETASK_CHECKS = [\n    CheckSpec(\"context-search\", \"Context search completed\", lambda ctx: ctx.searched_context, \"Search existing implementations first.\"),\n    CheckSpec(\"tools-ready\", \"Required tools are available\", lambda ctx: ctx.tools_ready, \"Verify tool availability before editing.\"),\n    CheckSpec(\"safe-target\", \"Target path is safe to edit\", lambda ctx: not ctx.unsafe_target, \"Stop and ask before mutating protected config.\"),\n]\n\ndef evaluate_specs(ctx: TaskContext) -> list[CheckSpec]:\n    return [spec for spec in PRETASK_CHECKS if not spec.check(ctx)]\n```\n\nWhen to use:\n\n- pre-task checklists;\n- policy gates;\n- validation rules;\n- eligibility filters;\n- reusable rule explanations.\n\nAvoid when:\n\n- checks need one-off local context and will not be reused;\n- a simple validation function is clearer;\n- check order has side effects that should be explicit.\n\nVerification:\n\n- one test per spec;\n- one aggregate test for multiple failures;\n- one test proving descriptions\u002Fhints are stable if user-facing.\n\n## Template Method plus Strategy\n\nUse when two functions share a skeleton but differ in provider, parser, storage, language, or platform behavior.\n\nShape:\n\n```python\nclass FunctionExtractor(ABC):\n    def extract(self, path: Path) -> list[FunctionInfo]:\n        source = self._read_source(path)\n        raw = self._parse_signatures(source, path)\n        calls = self._count_calls(source)\n        return self._enrich(raw, calls)\n\n    @abstractmethod\n    def _parse_signatures(self, source: str, path: Path) -> list[FunctionInfo]: ...\n\n    @abstractmethod\n    def _count_calls(self, source: str) -> dict[str, int]: ...\n\nclass PythonExtractor(FunctionExtractor): ...\nclass TypeScriptExtractor(FunctionExtractor): ...\n\nEXTRACTORS: dict[str, FunctionExtractor] = {\n    \".py\": PythonExtractor(),\n    \".ts\": TypeScriptExtractor(),\n    \".tsx\": TypeScriptExtractor(),\n}\n```\n\nWhen to use:\n\n- Python vs TypeScript extraction;\n- provider-specific request builders with shared validation\u002Fresponse handling;\n- platform adapters with shared envelope behavior;\n- storage backends with shared orchestration.\n\nAvoid when:\n\n- duplication is superficial and names differ but logic does not;\n- composition with small functions is enough;\n- inheritance would obscure data flow or make tests harder.\n\nVerification:\n\n- shared skeleton test using a fake strategy;\n- concrete strategy tests for each variant;\n- registry test for extension\u002Fprovider\u002Fplatform routing.\n\n## Pipeline \u002F Chain of Responsibility\n\nUse when content or data is transformed by a sequence of independent steps.\n\nReplaces long in-function transform chains:\n\n```python\ncontent = normalize_links(content)\ncontent = convert_captions(content)\ncontent = rewrite_youtube_embeds(content)\ncontent = sanitize_html(content)\nreturn content\n```\n\nPrefer explicit pipeline composition when the chain is growing:\n\n```python\nclass Transform(Protocol):\n    name: str\n    def apply(self, content: str) -> str: ...\n\nclass ContentPipeline:\n    def __init__(self, transforms: Sequence[Transform]) -> None:\n        self._transforms = list(transforms)\n\n    def process(self, content: str) -> str:\n        for transform in self._transforms:\n            content = transform.apply(content)\n        return content\n```\n\nWhen to use:\n\n- regex\u002Fcontent conversion;\n- AST or lint collector passes;\n- data cleaning stages;\n- request\u002Fresponse middleware;\n- hook enrichment\u002Frendering steps.\n\nAvoid when:\n\n- the order is fixed and only two simple lines;\n- transforms share hidden mutable state;\n- failure handling needs transaction semantics rather than a linear chain.\n\nVerification:\n\n- unit test each transform;\n- integration test the ordered pipeline;\n- test that order-sensitive transforms stay in the documented order.\n\n## Testing playbook for pattern refactors\n\n1. Characterize the existing behavior with narrow tests before changing code.\n2. Include edge cases that motivated the pattern, not only the happy path.\n3. Refactor in the smallest slice that preserves public behavior.\n4. Run focused tests after each slice.\n5. Run the local project quality gate only after the focused tests pass.\n6. If a hook\u002Flint backstop denies the refactor, repair the design. Do not suppress the rule.\n\nGood test shapes:\n\n- Dispatch tables: registered key, unsupported key, handler exception path.\n- Guard clauses: missing input\u002Fconfig, invalid input, happy path.\n- State machines: each transition, final flush, malformed\u002Fincomplete input.\n- Specs: individual pass\u002Ffail, aggregated failures, user-facing hint text.\n- Strategy\u002Ftemplate: fake strategy for skeleton, concrete strategy for variants.\n- Pipelines: individual transforms, ordered integration, idempotency where expected.\n\n## Anti-patterns this skill should prevent\n\n- Pattern theater: adding abstract base classes for one local if statement.\n- Registry without tests: moving branches into a dict but not proving each key works.\n- State enum cosplay: enum exists but boolean flags still drive the real behavior.\n- Over-shared template: forcing different flows into one inheritance tree until each override is a workaround.\n- Pipeline opacity: transforms mutate hidden global state or silently depend on undocumented order.\n- Refactor without behavior lock: \"cleaner\" code with no test proving equivalence.\n\n## Slopgate rule-to-pattern trigger map\n\nLoad this skill when Slopgate fires these rules:\n\n| Slopgate Rule | Pattern to Apply | Section |\n|---------------|------------------|---------|\n| `PY-CODE-014` god class | Extract collaborator by data + responsibility | State Pattern \u002F Template Method |\n| `PY-CODE-017` flat siblings | Package split with `__init__.py` facade | Dispatch Table (for package API) |\n| `PY-CODE-018` oversized module | Identify seams → package split | Pipeline \u002F Template Method |\n| `QUALITY-LINT-001` long-method | Extract helpers by phase | Pipeline \u002F Guard Clauses |\n| `QUALITY-LINT-001` repeated-code-block | Extract shared helper\u002Fservice | Template Method + Strategy |\n| `PY-QUALITY-010` magic numbers | Specification Pattern for policy constants | Specification Pattern |\n| `PY-CODE-012` thin wrappers | Inline or add real boundary | Guard Clauses \u002F Specification |\n| `PY-CODE-013` feature envy | Move behavior to envied owner | State Pattern \u002F direct method |\n\n## Agent prompt\u002Frule integration snippet\n\nUse this as thin routing text in Claude, OpenCode, Codex, or Cursor markdown; keep this full skill as the canonical playbook:\n\n```text\nWhen editing code with branching or duplicated control flow, check for these refactor opportunities before writing:\n- 3+ if\u002Felif branches selecting behavior by key\u002Ftype\u002Fprotocol\u002Fprovider\u002Fevent -> dispatch table\u002Fregistry.\n- nested happy path -> guard clauses.\n- boolean flags modeling parser\u002Fworkflow state -> enum state machine.\n- repeated validation\u002Fpolicy booleans -> specification objects.\n- duplicated skeleton with variant parsing\u002Fprovider\u002Fplatform behavior -> template method + strategy.\n- ordered regex\u002Fcontent\u002Fdata transforms -> pipeline\u002Fchain.\n\nIf two or more triggers appear, load skill intelligent-coding-patterns before editing. Do not introduce these patterns for single-use or obviously simpler code. Add or identify behavior-locking tests before refactoring.\n```\n\n## Slopgate hook guidance\n\nFor advisory hook responses, prefer solution-first language:\n\n```text\n[QUALITY-PATTERN-002 | ADVISORY | PRE-WRITE]\nThis looks like behavior dispatch by protocol with 5 branches. Prefer a registry mapping protocol -> handler. Load intelligent-coding-patterns, section Dispatch Table. If this is intentionally local\u002Fsimple, keep the direct branch and document why.\n```\n\nStart advisory-first for these pattern smells. Promote to blocking only for high-confidence cases such as new boolean-flag parser loops without tests, new 5+ branch key dispatch chains, or repeated ignored advisories on the same file\u002Frule.\n",{"name":5,"author":63,"license":15,"version":64,"metadata":65,"description":98,"compatibility":99},"Slopgate","1.0.0",{"hermes":66,"slopgate":77},{"tags":67,"related_skills":73},[68,69,70,71,72],"slopgate","design-patterns","dispatch","state-machines","refactor",[74,75,76],"slopgate-code-hygiene-refactor","slopgate-code-smell-utility-locator","slopgate-test-extender",{"rule_ids":78,"activation":87},[79,80,81,82,83,84,85,86],"PY-CODE-012","PY-CODE-013","PY-CODE-014","PY-CODE-017","PY-CODE-018","PY-QUALITY-010","QUALITY-LINT-001","QUALITY-PATTERN-002",{"avoid":88,"primary":92},[89,90,91],"two-branch cleanup","style-only edits","speculative abstraction",[93,94,95,96,97],"pattern selection","dispatch chains","state machines","policy predicates","pipelines","Pattern-selection playbook for agents editing code with complex branching, stateful parsers\u002Fworkflows, duplicated skeletons, policy checks, or ordered transforms. Load before refactoring if\u002Felif dispatch chains, boolean-flag state machines, repeated validation predicates, parallel provider\u002Flanguage implementations, or regex\u002Fcontent transformation pipelines. Also load when asked to \"apply a design pattern\", \"which pattern should I use here\", \"refactor this switch statement\", \"replace if-elif chain\", \"state machine pattern\", \"strategy pattern\", \"template method\", \"pipeline pattern\", \"specification pattern\", \"dispatch table\", \"guard clause refactor\", \"reduce cyclomatic complexity\", or when Slopgate fires PY-CODE-014, PY-CODE-017, PY-CODE-018, QUALITY-LINT-001, or PY-QUALITY-010. Use with behavior-locking tests and avoid pattern theater for simple one-off code.\n","claude-code, opencode, codex, hermes, slopgate","master","5fab8004af1390aa17b3447f2780766c8bf2482c",".codex\u002Fskills\u002Fslopgate-intelligent-coding-patterns",0,"https:\u002F\u002Fgithub.com\u002Fvasceannie\u002Fslopgate","https:\u002F\u002Fgithub.com\u002Fvasceannie","thingswithstuff.io","2026-11-12 20:22:46",{"source":8,"skillName":5,"commands":109,"prompt":119,"zipAvailable":120},[110,113,116],{"tool":111,"command":112},"npx","npx skills add vasceannie\u002Fslopgate --skill slopgate-intelligent-coding-patterns",{"tool":114,"command":115},"bunx","bunx skills add vasceannie\u002Fslopgate --skill slopgate-intelligent-coding-patterns",{"tool":117,"command":118},"pnpm","pnpm dlx skills add vasceannie\u002Fslopgate --skill slopgate-intelligent-coding-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fvasceannie\u002Fslopgate\u002Fblob\u002Fmaster\u002F.codex\u002Fskills\u002Fslopgate-intelligent-coding-patterns\u002FSKILL.md",true,[],[123,148,172,182,207,227],{"skillNo":124,"name":125,"nameZh":6,"description":126,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":127,"categories":128,"keywords":130,"publishedAt":58},"01M71951JDWCYMS8GDC2C7395D","type-strictness","Enforce strict type compliance by eliminating `Any` types and `# type: ignore` comments. Use when:\n(1) Editing code that contains `Any` as a type annotation\n(2) Code has `# type: ignore` or `# pyright: ignore` comments\n(3) User requests type fixes or type strictness enforcement\n(4) Importing from untyped third-party libraries\n(5) User asks to \"fix types\", \"remove Any\", or \"add proper typing\"\n(6) Pyrefly or mypy reports type errors that need resolution\n(7) Code review reveals weak typing patterns\nFollows hierarchical resolution: codebase inference → type stubs → library inspection → type guards → casting (last resort).","https:\u002F\u002Fgithub.com\u002Fvasceannie\u002Fslopgate\u002Fblob\u002Fmaster\u002Fbundle\u002Fshared\u002Fskills\u002Ftype-strictness\u002FSKILL.md",[129],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[131,132,133,134,135,136,137,138,139,44,42,140,141,142,143,144,145,146,147,39],"type","type strictness","typing","types","remove","code review","fix","errors","inspection","review","reports","libraries","casting","pyrefly","mypy","pyright","library",{"skillNo":149,"name":76,"nameZh":6,"description":150,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":151,"categories":152,"keywords":157,"publishedAt":58},"01M7194XGBQXSE7Y5BZ4K5CSTK","Extend Python test suites with parametrization, fixture reuse, and quality enforcement. Use when asked to add tests, extend existing tests, improve test coverage, consolidate duplicate tests, fix test quality issues, or when Slopgate reports untested-production-code, missing test references, or coverage gaps. Triggers on requests like \"add tests for X\", \"extend these tests\", \"parametrize tests\", \"consolidate tests\", \"fix test quality\", \"improve test coverage\", \"write tests for this function\", \"test this module\", \"behavior tests\", \"integration tests\", \"missing tests\", \"coverage holes\", \"untested code\", or when a hook denies with test-related findings.","https:\u002F\u002Fgithub.com\u002Fvasceannie\u002Fslopgate\u002Fblob\u002Fmaster\u002Fbundle\u002Fshared\u002Fskills\u002Fslopgate-test-extender\u002FSKILL.md",[153,154],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":155,"categoryName":156,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量",[158,159,160,161,162,137,163,164,165,48,47,166,44,42,167,168,141,169,170,171],"slopgate test extender","test","coverage","fixture","testing","issues","write tests","improve","loop","candidate","consolidate","references","opencode","orchestrator",{"skillNo":173,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":174,"categories":175,"keywords":181,"publishedAt":58},"01M7194RMVQS5YJJ4ZEFXX20VS","https:\u002F\u002Fgithub.com\u002Fvasceannie\u002Fslopgate\u002Fblob\u002Fmaster\u002Fbundle\u002Fshared\u002Fskills\u002Fslopgate-intelligent-coding-patterns\u002FSKILL.md",[176,177,178,179,180],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":27,"categoryName":28,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":30,"categoryName":31,"taxonomyType":32,"taxonomyTypeDesc":33},{"categoryNo":35,"categoryName":36,"taxonomyType":32,"taxonomyTypeDesc":33},[41,38,39,40,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42],{"skillNo":183,"name":184,"nameZh":6,"description":185,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":186,"categories":187,"keywords":190,"publishedAt":58},"01M7194KTXBM85GB0W7JKFQD55","slopgate-hygiene-orchestrator","Orchestrate systematic elimination of linter warnings and errors across Python, TypeScript, and Rust codebases. Use when asked to \"clean up lints\", \"fix all warnings\", \"run hygiene\", \"eliminate type errors\", \"orchestrate code quality fixes\", \"fix lint errors\", \"resolve quality gate failures\", \"pass CI checks\", \"reduce tech debt\", \"refactor to pass hooks\", or when a Slopgate hook denies with QUALITY-LINT-001, PY-CODE-017, PY-CODE-018, or any collector finding. This skill coordinates multiple code-hygiene-enforcer agents working in parallel on non-conflicting file groupings, tracks progress persistently via JSON exports, and loops until all issues are resolved. CRITICAL: Never run linters directly—always use `slopgate lint check` as the primary gate, discover project-specific tools from config files, and export findings to JSON for tracking.","https:\u002F\u002Fgithub.com\u002Fvasceannie\u002Fslopgate\u002Fblob\u002Fmaster\u002Fbundle\u002Fshared\u002Fskills\u002Fslopgate-hygiene-orchestrator\u002FSKILL.md",[188,189],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":27,"categoryName":28,"taxonomyType":21,"taxonomyTypeDesc":22},[191,192,171,193,137,194,195,196,197,198,47,43,199,200,201,202,203,204,205,206],"slopgate hygiene orchestrator","hygiene","project","ci","local","clean","never run","files","run","lint check","systematic","config","typescript","debt","quality-gates","hook",{"skillNo":208,"name":75,"nameZh":6,"description":209,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":210,"categories":211,"keywords":214,"publishedAt":58},"01M7194G50FZYXXT8VNK360RPA","Autoactivate when code-smell hooks or reviews mention feature envy, thin wrappers, duplicate helpers, duplicate code,\nscattered helpers, builders\u002Ffactories\u002Fconfig\u002Fconstants\u002Fdataclass reuse, PY-CODE-012, PY-CODE-013, QUALITY-LINT-001,\nor repeated slopgate code-quality denials. Also load when asked to \"find existing helpers\", \"consolidate utilities\",\n\"search for duplicate code\", \"where is this already implemented\", \"reuse existing logic\", \"don't duplicate this\",\n\"find similar functions\", \"utility inventory\", \"code smell radar\", or before adding new helpers\u002Fwrappers so agents can\nfind existing shared utilities and consolidate instead of duplicating.","https:\u002F\u002Fgithub.com\u002Fvasceannie\u002Fslopgate\u002Fblob\u002Fmaster\u002Fbundle\u002Fshared\u002Fskills\u002Fslopgate-code-smell-utility-locator\u002FSKILL.md",[212,213],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":30,"categoryName":31,"taxonomyType":32,"taxonomyTypeDesc":33},[46,215,42,216,160,217,218,219,220,48,221,44,222,168,170,223,224,202,225,226],"slopgate code smell utility locator","shared","reviews","inventory","search","hooks","new","coordination","radar","code-quality","Utilities","dataclass",{"skillNo":228,"name":74,"nameZh":6,"description":229,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":230,"categories":231,"keywords":234,"publishedAt":58},"01M7194AWG1Q37F9756H4SFDH9","Recovery playbook for Slopgate and project quality failures. Load after hook\u002Flint denials such as PY-CODE-017 flat sibling modules, PY-CODE-018 oversized modules, QUALITY-LINT-001 post-edit quality backstops, PY-QUALITY-010 magic numbers \u002F repeated literals, PY-CODE-012\u002FPY-CODE-013 smell findings, type-suppression bans, duplicate helpers, or repeated hygiene retry loops. Also load when asked to \"refactor this module\", \"split this file\", \"extract a class\", \"reduce complexity\", \"fix god class\", \"flatten module hierarchy\", \"move code to a package\", \"extract helpers\", \"consolidate duplicates\", \"replace magic numbers with constants\", or when a hook blocks an edit with structural complaints. Focuses on preserving public APIs while refactoring toward packages, cohesive modules, typed seams, and focused tests.","https:\u002F\u002Fgithub.com\u002Fvasceannie\u002Fslopgate\u002Fblob\u002Fmaster\u002Fbundle\u002Fshared\u002Fskills\u002Fslopgate-code-hygiene-refactor\u002FSKILL.md",[232,233],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":30,"categoryName":31,"taxonomyType":32,"taxonomyTypeDesc":33},[235,236,42,72,192,237,56,238,239,193,240,218,241,137,48,46,44,43,222,168],"code hygiene","slopgate code hygiene refactor","modules","duplicates","retry","move","structural"]