$npx -y skills add humorless/clj-native-agent --skill clj-refactorScan files for mechanism/policy separation opportunities
| 1 | Scan the specified files or directory for opportunities to improve |
| 2 | mechanism/policy separation, following the principles below. |
| 3 | |
| 4 | ## What to Look For |
| 5 | |
| 6 | Using Arne Brasseur's definitions: |
| 7 | |
| 8 | **Mechanism** is code that is: |
| 9 | - Unopinionated and context-free |
| 10 | - Reusable across different business domains |
| 11 | - Easy to test in isolation |
| 12 | - Stable — changes slowly over time |
| 13 | |
| 14 | **Policy** is code that is: |
| 15 | - Opinionated — reflects current business decisions |
| 16 | - Contextual — tied to a specific domain |
| 17 | - Expected to change frequently |
| 18 | |
| 19 | The distinction is not in *what* the code does, but in *how* it is written. |
| 20 | The goal is to push code toward the edges of this spectrum. |
| 21 | |
| 22 | ## Diagnostic Heuristics |
| 23 | |
| 24 | When assessing where code sits on the spectrum, ask: |
| 25 | |
| 26 | - Does this code accept all its dependencies as explicit parameters, |
| 27 | or does it rely on defaults, globals, or implicit context? |
| 28 | (More explicit → more mechanism) |
| 29 | |
| 30 | - If you needed to reuse this logic elsewhere, would you call it |
| 31 | with different parameters, or copy-paste and modify it? |
| 32 | (Parametric reuse → mechanism; copy-paste reuse → policy) |
| 33 | |
| 34 | - Is this code expressing a stable technical fact, or a current |
| 35 | business decision? Business decisions belong in policy. |
| 36 | |
| 37 | - How hard-coded are the values? Hard-coded constants are a sign |
| 38 | that policy has leaked into mechanism. |
| 39 | |
| 40 | - Does this code prioritize convenience (easy) over explicitness |
| 41 | (simple)? Convenience-oriented defaults are often policy leaking |
| 42 | into mechanism. |
| 43 | |
| 44 | ## Your Task |
| 45 | |
| 46 | For each file or module examined, report: |
| 47 | |
| 48 | 1. **Mixed code** — functions or modules where mechanism and policy |
| 49 | are tangled together. Describe what is mixed and where the boundary |
| 50 | should be drawn. |
| 51 | |
| 52 | 2. **Extraction candidates** — pieces of mechanism that are currently |
| 53 | embedded in policy code and could be extracted into a separate |
| 54 | module or library. For each candidate, explain why it qualifies |
| 55 | as mechanism (context-free, stable, reusable). |
| 56 | |
| 57 | 3. **Misplaced policy** — business logic that has drifted into what |
| 58 | should be low-level mechanism. Describe what assumption is hidden |
| 59 | and where it belongs. |
| 60 | |
| 61 | 4. **Proposed refactoring** — for each finding, suggest a concrete |
| 62 | refactoring. Show the before/after structure, not just the principle. |
| 63 | |
| 64 | ## Constraints |
| 65 | |
| 66 | - Do not refactor prematurely. Only suggest extraction when a pattern |
| 67 | appears in at least two distinct use cases. |
| 68 | - Preserve existing behavior. This is a structural refactor, not a |
| 69 | rewrite of business logic. |
| 70 | - Keep suggestions grounded in the actual code. Do not propose |
| 71 | abstractions that have no evidence in the current codebase. |