agent-directives 0.1.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.
Files changed (57) hide show
  1. package/README.md +385 -0
  2. package/directives/adaptive-routing.md +361 -0
  3. package/directives/architecture-boundaries.md +223 -0
  4. package/directives/codebase-navigation.md +325 -0
  5. package/directives/context-handoff.md +220 -0
  6. package/directives/error-memory.md +169 -0
  7. package/directives/exploration-mode.md +266 -0
  8. package/directives/session-decisions.md +193 -0
  9. package/directives/specification-driven-development.md +278 -0
  10. package/directives/task-framing.md +154 -0
  11. package/directives/test-driven-development.md +305 -0
  12. package/directives/type-driven-development.md +173 -0
  13. package/directives/verification.md +266 -0
  14. package/directives/workspace-isolation.md +219 -0
  15. package/dist/cli.d.ts +3 -0
  16. package/dist/cli.d.ts.map +1 -0
  17. package/dist/cli.js +232 -0
  18. package/dist/cli.js.map +1 -0
  19. package/dist/context-audit.d.ts +30 -0
  20. package/dist/context-audit.d.ts.map +1 -0
  21. package/dist/context-audit.js +75 -0
  22. package/dist/context-audit.js.map +1 -0
  23. package/dist/install.d.ts +18 -0
  24. package/dist/install.d.ts.map +1 -0
  25. package/dist/install.js +28 -0
  26. package/dist/install.js.map +1 -0
  27. package/dist/manifest.d.ts +25 -0
  28. package/dist/manifest.d.ts.map +1 -0
  29. package/dist/manifest.js +29 -0
  30. package/dist/manifest.js.map +1 -0
  31. package/dist/prompt.d.ts +3 -0
  32. package/dist/prompt.d.ts.map +1 -0
  33. package/dist/prompt.js +29 -0
  34. package/dist/prompt.js.map +1 -0
  35. package/dist/targets.d.ts +10 -0
  36. package/dist/targets.d.ts.map +1 -0
  37. package/dist/targets.js +32 -0
  38. package/dist/targets.js.map +1 -0
  39. package/manifest.json +387 -0
  40. package/package.json +74 -0
  41. package/skills/architecture-boundary-reviewer/SKILL.md +228 -0
  42. package/skills/code-reviewer/SKILL.md +77 -0
  43. package/skills/codebase-health-reviewer/SKILL.md +234 -0
  44. package/skills/harness-hooks-reviewer/SKILL.md +159 -0
  45. package/skills/implementation-task-planner/SKILL.md +205 -0
  46. package/skills/mcp-integration-reviewer/SKILL.md +157 -0
  47. package/skills/product-requirements-writer/SKILL.md +205 -0
  48. package/skills/production-readiness-reviewer/SKILL.md +240 -0
  49. package/skills/self-audit/SKILL.md +134 -0
  50. package/skills/spec-reviewer/SKILL.md +304 -0
  51. package/skills/subagent-driven-development/SKILL.md +236 -0
  52. package/skills/systematic-debugging/SKILL.md +313 -0
  53. package/skills/test-reviewer/SKILL.md +293 -0
  54. package/templates/AGENTS.md +120 -0
  55. package/templates/CLAUDE.md +115 -0
  56. package/templates/copilot-instructions.md +116 -0
  57. package/templates/decision-log.md +44 -0
