$npx -y skills add deepklarity/harness-kit --skill hk-compoundCompound a learning into a reusable pattern. Use after solving a non-trivial problem, discovering a principle worth reusing, or hitting a gotcha that would bite someone else. Triggers on: 'document this', 'capture this learning', 'that was tricky', 'let's compound this', 'compoun
| 1 | # /hk-compound — Compound a Pattern |
| 2 | |
| 3 | Extract the transferable principle from what just happened and add it to the pattern library. The goal is not to document an incident — it's to name a reusable pattern that gets richer over time as more instances accumulate under it. |
| 4 | |
| 5 | ## The unit: a pattern |
| 6 | |
| 7 | A pattern is a named, transferable principle. It starts lean — a clear statement and one instance. It grows as you encounter more cases. The value compounds because each new instance sharpens the principle and makes it easier to recognize next time. |
| 8 | |
| 9 | This is not a post-mortem filing system. Don't capture "what happened." Capture "what's the reusable insight, and how would I recognize this situation again?" |
| 10 | |
| 11 | ## When to use |
| 12 | |
| 13 | - You solved something and the *principle* behind the fix applies beyond this specific case |
| 14 | - You noticed a recurring shape across multiple situations |
| 15 | - You made a trade-off decision worth remembering the reasoning for |
| 16 | - You hit a gotcha that has a recognizable signal before you fall into it |
| 17 | |
| 18 | Skip it for: one-off fixes with no transferable insight, trivial config, things that are obvious once you know them. |
| 19 | |
| 20 | ## Context hint |
| 21 | |
| 22 | <context_hint> #$ARGUMENTS </context_hint> |
| 23 | |
| 24 | If the context hint above is empty, scan the conversation for the most significant learning — the thing that took the most investigation or had the most non-obvious outcome. Focus on extracting the transferable principle, not recapping the incident. |
| 25 | |
| 26 | ## Process |
| 27 | |
| 28 | ### Step 1: Extract the pattern |
| 29 | |
| 30 | Spawn a haiku subagent to analyze the conversation. The subagent returns text only — no file writes. |
| 31 | |
| 32 | ``` |
| 33 | Task(model: haiku, subagent_type: general-purpose) |
| 34 | |
| 35 | Prompt: "You have access to the full conversation context. Extract: |
| 36 | |
| 37 | 1. PATTERN NAME: A short, memorable name for the principle (e.g., 'Verify Preconditions Before Flags', 'Information Density via Progressive Disclosure'). Not a description of what happened — a name for the reusable idea. |
| 38 | |
| 39 | 2. THE PRINCIPLE: 1-3 sentences. The transferable insight stated clearly enough that someone unfamiliar with the specific situation would understand and be able to apply it. No jargon without explanation. |
| 40 | |
| 41 | 3. WHY IT MATTERS: 1-2 sentences. What goes wrong when you ignore this? What do you gain by following it? Be concrete. |
| 42 | |
| 43 | 4. THE SIGNAL: How would you recognize that this pattern applies? What does the situation look like right before you need this? (If unclear from a single instance, say so — this can be added later.) |
| 44 | |
| 45 | 5. THIS INSTANCE: A brief description of what happened in this conversation that surfaced the pattern. Include specifics — error messages, file paths, code snippets — but keep it to a few lines. Date it. |
| 46 | |
| 47 | 6. TAGS: 3-5 lowercase hyphenated keywords for grep discovery. |
| 48 | |
| 49 | Be concrete and specific. No filler. If you can't articulate a transferable principle — if it's just 'we fixed X by doing Y' with no broader lesson — say so." |
| 50 | ``` |
| 51 | |
| 52 | If the subagent can't find a transferable principle, tell the user and skip. Not everything needs to be compounded. |
| 53 | |
| 54 | ### Step 2: Check for existing patterns |
| 55 | |
| 56 | Search `docs/patterns/` for related patterns: |
| 57 | |
| 58 | ``` |
| 59 | Grep: pattern="<keywords from tags and pattern name>" path=docs/patterns/ output_mode=files_with_matches -i=true |
| 60 | ``` |
| 61 | |
| 62 | Three outcomes: |
| 63 | |
| 64 | - **Existing pattern matches**: This is a new instance of that pattern. Go to Step 3a. |
| 65 | - **Related but different**: Create a new pattern. Mention the related one in the doc. |
| 66 | - **Nothing related**: Create a new pattern. |
| 67 | |
| 68 | ### Step 3a: Add instance to existing pattern |
| 69 | |
| 70 | Read the existing pattern file. Append the new instance under `## Instances`. If the new instance sharpens the principle or clarifies the signal, update those sections too — patterns are living docs. |
| 71 | |
| 72 | Then skip to Step 5. |
| 73 | |
| 74 | ### Step 3b: Create new pattern |
| 75 | |
| 76 | **File path**: `docs/patterns/<slugified-pattern-name>.md` |
| 77 | |
| 78 | No dates in filenames — patterns are living documents, not snapshots. Keep slugs short and descriptive. |
| 79 | |
| 80 | ```bash |
| 81 | mkdir -p docs/patterns/ |
| 82 | ``` |
| 83 | |
| 84 | Write the file using the structure below. |
| 85 | |
| 86 | ### Step 4: Write the pattern doc |
| 87 | |
| 88 | ```markdown |
| 89 | tags: tag-one, tag-two, tag-three |
| 90 | |
| 91 | # <Pattern Name> |
| 92 | |
| 93 | <The principle. 1-3 clear sentences. This is the part someone would quote in a PR review or bring up in a design discussion. State it plainly — if a smart person reading this for the first time can't immediately understand what you mean, rewrite it.> |
| 94 | |
| 95 | ## Why it matters |
| 96 | |
| 97 | <What goes wrong without this. What you gain with it. Keep it concrete — not "improves code quality" but "you'll spend 20 minutes debugging a misle |