@gcunharodrigues/wrxn 0.7.3 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/manifest.json CHANGED
@@ -298,11 +298,26 @@
298
298
  "class": "managed",
299
299
  "profile": "project"
300
300
  },
301
+ {
302
+ "path": ".claude/skills/resolving-merge-conflicts/SKILL.md",
303
+ "class": "managed",
304
+ "profile": "project"
305
+ },
301
306
  {
302
307
  "path": ".claude/skills/tdd/SKILL.md",
303
308
  "class": "managed",
304
309
  "profile": "project"
305
310
  },
311
+ {
312
+ "path": ".claude/skills/tdd/tests.md",
313
+ "class": "managed",
314
+ "profile": "project"
315
+ },
316
+ {
317
+ "path": ".claude/skills/tdd/mocking.md",
318
+ "class": "managed",
319
+ "profile": "project"
320
+ },
306
321
  {
307
322
  "path": ".claude/skills/tech-search/SKILL.md",
308
323
  "class": "managed",
@@ -343,6 +358,21 @@
343
358
  "class": "managed",
344
359
  "profile": "project"
345
360
  },
361
+ {
362
+ "path": ".claude/skills/write-a-skill/GLOSSARY.md",
363
+ "class": "managed",
364
+ "profile": "project"
365
+ },
366
+ {
367
+ "path": ".claude/skills/write-an-agent/SKILL.md",
368
+ "class": "managed",
369
+ "profile": "project"
370
+ },
371
+ {
372
+ "path": ".claude/skills/write-an-agent/EXAMPLES.md",
373
+ "class": "managed",
374
+ "profile": "project"
375
+ },
346
376
  {
347
377
  "path": ".claude/skills/audit/SKILL.md",
348
378
  "class": "managed",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gcunharodrigues/wrxn",
3
- "version": "0.7.3",
3
+ "version": "0.9.0",
4
4
  "description": "WRXN Kernel — installable AI operating system. Two profiles (project | workspace), pull-based updates, managed/seeded/state file classes.",
5
5
  "bin": {
6
6
  "wrxn": "bin/wrxn.cjs"
@@ -48,9 +48,18 @@ The goal is not a clean repro but a **higher reproduction rate**. Loop the trigg
48
48
 
49
49
  Stop and say so explicitly. List what you tried. Ask the user for: (a) access to whatever environment reproduces it, (b) a captured artifact (HAR file, log dump, core dump, screen recording with timestamps), or (c) permission to add temporary production instrumentation. Do **not** proceed to hypothesise without a loop.
50
50
 
51
- Do not proceed to Phase 2 until you have a loop you believe in.
51
+ ### Completion criterion a tight loop that goes red
52
52
 
53
- ## Phase 2Reproduce
53
+ Phase 1 is done when the loop is **tight** and **red-capable**: you can name **one command** a script path, a test invocation, a curl — that you have **already run at least once** (paste the invocation and its output), and that is:
54
+
55
+ - [ ] **Red-capable** — it drives the actual bug code path and asserts the **user's exact symptom**, so it can go red on this bug and green once fixed. Not "runs without erroring" — it must be able to _catch this specific bug_.
56
+ - [ ] **Deterministic** — same verdict every run (flaky bugs: a pinned, high reproduction rate, per above).
57
+ - [ ] **Fast** — seconds, not minutes.
58
+ - [ ] **Agent-runnable** — you can run it unattended; a human in the loop only via `scripts/hitl-loop.template.sh`.
59
+
60
+ If you catch yourself reading code to build a theory before this command exists, **stop — jumping straight to a hypothesis is the exact failure this skill prevents.** No red-capable command, no Phase 2.
61
+
62
+ ## Phase 2 — Reproduce + minimise
54
63
 
55
64
  Run the loop. Watch the bug appear.
56
65
 
@@ -60,7 +69,15 @@ Confirm:
60
69
  - [ ] The failure is reproducible across multiple runs (or, for non-deterministic bugs, reproducible at a high enough rate to debug against).
61
70
  - [ ] You have captured the exact symptom (error message, wrong output, slow timing) so later phases can verify the fix actually addresses it.
62
71
 
63
- Do not proceed until you reproduce the bug.
72
+ ### Minimise
73
+
74
+ Once it's red, shrink the repro to the **smallest scenario that still goes red**. Cut inputs, callers, config, data, and steps **one at a time**, re-running the loop after each cut — keep only what's load-bearing for the failure.
75
+
76
+ Why bother: a minimal repro shrinks the hypothesis space in Phase 3 (fewer moving parts left to suspect) and becomes the clean regression test in Phase 5.
77
+
78
+ Done when **every remaining element is load-bearing** — removing any one of them makes the loop go green.
79
+
80
+ Do not proceed until you have reproduced **and** minimised.
64
81
 
65
82
  ## Phase 3 — Hypothesise
66
83
 
@@ -5,6 +5,6 @@ description: Interview the user relentlessly about a plan or design until reachi
5
5
 
6
6
  Interview me relentlessly about every aspect of this plan until we reach a shared understanding. Walk down each branch of the design tree, resolving dependencies between decisions one-by-one. For each question, provide your recommended answer.
7
7
 
8
- Ask the questions one at a time.
8
+ Ask the questions one at a time, waiting for feedback on each question before continuing. Asking multiple questions at once is bewildering.
9
9
 
10
10
  If a question can be answered by exploring the codebase, explore the codebase instead.
@@ -2,6 +2,7 @@
2
2
  name: handoff
3
3
  description: Compact the current conversation into a handoff document for another agent to pick up.
4
4
  argument-hint: "What will the next session be used for?"
5
+ disable-model-invocation: true
5
6
  ---
6
7
 
7
8
  Write a handoff document summarising the current conversation so a fresh agent can continue the work.
@@ -51,3 +51,63 @@ What maintainers get from depth. Change, bugs, knowledge, and verification conce
51
51
  - **Depth as ratio of implementation-lines to interface-lines** (Ousterhout): rewards padding the implementation. We use depth-as-leverage instead.
52
52
  - **"Interface" as the TypeScript `interface` keyword or a class's public methods**: too narrow — interface here includes every fact a caller must know.
53
53
  - **"Boundary"**: overloaded with DDD's bounded context. Say **seam** or **interface**.
54
+
55
+ ## Deep vs shallow
56
+
57
+ **Deep module** — small interface, lots of implementation:
58
+
59
+ ```
60
+ ┌─────────────────────┐
61
+ │ Small Interface │ ← Few methods, simple params
62
+ ├─────────────────────┤
63
+ │ │
64
+ │ Deep Implementation│ ← Complex logic hidden
65
+ │ │
66
+ └─────────────────────┘
67
+ ```
68
+
69
+ **Shallow module** — large interface, little implementation (avoid):
70
+
71
+ ```
72
+ ┌─────────────────────────────────┐
73
+ │ Large Interface │ ← Many methods, complex params
74
+ ├─────────────────────────────────┤
75
+ │ Thin Implementation │ ← Just passes through
76
+ └─────────────────────────────────┘
77
+ ```
78
+
79
+ When designing an interface, ask:
80
+
81
+ - Can I reduce the number of methods?
82
+ - Can I simplify the parameters?
83
+ - Can I hide more complexity inside?
84
+
85
+ ## Designing for testability
86
+
87
+ Good interfaces make testing natural.
88
+
89
+ **Accept dependencies, don't create them.** A module handed its collaborators can be tested with fakes; one that constructs them internally can't.
90
+
91
+ ```typescript
92
+ // Testable
93
+ function processOrder(order, paymentGateway) {}
94
+
95
+ // Hard to test
96
+ function processOrder(order) {
97
+ const gateway = new StripeGateway();
98
+ }
99
+ ```
100
+
101
+ **Return results, don't produce side effects.** A function that returns a value is checked by reading its output; one that mutates state forces the test to rebuild that state first.
102
+
103
+ ```typescript
104
+ // Testable
105
+ function calculateDiscount(cart): Discount {}
106
+
107
+ // Hard to test
108
+ function applyDiscount(cart): void {
109
+ cart.total -= discount;
110
+ }
111
+ ```
112
+
113
+ **Small surface area.** Fewer methods = fewer tests needed. Fewer params = simpler test setup.
@@ -0,0 +1,14 @@
1
+ ---
2
+ name: resolving-merge-conflicts
3
+ description: "Use when you need to resolve an in-progress git merge/rebase conflict."
4
+ ---
5
+
6
+ 1. **See the current state** of the merge/rebase. Check git history, and the conflicting files.
7
+
8
+ 2. **Find the primary sources** for each conflict. Understand deeply why each change was made, and what the original intent was. Read the commit messages, check the PRs, check original issues/tickets.
9
+
10
+ 3. **Resolve each hunk.** Preserve both intents where possible. Where incompatible, pick the one matching the merge's stated goal and note the trade-off. Do **not** invent new behaviour. Always resolve; never `--abort`.
11
+
12
+ 4. Discover the project's **automated checks** and run them — run the configured test command `$WRXN_TEST_CMD` (falls back to `npm test`), plus any typecheck/format step. Fix anything the merge broke. Use `recon_impact` on the touched symbols to gauge the blast radius of each resolution.
13
+
14
+ 5. **Finish the merge/rebase.** Stage everything and commit. If rebasing, continue the rebase process until all commits are rebased.
@@ -18,5 +18,6 @@ verticality review → **tdd** → code review → security review → QA-walk
18
18
  ## Rules
19
19
 
20
20
  - Tests and typecheck pass on **every commit** (Constitution Art. III). A red commit is not done.
21
- - Test external behavior, not implementation — internals stay refactorable.
21
+ - Test external behavior, not implementation — internals stay refactorable. For test quality see [tests.md](tests.md); for mocking at boundaries see [mocking.md](mocking.md).
22
22
  - One slice = one tracer bullet: independently buildable and walkable (Constitution Art. II).
23
+ - **No horizontal slices.** Do NOT write all tests first, then all code — bulk tests pin imagined behavior, not real. One test → one impl → repeat, each cycle learning from the last.
@@ -0,0 +1,59 @@
1
+ # When to Mock
2
+
3
+ Mock at **system boundaries** only:
4
+
5
+ - External APIs (payment, email, etc.)
6
+ - Databases (sometimes - prefer test DB)
7
+ - Time/randomness
8
+ - File system (sometimes)
9
+
10
+ Don't mock:
11
+
12
+ - Your own classes/modules
13
+ - Internal collaborators
14
+ - Anything you control
15
+
16
+ ## Designing for Mockability
17
+
18
+ At system boundaries, design interfaces that are easy to mock:
19
+
20
+ **1. Use dependency injection**
21
+
22
+ Pass external dependencies in rather than creating them internally:
23
+
24
+ ```typescript
25
+ // Easy to mock
26
+ function processPayment(order, paymentClient) {
27
+ return paymentClient.charge(order.total);
28
+ }
29
+
30
+ // Hard to mock
31
+ function processPayment(order) {
32
+ const client = new StripeClient(process.env.STRIPE_KEY);
33
+ return client.charge(order.total);
34
+ }
35
+ ```
36
+
37
+ **2. Prefer SDK-style interfaces over generic fetchers**
38
+
39
+ Create specific functions for each external operation instead of one generic function with conditional logic:
40
+
41
+ ```typescript
42
+ // GOOD: Each function is independently mockable
43
+ const api = {
44
+ getUser: (id) => fetch(`/users/${id}`),
45
+ getOrders: (userId) => fetch(`/users/${userId}/orders`),
46
+ createOrder: (data) => fetch('/orders', { method: 'POST', body: data }),
47
+ };
48
+
49
+ // BAD: Mocking requires conditional logic inside the mock
50
+ const api = {
51
+ fetch: (endpoint, options) => fetch(endpoint, options),
52
+ };
53
+ ```
54
+
55
+ The SDK approach means:
56
+ - Each mock returns one specific shape
57
+ - No conditional logic in test setup
58
+ - Easier to see which endpoints a test exercises
59
+ - Type safety per endpoint
@@ -0,0 +1,61 @@
1
+ # Good and Bad Tests
2
+
3
+ ## Good Tests
4
+
5
+ **Integration-style**: Test through real interfaces, not mocks of internal parts.
6
+
7
+ ```typescript
8
+ // GOOD: Tests observable behavior
9
+ test("user can checkout with valid cart", async () => {
10
+ const cart = createCart();
11
+ cart.add(product);
12
+ const result = await checkout(cart, paymentMethod);
13
+ expect(result.status).toBe("confirmed");
14
+ });
15
+ ```
16
+
17
+ Characteristics:
18
+
19
+ - Tests behavior users/callers care about
20
+ - Uses public API only
21
+ - Survives internal refactors
22
+ - Describes WHAT, not HOW
23
+ - One logical assertion per test
24
+
25
+ ## Bad Tests
26
+
27
+ **Implementation-detail tests**: Coupled to internal structure.
28
+
29
+ ```typescript
30
+ // BAD: Tests implementation details
31
+ test("checkout calls paymentService.process", async () => {
32
+ const mockPayment = jest.mock(paymentService);
33
+ await checkout(cart, payment);
34
+ expect(mockPayment.process).toHaveBeenCalledWith(cart.total);
35
+ });
36
+ ```
37
+
38
+ Red flags:
39
+
40
+ - Mocking internal collaborators
41
+ - Testing private methods
42
+ - Asserting on call counts/order
43
+ - Test breaks when refactoring without behavior change
44
+ - Test name describes HOW not WHAT
45
+ - Verifying through external means instead of interface
46
+
47
+ ```typescript
48
+ // BAD: Bypasses interface to verify
49
+ test("createUser saves to database", async () => {
50
+ await createUser({ name: "Alice" });
51
+ const row = await db.query("SELECT * FROM users WHERE name = ?", ["Alice"]);
52
+ expect(row).toBeDefined();
53
+ });
54
+
55
+ // GOOD: Verifies through interface
56
+ test("createUser makes user retrievable", async () => {
57
+ const user = await createUser({ name: "Alice" });
58
+ const retrieved = await getUser(user.id);
59
+ expect(retrieved.name).toBe("Alice");
60
+ });
61
+ ```
@@ -19,6 +19,8 @@ Work from whatever is already in the conversation context. If the user passes an
19
19
 
20
20
  If you have not already explored the codebase, do so to understand the current state of the code. Issue titles and descriptions should use the project's domain glossary vocabulary, and respect ADRs in the area you're touching.
21
21
 
22
+ Look for opportunities to prefactor the code to make the implementation easier. "Make the change easy, then make the easy change."
23
+
22
24
  ### 3. Draft vertical slices
23
25
 
24
26
  Break the plan into **tracer bullet** issues. Each issue is a thin vertical slice that cuts through ALL integration layers end-to-end, NOT a horizontal slice of one layer.
@@ -11,7 +11,7 @@ The issue tracker and triage label vocabulary should have been provided to you
11
11
 
12
12
  1. Explore the repo to understand the current state of the codebase, if you haven't already. Use the project's domain glossary vocabulary throughout the PRD, and respect any ADRs in the area you're touching.
13
13
 
14
- 2. Sketch out the seams at which you're going to test the feature. Existing seams should be preferred to new ones. Use the highest seam possible. If new seams are needed, propose them at the highest point you can.
14
+ 2. Sketch out the seams at which you're going to test the feature. Existing seams should be preferred to new ones. Use the highest seam possible. If new seams are needed, propose them at the highest point you can. The fewer seams across the codebase, the better - the ideal number is one.
15
15
 
16
16
  Check with the user that these seams match their expectations.
17
17
 
@@ -83,7 +83,11 @@ The maintainer may:
83
83
 
84
84
  ## When to write to `.out-of-scope/`
85
85
 
86
- Only when an **enhancement** (not a bug) is rejected as `wontfix`. The flow:
86
+ Only when an **enhancement** (not a bug) is rejected as `wontfix`.
87
+
88
+ Do **not** write here when something is closed as `wontfix` because it's **already implemented**. That's a built feature, not a rejected one; recording it would poison the dedup checks with false rejections. Instead, the closing comment points to where the feature already lives.
89
+
90
+ The flow:
87
91
 
88
92
  1. Maintainer decides a feature request is out of scope
89
93
  2. Check if a matching `.out-of-scope/` file already exists
@@ -60,7 +60,7 @@ Show counts and a one-line summary per issue. Let the maintainer pick.
60
60
 
61
61
  ## Triage a specific issue
62
62
 
63
- 1. **Gather context.** Read the full issue (body, comments, labels, reporter, dates). Parse any prior triage notes so you don't re-ask resolved questions. Explore the codebase using the project's domain glossary, respecting ADRs in the area. Read `.out-of-scope/*.md` and surface any prior rejection that resembles this issue.
63
+ 1. **Gather context.** Read the full issue (body, comments, labels, reporter, dates). Parse any prior triage notes so you don't re-ask resolved questions. Explore the codebase using the project's domain glossary, respecting ADRs in the area. Run two checks against the codebase: (a) **redundancy** — search for an existing implementation of the requested behavior by domain concept (not just the request's wording), and report where you looked. If found, it's an already-implemented `wontfix` (step 5). (b) **prior rejection** — read `.out-of-scope/*.md` and surface any prior rejection that resembles this issue.
64
64
 
65
65
  2. **Recommend.** Tell the maintainer your category and state recommendation with reasoning, plus a brief codebase summary relevant to the issue. Wait for direction.
66
66
 
@@ -72,6 +72,7 @@ Show counts and a one-line summary per issue. Let the maintainer pick.
72
72
  - `ready-for-agent` — post an agent brief comment ([AGENT-BRIEF.md](AGENT-BRIEF.md)).
73
73
  - `ready-for-human` — same structure as an agent brief, but note why it can't be delegated (judgment calls, external access, design decisions, manual testing).
74
74
  - `needs-info` — post triage notes (template below).
75
+ - `wontfix` (already implemented) — the change already exists in the codebase. Point to where it lives; do **not** write to `.out-of-scope/` (that KB is for *rejected* requests, not built ones).
75
76
  - `wontfix` (bug) — polite explanation, then close.
76
77
  - `wontfix` (enhancement) — write to `.out-of-scope/`, link to it from a comment, then close ([OUT-OF-SCOPE.md](OUT-OF-SCOPE.md)).
77
78
  - `needs-triage` — apply the role. Optional comment if there's partial progress.
@@ -0,0 +1,181 @@
1
+ # Glossary — Building Great Skills
2
+
3
+ The domain model for what makes a skill great. A skill exists to wrangle determinism out of a stochastic system; every term below is a lever on that goal. This is the disclosed reference for [`write-a-skill`](SKILL.md).
4
+
5
+ **Bold terms** in any definition are themselves defined in this glossary; find them by their heading.
6
+
7
+ ## Language
8
+
9
+ ### Predictability
10
+
11
+ The degree to which a skill makes the agent behave the same *way* on every run — the same process, not the same output (a brainstorming skill should *predictably* diverge; its tokens vary, its behaviour doesn't). The root virtue every other term serves — cost and maintainability are symptoms of it, not rivals.
12
+
13
+ _Avoid_: consistency, reliability, robustness, output-determinism
14
+
15
+ ### Model-Invoked
16
+
17
+ A skill that keeps its **description** field, so the agent can see it and fire it autonomously — and the human can still type its name, so model-invocation always *includes* user reach. There is no model-only state: a description only ever *adds* agent discovery, never removes the human's. Pays a permanent **context load** on every turn in exchange for that discoverability. Reachable by other skills, because the description that makes it agent-discoverable makes it invocable. A model-invoked skill whose content is all **reference** is also one home for shared reference: another skill can invoke it, so reference needed by several skills lives in one place. Pick model-invocation only when the agent must reach the skill on its own; if it never fires except by hand, drop the description and pay no context load.
18
+
19
+ _Avoid_: ability, tool, capability
20
+
21
+ ### User-Invoked
22
+
23
+ A skill with its **description** stripped — invisible to the agent and reachable only by the human typing its name (user-*only*, where **model-invoked** is user-*and-agent*). Trades agent-discoverability for zero **context load**. Because it has no description, nothing but the human can reach it: no other skill can fire it.
24
+
25
+ _Avoid_: procedure, workflow, command
26
+
27
+ ### Description
28
+
29
+ The skill's machine-readable trigger, and the one **context pointer** a **model-invoked** skill is forced to keep loaded at all times. Its mere presence *is* the invocation axis: keep it and the skill is model-invoked (and reachable by other skills); delete it and the skill is **user-invoked**, reachable only by the human. The source of a model-invoked skill's **context load**.
30
+
31
+ _Avoid_: frontmatter, summary
32
+
33
+ ### Context Pointer
34
+
35
+ A reference held in the agent's context that names some out-of-context material and encodes the condition for reaching it. The **description** is the top-level context pointer (context window → skill); pointers to disclosed files are the same object one level down. Its wording, not the target, decides *when* the agent reaches — and *how reliably*. A must-have target behind a weakly worded pointer is a variance bug: fix the wording first, and inline the material only if sharpening fails.
36
+
37
+ _Avoid_: link, reference, import
38
+
39
+ ### Context Load
40
+
41
+ The cost a **model-invoked** skill imposes on the agent's context window — its **description**, always loaded, spending both tokens and attention. What **user-invoked** skills escape by having no description, and the brake on splitting into more model-invoked skills.
42
+
43
+ _Avoid_: token cost, context bloat
44
+
45
+ ### Cognitive Load
46
+
47
+ The cost a **user-invoked** skill imposes on the human — what they must hold in their head: which skills exist and when to reach for each (the human is the index). What **model-invocation** removes by being agent-discoverable, and the brake on splitting into more user-invoked skills. Not a cost to minimise: it is the price of human agency, the reason some skills stay user-invoked. Spend it where human judgement matters; remove it where it does not.
48
+
49
+ _Avoid_: human index, burden, overhead
50
+
51
+ ### Granularity
52
+
53
+ How finely you divide skills. Finer division spends one of the two loads: more **model-invoked** skills spend **context load** (more descriptions crowding the window and competing for attention); more **user-invoked** skills spend **cognitive load** (more for the human to remember and reach for). Two cuts guide the division. By **invocation**, split off a model-invoked skill where you have a distinct **leading word** to trigger it — a trigger word you actually use in your prompts. By **sequence**, split a run of **steps** where a step's **post-completion steps** need hiding, since isolating it in its own context clears what follows. Beware the reverse: merging sequences exposes each step's post-completion steps to what follows, inviting premature completion.
54
+
55
+ _Avoid_: chunking, modularity
56
+
57
+ ### Router Skill
58
+
59
+ A **user-invoked** skill whose job is to point at your other user-invoked skills — naming each and when to reach for it — so the human has one skill to remember instead of many. It can only hint, never fire them: user-invoked skills have no **description**, so nothing but the human can reach them. The cure for **cognitive load** when user-invoked skills multiply.
60
+
61
+ _Avoid_: dispatcher, menu, registry, index, router procedure
62
+
63
+ ### Information Hierarchy
64
+
65
+ A skill's content ranked by how immediately the agent needs it — a single ladder, produced by two cuts: in-file or behind a pointer, and step or reference. The rungs:
66
+
67
+ - **Steps** — in-file, primary
68
+ - **Reference**, in-file — secondary
69
+ - **Reference**, disclosed — behind a **context pointer**
70
+
71
+ A skill with no **steps** uses just the bottom two rungs — often a legitimately flat peer-set (e.g. every rule of a review on one rung), which is a fine arrangement, not a smell. The hierarchy is independent of invocation: a skill can be model- or user-invoked whether it is all steps, all reference, or both. When a skill has steps, in-file reference that should be disclosed buries them and turns attending to them into a coin-flip — a variance lever, not just a legibility one. Keep the top of the ladder legible; push down it whatever you can.
72
+
73
+ _Avoid_: structure, organization, layout
74
+
75
+ ### Co-location
76
+
77
+ Keeping the material an agent needs at once in one place — a concept's definition, rules, and caveats under a single heading, not scattered across the file — so reading one part brings its neighbours with it. The within-file companion to the **Information Hierarchy**: the hierarchy ranks *how far down* a piece sits; co-location decides *what sits beside it* once there. There is no formula for the right format of a body of **reference**; the test is that a skill should read like documentation written for the agent, and grouped material reads that way where scattered material does not. Distinct from **Duplication**: that repeats one meaning in two places, where scattering fragments a single meaning across many.
78
+
79
+ _Avoid_: grouping, clustering, cohesion
80
+
81
+ ### Branch
82
+
83
+ A distinct way a skill can be invoked — a case the skill handles — so different runs take different paths through it. A skill with many steps may carry many branches; a linear one has none.
84
+
85
+ _Avoid_: path, case, fork
86
+
87
+ ### Progressive Disclosure
88
+
89
+ Moving **reference** down the ladder — out of SKILL.md and behind a **context pointer** — so the top stays legible. Not primarily a token optimisation; it is how the **information hierarchy** is protected. Licensed by **branching**: disclose what only some branches need, inline what every path needs, and if a pointer fires unreliably on must-have material, sharpen its wording, and pull it back inline only if that fails.
90
+
91
+ _Avoid_: lazy loading, chunking
92
+
93
+ ### Steps
94
+
95
+ The ordered actions the agent performs — when a skill has them, the primary tier of its content, and the part that earns its place in SKILL.md. Not every skill has steps: a skill can be all steps (`tdd`), all **reference** (a review), or both, independent of invocation. Every step ends on a **completion criterion**, clear or vague.
96
+
97
+ _Avoid_: workflow, instructions, choreography
98
+
99
+ ### Completion Criterion
100
+
101
+ The condition that tells the agent a unit of work is done — the target it judges against. Two properties make it a lever, not just a quality. Its **clarity** (can the agent tell done from not-done?) resists **premature completion** — a vague bound ("understanding reached") lets the agent declare done and slip to the next step; this axis needs *steps* to bite, since premature completion is a between-steps failure. Its **demand** (how much it requires) sets **legwork** — "every modified model accounted for" forces thorough work where "produce a change list" does not — and this axis is *not* step-bound: it can bind a body of flat reference too, which is how a skill with no steps still carries an exhaustiveness bar ("every rule applied"). The strongest criteria are both checkable and exhaustive.
102
+
103
+ _Avoid_: done condition, exit condition, stopping rule
104
+
105
+ ### Post-Completion Steps
106
+
107
+ The **steps** that follow the current step. Visible, they pull the agent forward into **premature completion** — the more it sees, the stronger the tug; the defence is to hide them by splitting the sequence of steps into two.
108
+
109
+ _Avoid_: horizon, fog of war, lookahead
110
+
111
+ ### Legwork
112
+
113
+ The work an agent does behind the scenes within a single step — reading files, exploring the codebase, making changes, digging up what it needs rather than offloading to the user. It lives below the step structure: never written as its own step, latent in the wording, controlled by the agent rather than the skill. The within-step counterpart to **post-completion steps**' across-step pull. Raised by a **leading word** (_comprehensive_, _thorough_) or a **completion criterion** that demands the work be exhaustive — including the demand axis applied to flat reference, which is what drives a skill of flat reference to cover all its rungs. Goes thin either when that demand is missing or when **premature completion** cuts the step short.
114
+
115
+ _Avoid_: scope, effort, diligence, coverage
116
+
117
+ ### Reference
118
+
119
+ Material the agent refers to on demand — definitions, facts, parameters, examples, conditional instructions. When a skill has **steps** it is secondary to them; when a skill has none it is the entire content; or it lives outside any skill entirely — see **External Reference**. Reached via **context pointers**, and the prime candidate for **progressive disclosure**.
120
+
121
+ _Avoid_: supporting material, docs, background
122
+
123
+ ### External Reference
124
+
125
+ **Reference** that lives outside the skill system — a plain file, no **description**, no **steps**, not invocable — that any skill can point at. The home for shared reference that needn't fire on its own, and the only shared home two **user-invoked** skills can use, since neither has a description and so neither can fire the other.
126
+
127
+ _Avoid_: doc, resource, knowledge base
128
+
129
+ ### Leading Word
130
+
131
+ A compact concept — also called a *Leitwort* — already living in the model's pretraining, that the agent thinks with while running the skill. It encodes a behavioural principle in the fewest possible tokens by invoking priors the model already holds (e.g. _lesson_, _proximal zone of development_, _fog of war_, _tracer bullets_). Repeated as a token, never as a sentence, it accumulates a distributed definition across the skill and anchors a whole region of behaviour. Coining your own works if you define it clearly, but a made-up word recruits no priors — you pay in definition tokens what a pretrained word gives free. Reach for an existing word first.
132
+
133
+ A leading word serves **predictability** twice. In the body it anchors **execution** — the agent reaches for the same behaviour every time the concept appears, and inside flat reference it focuses attention on a class of thing to look for, recruiting the right checks each run. In the **description** it anchors **invocation** — and not only within the skill: when the same word lives in your prompts, your docs, and your codebase, the agent links that shared language to the skill and fires it more reliably. Word a description with the leading words you actually use when you want the skill.
134
+
135
+ _Avoid_: keyword, term, motif
136
+
137
+ ### Single Source of Truth
138
+
139
+ The desired state where each meaning lives in exactly one authoritative place, so a change to the skill's behaviour is a change in one place. **Duplication** is its violation.
140
+
141
+ _Avoid_: home, canonical location
142
+
143
+ ### Relevance
144
+
145
+ Whether a line still bears on what the skill does — the lens for what to keep. A line loses relevance either by never bearing on the task (mere exposition, or a **branch** that should be disclosed) or by going stale: drifting out of date as the behaviour or world it describes changes. Shorter skills are easier to keep relevant, because each line is cheaper to check. Distinct from **no-op**: relevance asks whether a line bears on the task, not whether it changes behaviour.
146
+
147
+ _Avoid_: load-bearing, staleness, freshness
148
+
149
+ ## Failure Modes
150
+
151
+ ### Premature Completion
152
+
153
+ Ending the current step before it is genuinely done, because the agent's attention slips to being done rather than to the work. A between-steps failure: it needs **steps** to occur — a skill with no steps that quits early isn't premature completion but thin **legwork** under an unmet demand. A tug-of-war between two forces: visible **post-completion steps** (the pull forward) and the **completion criterion**'s clarity (the resistance — a sharp, checkable bar holds; a vague one gives way). Fuzziness is the necessary condition: a sharp bound resists the pull no matter how many later steps are visible, so a step that never rushes needs no defending. Two levers hold a step that does, but reach for them in order: **sharpen the bound first** — it is local and cheap. Only when the criterion is irreducibly fuzzy *and* you actually observe the rush do you **hide the later steps** — and hiding only works across a real context boundary (a user-invoked hand-off or a subagent dispatch; an inline model-invoked call leaves the later steps in context and clears nothing). One cause of thin legwork, but distinct from it: legwork can be thin even when a step runs to full completion.
154
+
155
+ _Avoid_: premature closure, the rush, rushing, shortcutting
156
+
157
+ ### Duplication
158
+
159
+ The same meaning given more than one **single source of truth**. It costs maintenance (change one place, you must change the others), costs tokens, and inflates prominence — repeating a meaning weights it on the ladder past its real rank. The accidental inverse of a **leading word**, which raises attention on purpose by repeating a token, never the meaning.
160
+
161
+ _Avoid_: repetition, redundancy
162
+
163
+ ### Sediment
164
+
165
+ Layers of old content that settle in a skill and are never cleared, because adding feels safe and removing feels risky — so stale and irrelevant lines accumulate and you must core down through them to find what is still live. The default fate of any skill without a pruning discipline; the slow erosion of **relevance**, as opposed to **duplication**'s repeated meaning.
166
+
167
+ _Avoid_: accretion, bloat, cruft, rot
168
+
169
+ ### Sprawl
170
+
171
+ A skill that is simply too long — too many lines in SKILL.md — independent of whether they are stale or repeated. Even an all-live, all-unique skill can sprawl. It costs readability (the agent wades through more before it can act, and attention thins across the excess), maintainability (every extra line is one more to keep **relevant**), and tokens. The cure is the **information hierarchy**: push **reference** down behind **context pointers**, and split by **branch** or sequence so each path carries only what it needs. Distinct from **sediment** (length from stale accumulation) and **duplication** (length from repeated meaning) — sprawl is length itself, whatever its cause.
172
+
173
+ _Avoid_: bloat, length, size, verbosity
174
+
175
+ ### No-Op
176
+
177
+ An instruction that changes nothing because the model already does it by default — you pay load to tell the agent what it would do anyway. The test: does a line change behaviour versus the default? A line can be perfectly **relevant** and still be a no-op. The same priors that make a **leading word** free make a no-op worthless.
178
+
179
+ A leading word is a *technique*; No-Op is a *verdict* on a line — and they cross. A leading word too weak to beat the default is a no-op (_be thorough_ when the agent is already thorough-ish), and the fix is a stronger word that passes the verdict (_relentless_), not a different technique. So the No-Op test — does it change behaviour versus the default? — is also how you grade whether a leading word is earning its repetitions. This is model-relative, not reader-relative: two people disagreeing over whether a line is a no-op disagree about the default, and settle it by running the skill, not by debate.
180
+
181
+ _Avoid_: redundant instruction, restating the obvious, belaboring
@@ -1,117 +1,123 @@
1
1
  ---
2
2
  name: write-a-skill
3
- description: Create new agent skills with proper structure, progressive disclosure, and bundled resources. Use when user wants to create, write, or build a new skill.
3
+ description: Author a predictable agent skill or sharpen an existing one — using the theory that earns predictability: the invocation tradeoff, the information-hierarchy ladder, leading words, completion criteria, and the failure-mode vocabulary. Use when someone wants to create, write, build, or improve a skill, design its structure or progressive disclosure, or says "write a skill", "new skill", or "make a skill".
4
4
  ---
5
5
 
6
- # Writing Skills
6
+ # Writing a Skill
7
7
 
8
- ## Process
9
-
10
- 1. **Gather requirements** - ask user about:
11
- - What task/domain does the skill cover?
12
- - What specific use cases should it handle?
13
- - Does it need executable scripts or just instructions?
14
- - Any reference materials to include?
15
-
16
- 2. **Draft the skill** - create:
17
- - SKILL.md with concise instructions
18
- - Additional reference files if content exceeds 500 lines
19
- - Utility scripts if deterministic operations needed
20
-
21
- 3. **Review with user** - present draft and ask:
22
- - Does this cover your use cases?
23
- - Anything missing or unclear?
24
- - Should any section be more/less detailed?
25
-
26
- ## Skill Structure
27
-
28
- ```
29
- skill-name/
30
- ├── SKILL.md # Main instructions (required)
31
- ├── REFERENCE.md # Detailed docs (if needed)
32
- ├── EXAMPLES.md # Usage examples (if needed)
33
- └── scripts/ # Utility scripts (if needed)
34
- └── helper.js
35
- ```
8
+ A skill exists to **wrangle determinism out of a stochastic system**. **Predictability** — the agent
9
+ taking the same *process* every run, not producing the same output — is the root virtue; every lever
10
+ below serves it. Author skills by reasoning from that virtue, not by filling a template.
36
11
 
37
- ## SKILL.md Template
12
+ **Scope:** the theory + a light process for writing skills *well*. For packaging mechanics (the
13
+ `init_skill.py` scaffold, `package_skill.py` validate-and-zip) use **skill-creator**; for a
14
+ separate-context subagent use **write-an-agent**. A skill is a workflow the agent follows inline.
38
15
 
39
- ```md
40
- ---
41
- name: skill-name
42
- description: Brief description of capability. Use when [specific triggers].
43
- ---
44
-
45
- # Skill Name
16
+ **Bold terms** are defined in **[GLOSSARY.md](GLOSSARY.md)** — the disclosed reference; consult it for
17
+ the full domain model.
46
18
 
47
- ## Quick start
19
+ ## Invocation — the first decision
48
20
 
49
- [Minimal working example]
21
+ Two choices, trading different costs:
50
22
 
51
- ## Workflows
23
+ | | Model-invoked | User-invoked |
24
+ |---|---|---|
25
+ | Reach | agent fires it autonomously + other skills + you by name | only you, by name |
26
+ | Cost | **context load** — the description sits in the window every turn | **cognitive load** — *you* are the index that must remember it |
27
+ | Mechanics | keep `description`, rich trigger phrasing | `disable-model-invocation: true` |
52
28
 
53
- [Step-by-step processes with checklists for complex tasks]
29
+ Pick model-invocation only when the agent (or another skill) must reach it on its own. **wrxn skills
30
+ are model-invoked: never set `disable-model-invocation`.** This skill's own frontmatter is the worked
31
+ example.
54
32
 
55
- ## Advanced features
33
+ ## The description — the routing lever
56
34
 
57
- [Link to separate files: See [REFERENCE.md](REFERENCE.md)]
58
- ```
35
+ The description is the one **context pointer** a model-invoked skill always keeps loaded, and the only
36
+ thing the agent sees when deciding to load. It does two jobs: state what the skill is, and list the
37
+ **branches** that should trigger it. Every word costs context load, so prune it harder than the body:
59
38
 
60
- ## Description Requirements
39
+ - **Front-load the leading word** — the description is where it does its invocation work.
40
+ - **One trigger per branch.** Synonyms renaming a single branch are **duplication** — collapse them.
41
+ - **Cut identity already in the body.** Keep triggers + any "when another skill needs…" reach clause.
42
+ - Third person; end on "Use when [specific triggers]".
61
43
 
62
- The description is **the only thing your agent sees** when deciding which skill to load. It's surfaced in the system prompt alongside all other installed skills. Your agent reads these descriptions and picks the relevant skill based on the user's request.
44
+ ## Information hierarchy where each piece sits
63
45
 
64
- **Goal**: Give your agent just enough info to know:
46
+ A skill is built from **steps** (ordered actions) and **reference** (definitions, rules, facts), mixed
47
+ freely. Rank every piece on the ladder by how immediately the agent needs it:
65
48
 
66
- 1. What capability this skill provides
67
- 2. When/why to trigger it (specific keywords, contexts, file types)
49
+ 1. **In-skill step** an ordered action in SKILL.md. The primary tier: what the agent does, in order.
50
+ 2. **In-skill reference** a rule or fact consulted on demand. Often a legitimately flat peer-set
51
+ (every rule of a review on one rung) — fine, not a smell.
52
+ 3. **Disclosed reference** — pushed into a sibling file (like this skill's GLOSSARY.md), reached by a
53
+ context pointer, loaded only when it fires.
68
54
 
69
- **Format**:
55
+ **Progressive disclosure** is the move down the ladder so the top stays legible — *licensed by
56
+ branching*: inline what every branch needs, push behind a pointer what only some branches reach. A
57
+ pointer's *wording*, not its target, decides when and how reliably the agent reaches the material.
70
58
 
71
- - Max 1024 chars
72
- - Write in third person
73
- - First sentence: what it does
74
- - Second sentence: "Use when [specific triggers]"
59
+ This ladder not a line budget — governs what stays in SKILL.md. It retires the old arbitrary rules
60
+ ("SKILL.md under 100 lines", "references one level deep"): **sprawl** is the disease, the ladder is the
61
+ cure. Push down whatever you can; keep the top legible.
75
62
 
76
- **Good example**:
63
+ ## Completion criteria — defeat premature completion
77
64
 
78
- ```
79
- Extract text and tables from PDF files, fill forms, merge documents. Use when working with PDF files or when user mentions PDFs, forms, or document extraction.
80
- ```
65
+ Each step ends on a **completion criterion** — the condition that tells the agent the work is done. The
66
+ strongest criteria are both:
81
67
 
82
- **Bad example**:
68
+ - **Checkable** — can the agent tell done from not-done? A vague bound ("understanding reached") invites
69
+ **premature completion**: the agent declares done and slips to the next step.
70
+ - **Exhaustive** where it matters — "every modified model accounted for", not "produce a change list".
71
+ The demand drives thorough **legwork**, and binds flat reference too ("every rule applied").
83
72
 
84
- ```
85
- Helps with documents.
86
- ```
73
+ Sharpening the bound is the cheapest defence against a rushed step — reach for it before any structural
74
+ fix.
87
75
 
88
- The bad example gives your agent no way to distinguish this from other document skills.
76
+ ## Leading words anchor behaviour in one token
89
77
 
90
- ## When to Add Scripts
78
+ A **leading word** (*Leitwort*) is a compact concept already living in the model's pretraining that the
79
+ agent thinks with while running the skill (*lesson*, *fog of war*, *tracer bullets*, *red*/*green*).
80
+ Repeated as a token — not as a sentence — it accumulates a distributed definition and anchors a whole
81
+ region of behaviour in the fewest tokens, by recruiting priors the model already holds. It serves
82
+ predictability twice: in the body it anchors *execution*; in the description it anchors *invocation*
83
+ (shared language across your prompts, docs, and code makes the agent fire the skill more reliably).
91
84
 
92
- Add utility scripts when:
85
+ Hunt restatements a leading word retires — "fast, deterministic, low-overhead" → *tight*; "a loop you
86
+ believe in" → *red*. Reach for an existing pretrained word first; a coined word recruits no priors, so
87
+ you pay in definition tokens what a pretrained word gives free.
93
88
 
94
- - Operation is deterministic (validation, formatting)
95
- - Same code would be generated repeatedly
96
- - Errors need explicit handling
89
+ ## Prune and the failure modes it prevents
97
90
 
98
- Scripts save tokens and improve reliability vs generated code.
91
+ - **Single source of truth** each meaning in exactly one place, so a change is a one-place edit.
92
+ - **Relevance** — does each line still bear on what the skill does? Cut stale lines.
93
+ - **No-op test** — does a line change behaviour versus the model's default? Hunt no-ops sentence by
94
+ sentence; when one fails, delete the whole sentence, don't trim words. Be aggressive. A weak leading
95
+ word (*be thorough* when the agent already is) is a no-op — fix with a stronger word (*relentless*).
99
96
 
100
- ## When to Split Files
97
+ Use this vocabulary to diagnose a misbehaving skill:
101
98
 
102
- Split into separate files when:
99
+ | Mode | What it is | Cure |
100
+ |---|---|---|
101
+ | **Premature completion** | a step ends before it's done; attention slips to *being done* | sharpen the criterion first; only then split to hide post-completion steps |
102
+ | **Duplication** | one meaning in two places | collapse to a single source of truth |
103
+ | **Sediment** | stale layers that settle because adding feels safe, removing risky | a pruning discipline (relevance) |
104
+ | **Sprawl** | simply too long, even when every line is live and unique | the ladder — disclose reference, split by branch |
105
+ | **No-op** | a line the model already obeys by default | delete it, or strengthen a weak leading word |
103
106
 
104
- - SKILL.md exceeds 100 lines
105
- - Content has distinct domains (finance vs sales schemas)
106
- - Advanced features are rarely needed
107
-
108
- ## Review Checklist
109
-
110
- After drafting, verify:
107
+ ## Process
111
108
 
112
- - [ ] Description includes triggers ("Use when...")
113
- - [ ] SKILL.md under 100 lines
114
- - [ ] No time-sensitive info
115
- - [ ] Consistent terminology
116
- - [ ] Concrete examples included
117
- - [ ] References one level deep
109
+ 1. **Gather** the task/domain, the concrete use cases (the **branches**), executable scripts vs just
110
+ instructions, reference material to bundle. Ask only the few that matter; don't overwhelm.
111
+ 2. **Draft** write the `description` first (it's the routing lever); body in **imperative form**
112
+ (verb-first, not second person); rank every piece on the ladder; disclose reference behind pointers.
113
+ 3. **Prune + review** — run the no-op test; check single source of truth + relevance; present to the
114
+ user (covers the cases? missing? right altitude?).
115
+
116
+ ## Validate
117
+
118
+ - [ ] Frontmatter `---` opens/closes; `name` present, kebab-case, equals the folder.
119
+ - [ ] `description` is third person, states what + "Use when…" triggers, front-loads the leading word.
120
+ - [ ] **No** `disable-model-invocation` (wrxn skills are model-invoked).
121
+ - [ ] Every step ends on a checkable — and where it matters, exhaustive — completion criterion.
122
+ - [ ] Reference only some branches need is disclosed behind a pointer, not buried inline.
123
+ - [ ] No duplication / sediment / sprawl / no-ops; leading words used consistently throughout.
@@ -0,0 +1,38 @@
1
+ # write-an-agent — Examples
2
+
3
+ ## A compressed read-only locator
4
+
5
+ A canonical interactive subagent: a single job, a least-privilege grant (read-only — no `Bash`, so no
6
+ push path), `haiku` (the work is mechanical), and a tight output contract with a concrete example.
7
+
8
+ ```
9
+ ---
10
+ name: route-finder
11
+ description: >
12
+ Read-only locator for HTTP routes. Returns a path:line table of where each route
13
+ is defined and its handler. Use PROACTIVELY when someone asks "where is the X
14
+ route", "what handles the Y endpoint", or "list all routes".
15
+ tools: Read, Grep, Glob
16
+ model: haiku
17
+ ---
18
+ You locate HTTP routes and report them. Nothing else.
19
+
20
+ ## Process
21
+ 1. Grep for route definitions (router calls, decorators, path strings).
22
+ 2. Resolve each route's handler symbol.
23
+ 3. Emit the table. Stop.
24
+
25
+ ## Constraints
26
+ - Read-only — never edit, run git, or propose changes.
27
+ - No preamble, no prose padding.
28
+
29
+ ## Output
30
+ Your final message IS the result. One row per route, nothing else:
31
+ `METHOD /path — handler@file:line`
32
+ Example:
33
+ `GET /users — listUsers@api/users.ts:42`
34
+ ```
35
+
36
+ **Why it's SOTA:** read-only grant (no push path), `haiku` (mechanical), the `description` leads
37
+ delegation with "use PROACTIVELY" + exact trigger phrases, and the output contract is a fixed
38
+ one-row-per-route shape — the caller gets a compact table, not prose.
@@ -0,0 +1,96 @@
1
+ ---
2
+ name: write-an-agent
3
+ description: Create a state-of-the-art interactive Claude Code subagent (.claude/agents/<name>.md) through a guided interview — pin its single job, routing trigger, least-privilege tools (you approve the grant), model, and a mandatory compressed output contract, then scaffold and validate the subagent file. Use when someone wants to create, add, or scaffold a subagent, build a custom agent, or says "write an agent", "create an agent", or "new subagent".
4
+ ---
5
+
6
+ # Writing an Agent
7
+
8
+ Scaffold an **interactive subagent** — a `.claude/agents/<name>.md` file spawned via the Agent/Task
9
+ tool — through a short interview that gets the few SOTA levers right. Your job here is not to fill a
10
+ template; it is to **interrogate the job until the subagent is sharp, cheap, and safe**, then write a
11
+ validated file.
12
+
13
+ **Scope:** interactive helpers (locators, reviewers, runners you call in-session). **Not** AFK
14
+ pipeline executors — those live in the kernel's dispatch-executor registry (`wrxn dispatch`). If the
15
+ user wants a workflow *they* follow inline, write a skill instead (`write-a-skill`).
16
+
17
+ ## Why a subagent (the levers that make it good)
18
+
19
+ A subagent is a **separate context** with its own tools, model, and system prompt. The caller sees
20
+ **only its final message**. That one fact drives every lever:
21
+
22
+ | Lever | Why |
23
+ |---|---|
24
+ | **Single responsibility** | One narrow job → sharp prompt → correct routing. An "and" means two subagents. |
25
+ | **`description` = #1 routing lever** | The main thread matches this text to delegate. Vague → mis-routed. Use "use PROACTIVELY" + trigger phrases. |
26
+ | **Least-privilege `tools`** | Omitting `tools` inherits ALL tools. Smaller surface = safer + cheaper. |
27
+ | **Compressed output contract** | The caller eats only the final message. A terse fixed shape is the highest-value, most-skipped lever. |
28
+ | **Stateless** | No memory but the spawn prompt + this file. Put everything it needs on the page. |
29
+ | **Model match** | Mechanical → haiku; reasoning → sonnet; hard → opus. |
30
+
31
+ ## File format (verified — code.claude.com/docs sub-agents)
32
+
33
+ ```
34
+ ---
35
+ name: <kebab-case, equals the filename>
36
+ description: >
37
+ <what it does> + WHEN. Include "use PROACTIVELY" + trigger phrases.
38
+ tools: Read, Grep, Glob # explicit allowlist ALWAYS — omitting inherits ALL tools
39
+ model: haiku # haiku | sonnet | opus | inherit
40
+ skills: tdd # OPTIONAL — preloads that skill's content at startup
41
+ ---
42
+ <system prompt — SOTA body order below>
43
+ ```
44
+
45
+ Real fields: `name`, `description`, `tools`, `model`, `skills` (advanced: `disallowedTools`,
46
+ `permissionMode`). Don't invent others.
47
+
48
+ ## Interview — run in this order
49
+
50
+ 1. **Job** — the ONE responsibility. If it needs an "and", STOP and propose two subagents.
51
+ 2. **Trigger** — when should the main thread delegate? → becomes `description`:
52
+ `<what it does>. Use PROACTIVELY when <the exact situations/phrases that route to it>.`
53
+ 3. **Propose frontmatter → ONE consolidated approval.** Infer from the job, then show `tools` +
54
+ `model` + `skills` together as a single preview; the operator approves or edits before you continue:
55
+ - **tools** — the minimal allowlist. Locator/reviewer → `Read, Grep, Glob`; + run things → `+Bash`;
56
+ mutates files → `+Edit, Write`; research → `WebFetch, WebSearch`; integration →
57
+ `mcp__<server>__<tool>` (named, never `*`). **Never omit** (= inherit-all). **Never grant a push
58
+ path** (no devops). Flag `Bash` as broad (reaches `git` + the network).
59
+ - **model** — mechanical → `haiku`, reasoning → `sonnet`, hard → `opus`, match the caller → `inherit`.
60
+ - **skills** — propose only if the job maps to a skill **installed here** (`.claude/skills/<name>/`
61
+ exists; a dangling preload = a broken subagent). Don't auto-add `caveman` — compression ships via
62
+ the body instruction, which is portable.
63
+ 4. **Output contract (mandatory)** — pin exactly what returns + how terse: a fixed return shape (e.g.
64
+ `path:line — finding`, one per line; or small JSON) **and** a compression instruction (lead with the
65
+ answer, drop prose, backtick exact paths/symbols). Don't finish the subagent without it.
66
+ 5. **Generate → validate → write** (below).
67
+
68
+ ## Body structure (SOTA order — every subagent)
69
+
70
+ 1. **Role** — one line: who it is + the single job.
71
+ 2. **Process** — the numbered steps it follows.
72
+ 3. **Constraints** — hard NOs: what it refuses (scope creep; edits if read-only; ever pushing).
73
+ 4. **Output contract** — the fixed return shape + **one concrete example**. State plainly: *your final
74
+ message IS the return value — return the result, not a conversational reply.* Compress.
75
+ 5. **Stateless reminder** — it gets only its spawn prompt + this file; no main-thread memory, no
76
+ inherited CLAUDE.md persona. Keep the page self-sufficient.
77
+
78
+ ## Validate (loose by design)
79
+
80
+ - [ ] `---` fences open/close; `name` present, kebab-case, equals the filename.
81
+ - [ ] `description` says **what** + **when** (the routing trigger; uses "use PROACTIVELY").
82
+ - [ ] `tools` is an explicit allowlist of **real** tools; present, never omitted; no push path.
83
+ - [ ] `model` ∈ `haiku | sonnet | opus | inherit`.
84
+ - [ ] `skills` (if present) names a skill that exists under `.claude/skills/`.
85
+ - [ ] Body has Role + Process + Constraints + Output contract (with an example).
86
+ - Don't hard-gate `tools` against a frozen list — new MCP tools are valid.
87
+
88
+ ## Write + load
89
+
90
+ - Write `.claude/agents/<name>.md` at the install root. **Brownfield-safe**: if it exists, STOP —
91
+ offer to edit or rename, never overwrite.
92
+ - **Loading:** a file written to disk is **not live this session**. Tell the operator to **restart
93
+ Claude Code, or create/refresh it via the `/agents` interface** (which loads immediately). Then it is
94
+ invokable by the Agent/Task tool, a workflow, or FleetView.
95
+
96
+ See **[EXAMPLES.md](EXAMPLES.md)** for a complete worked subagent.