@@ -0,0 +1,278 @@
1
+ ---
2
+ name: specification-driven-development
3
+ description: Requires written specifications for features or changes large enough that build-and-see would risk rework.
4
+ version: 1.0.0
5
+ required: false
6
+ category: workflow
7
+ tools:
8
+ - claude
9
+ - copilot
10
+ - codex
11
+ - cursor
12
+ triggers:
13
+ - new-feature
14
+ - api-addition
15
+ - cross-cutting-change
16
+ - specification
17
+ routing:
18
+ load: conditional
19
+ ---
20
+
21
+ # Specification-Driven Development Directive
22
+
23
+ **When to load:** Load this directive when building features or changes that are large enough to benefit from written specifications before implementation. Applies to new features, cross-cutting changes, API additions, and any work where "build it and see" risks significant rework.
24
+
25
+ This directive governs how the agent defines what it's going to build before
26
+ building it, then verifies the result against that definition. It operates at a
27
+ higher level than TDD (which governs test mechanics) and type-driven development
28
+ (which governs type definitions). All three are complementary: spec-driven
29
+ defines **what** and **why**, type-driven defines **shapes**, TDD defines
30
+ **correctness**.
31
+
32
+ **Do not implement before the specification is written.** Specifications are the
33
+ contract. Code is the delivery.
34
+
35
+ ---
36
+
37
+ ## Core Principle: Write It Down First
38
+
39
+ A specification is a written description of what the system will do, written
40
+ **before** the system does it. It is not documentation after the fact. It is a
41
+ design tool that forces clarity about requirements, scope, and success criteria
42
+ before any code is written.
43
+
44
+ The specification serves three audiences:
45
+
46
+ 1. **The implementer** (you, possibly in a different session) — knows exactly what to build
47
+ 2. **The reviewer** — can verify the implementation against an explicit contract
48
+ 3. **Future readers** — understand why the system works this way
49
+
50
+ ---
51
+
52
+ ## The Specification Loop
53
+
54
+ ```text
55
+ ┌─────────────────────────────────────────┐
56
+ │ SPECIFICATION LOOP │
57
+ ├─────────────────────────────────────────┤
58
+ │ │
59
+ │ 1. PROPOSE ──▶ Define what and why │
60
+ │ │ │
61
+ │ ▼ │
62
+ │ 2. DESIGN ──▶ Define how │
63
+ │ │ │
64
+ │ ▼ │
65
+ │ 3. SPECIFY ──▶ Define requirements │
66
+ │ │ │
67
+ │ ▼ │
68
+ │ 4. IMPLEMENT ──▶ Build against spec │
69
+ │ │ │
70
+ │ ▼ │
71
+ │ 5. VERIFY ──▶ Check against spec │
72
+ │ │ │
73
+ │ ▼ │
74
+ │ Done │
75
+ │ │
76
+ └─────────────────────────────────────────┘
77
+ ```
78
+
79
+ ### Phase 1: Propose
80
+
81
+ Write a short proposal that answers:
82
+
83
+ - **What** is changing and why
84
+ - **Scope** — what's in and what's explicitly out
85
+ - **Success criteria** — how do we know it's done
86
+ - **Risks** — what could go wrong or make this harder than expected
87
+
88
+ The proposal should be one page or less. If it needs to be longer, the scope
89
+ is too big — break it into smaller changes.
90
+
91
+ **Gate:** Read the proposal back. Does a competent developer understand what
92
+ to build without asking clarifying questions? If not, fill the gaps before
93
+ proceeding. **Wobble check:** If you or the user hold strong conviction on any
94
+ design choice in the proposal, introduce one credible dissenting perspective
95
+ before locking it. If the conviction survives the challenge, it's stronger.
96
+ If it doesn't, the proposal just avoided a blind spot.
97
+
98
+ ### Phase 2: Design
99
+
100
+ Write a design document that answers:
101
+
102
+ - **Architecture** — how the change fits into the existing system
103
+ - **Key decisions** — what approach was chosen and why alternatives were rejected
104
+ - **Component changes** — what files, modules, or services are affected
105
+ - **Data flow** — how data moves through the system for this change
106
+
107
+ The design should be concrete enough that an implementer can work from it
108
+ without making architectural decisions.
109
+
110
+ **Gate:** Trace through the design mentally. Can you walk from trigger to
111
+ outcome without hitting a gap? If not, fill the gap. **Counterfactual check:**
112
+ For at least one key decision, ask: _"Would this hold if the system used a
113
+ different architecture, language, or data model?"_ Decisions that only make
114
+ sense under current assumptions should be noted as such — they're valid, but
115
+ they're load-bearing.
116
+
117
+ ### Phase 3: Specify
118
+
119
+ Write detailed requirements. Each requirement should be:
120
+
121
+ - **Atomic** — one requirement, one behavior
122
+ - **Testable** — there is a clear pass/fail condition
123
+ - **Unambiguous** — one reasonable interpretation
124
+
125
+ Use a consistent format for requirements and scenarios:
126
+
127
+ ```markdown
128
+ ### Requirement: [Name]
129
+
130
+ The system SHALL [behavior].
131
+
132
+ #### Scenario: [Name]
133
+
134
+ - **GIVEN** [precondition]
135
+ - **WHEN** [trigger]
136
+ - **THEN** [expected outcome]
137
+ ```
138
+
139
+ **Gate:** For each requirement, ask: "Could I write a test for this?" If not,
140
+ the requirement is too vague.
141
+
142
+ ### Phase 4: Implement
143
+
144
+ Build the code against the specification:
145
+
146
+ - Requirements become implementation tasks
147
+ - Scenarios become test cases (feed into TDD)
148
+ - Design decisions guide architecture choices
149
+
150
+ During implementation, the specification is the source of truth. If the code
151
+ suggests the specification is wrong, **stop and update the specification first**,
152
+ then adjust the code. Do not silently diverge.
153
+
154
+ **Implementation discipline:**
155
+
156
+ 1. Pick a requirement
157
+ 2. Write a test for its scenario (TDD)
158
+ 3. Implement to make the test pass
159
+ 4. Move to the next requirement
160
+ 5. Track progress against the full requirement list
161
+
162
+ ### Phase 5: Verify
163
+
164
+ After implementation, verify the result against the specification (see
165
+ verification directive for the general protocol). For spec-driven development,
166
+ verification checks three dimensions:
167
+
168
+ | Dimension | Question | Method |
169
+ | ------------ | ------------------------------------ | ---------------------------------- |
170
+ | Completeness | Are all requirements implemented? | Check each requirement has code |
171
+ | Correctness | Does the code do what the spec says? | Trace scenarios to implementations |
172
+ | Coherence | Does the code follow the design? | Check architecture matches design |
173
+
174
+ ---
175
+
176
+ ## Progressive Depth
177
+
178
+ Not every change needs all five phases. Scale the specification to the
179
+ complexity of the change:
180
+
181
+ | Change Size | Proposal | Design | Detailed Spec | Phases |
182
+ | ----------------- | -------- | ------ | ------------- | ------ |
183
+ | Small (single fn) | Yes | Skip | Brief | 1, 3-5 |
184
+ | Medium (feature) | Yes | Yes | Yes | 1-5 |
185
+ | Large (cross-cut) | Yes | Yes | Yes | 1-5 |
186
+ | Fix (bug) | Brief | Skip | Skip | 1, 4-5 |
187
+
188
+ **Rule of thumb:** If you can hold the full change in your head, a brief
189
+ proposal is sufficient. If you can't, write the design and spec.
190
+
191
+ ---
192
+
193
+ ## Specification Location
194
+
195
+ Store specifications where the project expects them. Common patterns:
196
+
197
+ ```text
198
+ project/
199
+ ├── docs/
200
+ │ └── specs/ # Specification documents
201
+ │ └── feature-a/
202
+ │ ├── proposal.md
203
+ │ ├── design.md
204
+ │ └── spec.md
205
+ ├── .agents/
206
+ │ └── specs/ # Agent-specific spec location
207
+ └── openspec/ # OpenSpec-compatible projects
208
+ └── specs/
209
+ ```
210
+
211
+ The key constraint: specifications live in the repository, not in the agent's
212
+ context window. They must be readable by future sessions.
213
+
214
+ ---
215
+
216
+ ## When Specifications Diverge from Reality
217
+
218
+ During implementation, you may discover that the specification is wrong. This
219
+ is valuable — it means the specification caught a bad assumption early.
220
+
221
+ **Process:**
222
+
223
+ 1. **Stop implementing** on the affected requirement
224
+ 2. **Document the divergence** — what the spec says, what reality requires
225
+ 3. **Update the specification** — change the spec to match reality
226
+ 4. **Note the change** — record why the spec changed (for the decision log)
227
+ 5. **Resume implementation** — work from the updated spec
228
+
229
+ **Do not:**
230
+
231
+ - Silently implement something different from the spec
232
+ - Keep implementing on top of a spec you know is wrong
233
+ - Throw away the spec because "code is the real documentation"
234
+
235
+ ---
236
+
237
+ ## Relationship to Other Directives
238
+
239
+ | Directive | Relationship |
240
+ | ----------------------- | -------------------------------------------------------- |
241
+ | Test-Driven Development | Spec scenarios feed into TDD test cases |
242
+ | Type-Driven Development | Spec requirements define what types should express |
243
+ | Task Framing | Proposal phase overlaps with task framing — either works |
244
+ | Codebase Navigation | Use SAFE pattern during design to understand the system |
245
+ | Verification | Phase 5 uses the verification protocol for spec checking |
246
+ | Exploration Mode | Use exploration during proposal/design to investigate |
247
+
248
+ These directives compose. Spec-driven development provides the overall shape;
249
+ the others fill in specific mechanics.
250
+
251
+ ---
252
+
253
+ ## Forbidden Patterns
254
+
255
+ | Pattern | Why Forbidden |
256
+ | ---------------------------------------------- | ---------------------------------------------------------- |
257
+ | Implementing before writing any specification | Skips the clarity that spec-first thinking provides |
258
+ | Writing specs after implementation | Documentation, not specification — misses the design value |
259
+ | Vague requirements without testable criteria | Untestable requirements are unimplementable requirements |
260
+ | Silently diverging from the spec during coding | Defeats the purpose of having a spec |
261
+ | Skipping verification against the spec | Unverified specs are aspirations, not contracts |
262
+ | Writing a spec and never reading it again | The spec is a living document, not a ceremony |
263
+
264
+ ---
265
+
266
+ ## Quick Reference
267
+
268
+ | Phase | Output | Gate |
269
+ | --------- | ----------------------- | ----------------------------------- |
270
+ | Propose | What, why, scope, risks | Could someone else build from this? |
271
+ | Design | Architecture, decisions | Can you trace trigger to outcome? |
272
+ | Specify | Requirements, scenarios | Could you write a test for each? |
273
+ | Implement | Code and tests | Does each test map to a scenario? |
274
+ | Verify | Verification report | All requirements covered? All pass? |
275
+
276
+ ---
277
+
278
+ _This directive is mandatory for features and cross-cutting changes. It is optional for trivial fixes, docs changes, and configuration updates where the change is obvious._
@@ -0,0 +1,154 @@
1
+ ---
2
+ name: task-framing
3
+ description: Frames non-trivial, ambiguous, high-risk, or cross-cutting tasks before substantial edits.
4
+ version: 1.0.0
5
+ required: true
6
+ category: workflow
7
+ tools:
8
+ - claude
9
+ - copilot
10
+ - codex
11
+ - cursor
12
+ triggers:
13
+ - non-trivial-task
14
+ - ambiguous-task
15
+ - high-risk-task
16
+ - cross-cutting-change
17
+ routing:
18
+ load: conditional
19
+ ---
20
+
21
+ # Task Framing Directive
22
+
23
+ ## Prerequisite: Before Major Edits on Non-Trivial Work
24
+
25
+ This directive governs how the agent frames a task before substantial edits.
26
+ It applies when the task is non-trivial, ambiguous, high-risk, or cross-cutting.
27
+ 'Non-trivial' typically means anything beyond a single-file typo fix or a
28
+ docs-only wording change.
29
+
30
+ Load this directive when selected by `directives/adaptive-routing.md` before a
31
+ non-trivial, ambiguous, high-risk, or cross-cutting task — including new
32
+ features, cross-cutting refactors, and anything affecting repo-wide conventions.
33
+
34
+ Do not optimize for agreement. Optimize for accuracy, uncertainty clarity, and
35
+ identifying weak assumptions.
36
+
37
+ **Anti-Righting-Reflex:** When the user presents a specific approach, do not
38
+ correct or counter it before understanding it. Ask *"What led you to this
39
+ approach?"* first. Their reasoning may contain constraints you don't have.
40
+ Only after understanding the why, surface concerns — framed as questions,
41
+ not corrections.
42
+
43
+ ---
44
+
45
+ ## The Minimum Framing Checklist
46
+
47
+ Before major edits, establish:
48
+
49
+ 1. **Problem** — what exactly is changing?
50
+ 2. **Success criteria** — what observable result makes the task done?
51
+ 3. **Constraints** — stack, runtime, repo conventions, compatibility limits,
52
+ boundaries, and files or behavior that must not change
53
+ 4. **Definitions** — resolve ambiguous words like "simple," "optimized,"
54
+ "clean," or "production-ready" into concrete criteria when they affect the
55
+ implementation
56
+ 5. **Assumptions** — name any environment or codebase assumptions that
57
+ materially affect the approach
58
+ 6. **Failure modes** — identify the main edge cases, regressions, or break
59
+ points before substantial edits
60
+ 7. **Alternatives** — when multiple plausible approaches exist, state the one
61
+ chosen and why the others were rejected. **If the choice looks binary
62
+ (A or B), find at least one third option before deciding.** Binary framing
63
+ usually means the decision space hasn't been fully explored. The third
64
+ option doesn't need to win — it needs to be real enough to consider.
65
+ 8. **Evidence plan** — which repo artifacts or official docs will validate the
66
+ approach? Prefer repo evidence first: directives, active decision logs,
67
+ types, tests, and existing patterns; use official external docs when runtime
68
+ or library behavior depends on them
69
+ 9. **Scope budget** — expected files or areas changed, expected kind of change,
70
+ explicit non-goals (what will not be changed), and nearby work that is
71
+ intentionally out of scope. The budget should be narrow enough that unrelated
72
+ cleanup, broad rewrites, and speculative abstractions are visibly out of
73
+ bounds.
74
+
75
+ If any of these materially affect the implementation and remain unknown, ask a
76
+ concise clarifying question before major edits.
77
+
78
+ ## When a Proposal Should Precede Implementation
79
+
80
+ Provide a short proposed approach before major edits when:
81
+
82
+ - The task changes repo policy or contributor workflow
83
+ - The task is cross-cutting
84
+ - The request contains ambiguous success criteria
85
+ - Multiple plausible implementations exist with different tradeoffs
86
+ - External behavior must be verified before coding
87
+
88
+ The proposal should name:
89
+
90
+ - chosen approach
91
+ - main assumptions
92
+ - key alternatives rejected
93
+ - primary regression or edge-case risks
94
+ - scope budget: expected files/areas, expected edit type, and what will not be
95
+ changed unless evidence shows it is required
96
+
97
+ Use a compact scope-budget line before substantial edits:
98
+
99
+ ```md
100
+ Scope budget: I expect to touch <files/areas> with <kind of edit>; I will not change <nearby-but-out-of-scope areas> unless evidence shows they are required or the user explicitly requests it.
101
+ ```
102
+
103
+ ## Depth, Risk, and Slice Gate
104
+
105
+ Before substantial edits, classify the task:
106
+
107
+ - **Trivial** — localized non-behavioral change → Light Path
108
+ - **Simple** — one clear behavior or file with an existing pattern → normal Full Path
109
+ - **Moderate** — multiple files, tests, or some ambiguity → Full Path + framing
110
+ - **Complex** — cross-cutting, unclear architecture, migration, public API, or
111
+ high uncertainty → route before full implementation
112
+
113
+ If risk is high or depth is complex, choose one route before full implementation:
114
+
115
+ | Unknown / risk | Route first | Output constraint |
116
+ | --- | --- | --- |
117
+ | Need to understand existing code, runtime, or dependency behavior | Exploration Path (read-only) | No code edits until the unknown is resolved |
118
+ | Behavior, API, or acceptance criteria unclear | Specification-Driven Development | Load `directives/specification-driven-development.md` and define the contract before coding |
119
+ | Feasibility unknown and throwaway validation is acceptable | Exploration Path (spike) | Temporary code edits allowed for validation only; do not ship spike code without a normal implementation pass |
120
+ | Multi-layer integration or user feedback may change the shape | Full Path | Implement a tracer bullet: the smallest end-to-end slice that proves the path |
121
+
122
+ For non-trivial features, decide whether the next implementation should be a
123
+ tracer bullet or a full feature pass:
124
+
125
+ - **Tracer bullet** — build the smallest end-to-end slice that proves integration,
126
+ architecture, and user-visible behavior.
127
+ - **Full feature pass** — use only when requirements are narrow, low-risk, and
128
+ already well understood.
129
+ - **Spike first** — use when feasibility or external behavior is unknown.
130
+
131
+ Prefer a tracer bullet when the feature crosses multiple layers, user feedback
132
+ may change the shape, or a full implementation would require speculative code.
133
+
134
+ When reasoning or research is part of the task, separate:
135
+
136
+ - repo evidence
137
+ - external facts
138
+ - your own inference
139
+
140
+ If a conclusion is uncertain, say so directly instead of smoothing it into a
141
+ confident answer.
142
+
143
+ ## Evidence Order
144
+
145
+ Prefer evidence in this order:
146
+
147
+ 1. Project-level instructions (e.g., AGENTS.md, CLAUDE.md, or equivalent)
148
+ 2. Applicable directive files
149
+ 3. Scoped instructions for the area you're working in
150
+ 4. Active decision logs in `docs/decisions/`
151
+ 5. Types, tests, and existing code patterns in the touched area
152
+ 6. Official external docs when behavior depends on a library, runtime, or spec
153
+
154
+ This order prevents generic advice from overriding repo-specific conventions.