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,325 @@
1
+ ---
2
+ name: codebase-navigation
3
+ description: Guides progressive codebase orientation with the SAFE pattern before implementation, review, or unfamiliar work.
4
+ version: 1.1.0
5
+ required: true
6
+ category: workflow
7
+ tools:
8
+ - claude
9
+ - copilot
10
+ - codex
11
+ - cursor
12
+ triggers:
13
+ - orientation
14
+ - unfamiliar-codebase
15
+ - multi-step-work
16
+ routing:
17
+ load: conditional
18
+ ---
19
+
20
+ # Codebase Navigation Directive
21
+
22
+ **When to load:** Load this directive for unfamiliar codebases or new multi-task sessions unless adaptive routing determines the task is purely conversational, docs-only, or the agent is already oriented.
23
+
24
+ This directive governs how the agent explores and reads the codebase before
25
+ starting repo-based implementation or review work. Adaptive routing may skip it
26
+ for purely conversational, docs-only, or already-oriented tasks.
27
+
28
+ **Do not skip orientation.** Starting work without surveying the codebase produces
29
+ code that doesn't fit existing patterns, duplicates logic, or breaks imports.
30
+
31
+ ---
32
+
33
+ ## S — Survey
34
+
35
+ **Goal:** Understand where things live and how the project is organized.
36
+ **Token budget:** ~2,000 tokens maximum.
37
+
38
+ Read these **in order**. Stop as soon as you have enough orientation for the task.
39
+
40
+ ```
41
+ 1. Project-level instructions (AGENTS.md, CLAUDE.md, or equivalent)
42
+ → project WHY, WHAT, HOW, workflow
43
+ 2. tree -L 2 -I node_modules (or equivalent)
44
+ → directory structure
45
+ - Do NOT recurse deeply — flat or depth-2 only.
46
+ Deep listings exceed the Survey token budget on larger repos.
47
+ 3. The project's entry point — main export file, router, or public API surface
48
+ → what's exported, what's public
49
+ 4. Build/test/lint commands (package.json scripts, Makefile, or equivalent)
50
+ ```
51
+
52
+ **Do NOT read at this stage:**
53
+
54
+ - Full implementation files
55
+ - Test file bodies
56
+ - Long config files
57
+ - Dependency directories (node_modules, vendor, etc.)
58
+
59
+ **What you should know after Survey:**
60
+
61
+ - Where the relevant source files live
62
+ - What the public API surface looks like
63
+ - How to build, test, and lint
64
+
65
+ ---
66
+
67
+ ## A — Anchor
68
+
69
+ **Goal:** Load the constraints that most strongly determine correct output.
70
+ **Token budget:** ~3,000 tokens maximum.
71
+
72
+ Anchor on **types and contracts**, not implementations.
73
+
74
+ ```
75
+ 1. Type definitions for the area you're working in
76
+ - Type imports in the relevant source files (just the imports, first ~20 lines)
77
+ - Co-located type definitions or dedicated types files
78
+
79
+ 2. Test file NAMES for the area (not bodies)
80
+ - grep "describe\|it(" tests/path/to/area-test.ts | head -30
81
+ - Test names are specifications — they tell you what behavior exists
82
+
83
+ 3. Existing capability search
84
+ - Search for existing utilities, helpers, services, validators, hooks,
85
+ commands, or types that already solve this problem
86
+ - Reuse existing behavior when it represents the same project knowledge
87
+ - Do not consolidate merely similar code if it represents different domain
88
+ concepts or would expand the scope budget
89
+
90
+ 4. ONE reference file showing the existing pattern
91
+ - Pick the most similar existing file to what you're working on
92
+ - Read its exports and public interface only (skip full body)
93
+
94
+ 5. Applicable directives and scoped instructions
95
+ - Load any project-level directives or scoped instructions that apply
96
+ ```
97
+
98
+ **Prefer:**
99
+
100
+ ```bash
101
+ # High-information, low-token reads
102
+ head -25 path/to/representative-file.ts # imports + exports
103
+ grep "key-pattern" path/to/representative-file.ts -A 20 # relevant metadata
104
+ grep "describe\|it(" tests/path/to/test-file.ts # test specifications
105
+
106
+ # Existing capability search: prefer AST-aware search when available
107
+ ast-grep --pattern 'export function $NAME($$$ARGS) { $$$BODY }' path/to/source/root
108
+ ast-grep --pattern 'export const $NAME = $$$VALUE' path/to/source/root
109
+
110
+ # Grep fallback when ast-grep is unavailable; choose the project's source roots
111
+ grep -R -E "function .*<domain-term>|const .*<domain-term>|export .*<domain-term>" path/to/source/root path/to/tests | head -30
112
+ ```
113
+
114
+ **If your agent framework provides dedicated read/search tools** (e.g. Read
115
+ with line ranges, Grep, or Glob), prefer those over raw shell commands — they
116
+ are typically optimized for the agent's context management.
117
+
118
+ **Prefer symbol-aware navigation when available.** In large or multi-language
119
+ codebases, use LSP/language-server/IDE symbol tools for go-to-definition,
120
+ find-references, call hierarchy, or diagnostics before broad text search. Plain
121
+ text search is still useful for unknown terms, but verify symbol identity before
122
+ editing when multiple packages, languages, generated files, or same-named
123
+ functions/classes may match. If no LSP/symbol tool is configured, state the
124
+ fallback and use imports, call sites, and narrow file slices to disambiguate.
125
+
126
+ **Avoid:**
127
+
128
+ ```bash
129
+ # Low-information, high-token reads
130
+ cat path/to/source-file.ts # entire file — wastes context
131
+ cat tests/path/to/test-file.ts # entire test file — wastes context
132
+ ```
133
+
134
+ ---
135
+
136
+ ## F — Filter
137
+
138
+ **Goal:** Narrow to exactly the files your task touches.
139
+ **Token budget:** ~2,000-5,000 tokens (task-dependent).
140
+
141
+ Only now read the specific files you'll modify or that your changes depend on.
142
+
143
+ Escalate reads from narrow to broad:
144
+
145
+ 1. File names and symbols
146
+ 2. Imports, exports, signatures, and frontmatter/metadata
147
+ 3. Test names, failing output, and documented examples
148
+ 4. Relevant function, section, or directive slices
149
+ 5. Whole files only when slices cannot answer the question
150
+
151
+ Do not read sibling implementations merely for familiarity. The Anchor phase's
152
+ allowance to read **ONE reference file** is a narrow exception to the Filter
153
+ phase rule: use one representative reference file only when it directly informs
154
+ the target change, not as general look-and-copy context.
155
+
156
+ ```
157
+ 1. Find dependents:
158
+ grep -rl "from.*my-module" src/ | head -10
159
+
160
+ 2. Find what the target file imports:
161
+ head -30 path/to/target-file.ts # just the import block
162
+
163
+ 3. Read the specific functions/types you need to change or extend
164
+ - Use line-offset reads, not cat
165
+ - Skim for structure, skip internal helpers you won't touch
166
+ ```
167
+
168
+ **The dependency check prevents:**
169
+
170
+ - Breaking imports in files you didn't know depended on yours
171
+ - Duplicating logic that already exists elsewhere
172
+ - Missing required changes to consumer code
173
+
174
+ ### Optional tool-assisted architecture check
175
+
176
+ If the task may change imports, exports, packages, services, shared code, or
177
+ folder boundaries, load `directives/architecture-boundaries.md` before Execute.
178
+
179
+ For TypeScript/JavaScript projects with Fallow available, use targeted checks
180
+ when they answer boundary questions faster than manual search:
181
+
182
+ ```bash
183
+ npx fallow list --boundaries
184
+ npx fallow dead-code --boundary-violations
185
+ npx fallow dead-code --circular-deps
186
+ ```
187
+
188
+ If GitNexus is available, use graph context to identify dependents, clusters,
189
+ services, and execution flows before making cross-cutting changes.
190
+
191
+ ---
192
+
193
+ ## E — Execute
194
+
195
+ **Goal:** Begin the standard implementation workflow with high-information context.
196
+
197
+ By this point entropy is reduced enough that first-try correctness should be
198
+ 70-85%. Proceed with your project's implementation workflow.
199
+
200
+ ---
201
+
202
+ ## Context Discipline Rules
203
+
204
+ These rules prevent context rot during long sessions.
205
+
206
+ ### 1. Read by Slice, Not by File
207
+
208
+ ```bash
209
+ # Good — reads what you need
210
+ head -30 path/to/file.ts # imports + signature
211
+ sed -n '45,80p' path/to/file.ts # specific section
212
+
213
+ # Bad — floods context
214
+ cat path/to/file.ts # entire 200-line file
215
+ ```
216
+
217
+ ### 2. Use grep Before cat
218
+
219
+ Before reading any file, grep for what you need. If grep answers your
220
+ question, don't read the file.
221
+
222
+ ```bash
223
+ grep "export.*function\|export.*const\|export type" path/to/file.ts
224
+ grep -n "key-pattern:" path/to/file.ts
225
+ ```
226
+
227
+ If your project uses AST-aware search tools (e.g., ast-grep), prefer those
228
+ over regex for structural queries — they match AST nodes, not strings, so they
229
+ won't false-positive on commented-out code, string literals, or nested scopes.
230
+
231
+ ### 3. Summarize Between Tasks
232
+
233
+ After completing each task (one full cycle through the workflow), summarize
234
+ before starting the next:
235
+
236
+ - What changed (1-2 sentences)
237
+ - Any decisions affecting subsequent work
238
+ - Forget intermediate exploration — keep only current state and constraints
239
+
240
+ ### 4. Compact After 5+ Tasks
241
+
242
+ If you've completed 5+ tasks in one session, pause and compact:
243
+
244
+ 1. Summarize all completed work (max 500 words)
245
+ 2. List current file state and pending work
246
+ 3. Discard exploration context from earlier tasks
247
+ 4. Write any qualifying decision logs or error entries (see below)
248
+
249
+ Without compaction, accuracy degrades roughly as follows (heuristic, not measurement):
250
+
251
+ ```
252
+ Tasks 1-5: ~90% signal
253
+ Tasks 6-10: ~60% signal
254
+ Tasks 11+: ~30% signal
255
+ ```
256
+
257
+ **Framework-dependent action:**
258
+
259
+ - If your framework supports auto-compaction (e.g., Claude Code): trigger it now
260
+ - If not: produce a session digest as a message summarizing completed work,
261
+ pending items, and active constraints, then continue
262
+
263
+ ### 5. Compact → Session Decisions Pipeline
264
+
265
+ Compacting produces two outputs with different audiences:
266
+
267
+ **Session digest** (for the _current_ session's context window):
268
+
269
+ - What changed (1-2 sentences per task)
270
+ - Current file state and pending work
271
+ - Active constraints for remaining work
272
+ - This replaces the full history — it IS the compacted context
273
+
274
+ **Decision log** (for _future_ sessions and contributors):
275
+
276
+ - Written following session-decisions guidance
277
+ - Only when durable decisions were made (architectural, convention, policy)
278
+ - Stored in `docs/decisions/YYYY-MM-DD-<topic>.md`
279
+ - Future agents scan frontmatter to find relevant context without reading everything
280
+
281
+ The connection: when you compact, check whether any completed task included a
282
+ qualifying decision. If so, write the decision log _during compacting_ while the
283
+ reasoning is fresh — don't wait until session end.
284
+
285
+ ```
286
+ Compacting checklist:
287
+ □ Summarize completed work (session digest)
288
+ □ List pending work and active constraints
289
+ □ For each completed task: did it set a durable decision?
290
+ → Yes: write docs/decisions/YYYY-MM-DD-<topic>.md now
291
+ → No: skip
292
+ □ Discard exploration context
293
+ ```
294
+
295
+ This ensures decisions are captured when reasoning is fresh, and the session
296
+ digest keeps the current context window lean for the next task.
297
+
298
+ ---
299
+
300
+ ## Forbidden Patterns
301
+
302
+ | Pattern | Why Forbidden |
303
+ | ------------------------------------------- | ----------------------------------------------------------- |
304
+ | `cat` on any file over 50 lines | Wastes context on low-information content |
305
+ | Reading a file "to get familiar" | Familiarity comes from types and tests, not implementations |
306
+ | Reading sibling implementations without a task-specific question | Burns context and invites pattern cargo-culting |
307
+ | Skipping Survey to start coding immediately | Produces code that doesn't fit the codebase |
308
+ | Reading full test file bodies during Anchor | Test names are the spec; bodies are for the RED phase |
309
+ | Loading all directives for every task | Use progressive disclosure — load only what applies |
310
+ | Starting a second task without compacting | Context from task 1 rots and confuses task 2 |
311
+
312
+ ---
313
+
314
+ ## Quick Reference
315
+
316
+ | Phase | Read | Budget | Know After |
317
+ | ----------- | -------------------------------------------- | ------------ | ----------------------- |
318
+ | **Survey** | Project instructions, tree, exports, scripts | ~2K tokens | Where things live |
319
+ | **Anchor** | Types, test names, one reference, directives | ~3K tokens | What correct looks like |
320
+ | **Filter** | Specific files task touches, dependents | ~2-5K tokens | What to change |
321
+ | **Execute** | Follow project implementation workflow | Per-step | Correct implementation |
322
+
323
+ ---
324
+
325
+ _This directive is mandatory before any implementation, bug fix, or refactor. It ensures the agent starts work with maximum information density and minimum context waste._
@@ -0,0 +1,220 @@
1
+ ---
2
+ name: context-handoff
3
+ description: Compresses task state at directive or session boundaries so later phases can continue from a compact, current-state handoff instead of drifting through accumulated chat history.
4
+ version: 1.0.0
5
+ required: false
6
+ category: workflow
7
+ tools:
8
+ - claude
9
+ - codex
10
+ triggers:
11
+ - directive-boundary
12
+ - session-handoff
13
+ - context-compaction
14
+ - long-running-task
15
+ - multi-phase-workflow
16
+ routing:
17
+ load: conditional
18
+ applies_to:
19
+ - implementation
20
+ - debugging
21
+ - review
22
+ - exploration
23
+ - policy-change
24
+ ---
25
+
26
+ # Context Handoff Directive
27
+
28
+ ## Purpose
29
+
30
+ Use this directive to compact the current task state before switching major
31
+ workflow phases, handing work to another agent/session, pausing a long task, or
32
+ starting a new directive that should not inherit stale context.
33
+
34
+ A handoff capsule is a current-state summary, not a transcript. It preserves the
35
+ facts, decisions, evidence, and open risks that still matter while explicitly
36
+ retiring obsolete plans and rejected paths.
37
+
38
+ ## Important Limitation
39
+
40
+ Markdown instructions cannot erase a model's active context. This directive is a
41
+ discipline mechanism for reducing context drift.
42
+
43
+ When a true fresh session is available, start the next session with only:
44
+
45
+ 1. the user's current request,
46
+ 2. the latest handoff capsule,
47
+ 3. project instructions required by the router, and
48
+ 4. repository evidence discovered by the new session.
49
+
50
+ When a true fresh session is not available, treat the latest handoff capsule as
51
+ the authoritative summary and ignore unstated prior assumptions.
52
+
53
+ ---
54
+
55
+ ## When to Use
56
+
57
+ Create or update a handoff capsule when any of these apply:
58
+
59
+ - The router switches between major phases or directives on Full, Debugging,
60
+ Boundary, Review, Exploration, or Policy paths.
61
+ - The task spans enough steps that accumulated chat context may become noisy.
62
+ - Work is paused and may resume later.
63
+ - Another agent/session will continue the work.
64
+ - A review, PR, or human handoff needs a compact summary of current state.
65
+ - The agent changed direction and needs to retire stale assumptions or rejected
66
+ approaches.
67
+
68
+ For Light Path work, a handoff is optional unless the user asks for one or the
69
+ work will continue in another session.
70
+
71
+ ---
72
+
73
+ ## Storage
74
+
75
+ Use the first available storage location:
76
+
77
+ 1. `.agents/handoff.md` — preferred when local file access is available.
78
+ 2. The final assistant response — when file access is unavailable.
79
+ 3. A PR comment — when handing off review context to humans or review agents.
80
+
81
+ Do not commit `.agents/handoff.md` or `.agents/handoff-log.md` unless the user
82
+ explicitly requests committed agent-state artifacts. These files are session
83
+ state, not project source.
84
+
85
+ If project conventions already define another agent state directory, use that
86
+ instead and state the chosen path in the handoff.
87
+
88
+ ---
89
+
90
+ ## Update Semantics
91
+
92
+ `.agents/handoff.md` is the active, authoritative handoff document. Rewrite it at
93
+ handoff boundaries so it always represents the latest compact current state.
94
+
95
+ Do not append indefinitely to the active handoff. Endless append-only handoffs
96
+ recreate context drift by preserving stale assumptions, obsolete plans, and
97
+ superseded evidence.
98
+
99
+ If an audit trail is needed, append historical entries to
100
+ `.agents/handoff-log.md`, but treat that log as historical only. The active
101
+ handoff supersedes the log, prior plans, stale tool output, and abandoned
102
+ approaches.
103
+
104
+ ---
105
+
106
+ ## Handoff Capsule Template
107
+
108
+ ```md
109
+ # Agent Handoff
110
+
111
+ Last updated: <date/time if available>
112
+ Storage: <path, response, or PR comment>
113
+ Current workflow route: <Light | Full | Debugging | Boundary | Review | Exploration | Policy | combined>
114
+ Current directive/phase: <directive or phase completing now>
115
+ Next recommended directive/phase: <directive or phase to load next>
116
+
117
+ ## User Intent
118
+
119
+ <The user's current request in 1-3 sentences.>
120
+
121
+ ## Current Task State
122
+
123
+ <What is true now. Include branch/PR, changed files, relevant commands, and the
124
+ current implementation/review status.>
125
+
126
+ ## Decisions That Still Matter
127
+
128
+ - <Decision and why it remains relevant.>
129
+
130
+ ## Evidence Collected
131
+
132
+ - <Command/tool/check>: <result and why it matters>
133
+
134
+ ## Files and Surfaces Involved
135
+
136
+ - `<path>` — <changed/read/relevant and why>
137
+
138
+ ## Open Risks / Unknowns
139
+
140
+ - <Risk, missing evidence, or uncertainty that the next phase must handle>
141
+
142
+ ## Rejected or Superseded Context
143
+
144
+ - <Old approach, stale failure output, or assumption the next phase should ignore>
145
+
146
+ ## Next Directive Input
147
+
148
+ The next directive should:
149
+ 1. <specific next action>
150
+ 2. <specific verification or question>
151
+
152
+ The next directive should not rely on:
153
+ - <unstated prior chat, obsolete plan, or old tool output>
154
+ ```
155
+
156
+ Use concise bullets. Keep the capsule short enough to paste into a new session.
157
+ Prefer current facts over narrative history.
158
+
159
+ ---
160
+
161
+ ## Phase Boundary Rules
162
+
163
+ Before switching from one major directive/phase to another:
164
+
165
+ 1. Identify whether a handoff is required by the route.
166
+ 2. Rewrite the active handoff with only current relevant state.
167
+ 3. Mark stale plans, old failures, and rejected approaches as superseded.
168
+ 4. Name the next directive/phase and the exact inputs it needs.
169
+ 5. If file storage is unavailable, print the capsule in the response.
170
+
171
+ The next directive must start from:
172
+
173
+ 1. the latest handoff capsule,
174
+ 2. the user's current request, and
175
+ 3. repository evidence it independently inspects when needed.
176
+
177
+ The next directive must not rely on hidden chat context that is absent from the
178
+ handoff.
179
+
180
+ ---
181
+
182
+ ## PR and Review Handoffs
183
+
184
+ For PR workflows, the final handoff may be placed in the PR body or a PR comment
185
+ when it helps reviewers. Keep it focused on:
186
+
187
+ - workflow route used,
188
+ - files/surfaces changed,
189
+ - verification evidence,
190
+ - known risks or skipped checks,
191
+ - review focus for humans or bots.
192
+
193
+ Do not post per-directive handoffs as repeated PR comments. Use a single compact
194
+ review handoff unless the user requests a detailed audit trail.
195
+
196
+ ---
197
+
198
+ ## Forbidden Patterns
199
+
200
+ | Pattern | Why Forbidden |
201
+ | --- | --- |
202
+ | Appending forever to the active handoff | Recreates context drift and makes stale state look relevant |
203
+ | Treating the handoff as proof without evidence | The capsule summarizes evidence; it does not replace running checks |
204
+ | Carrying forward assumptions not written in the capsule | Defeats the purpose of compaction |
205
+ | Committing session-state handoff files by default | Pollutes project history with local agent state |
206
+ | Using handoff ceremony for tiny one-step Light Path work | Adds boilerplate without reducing risk |
207
+ | Hiding unresolved risks to make the handoff look clean | The next phase needs accurate open questions |
208
+
209
+ ---
210
+
211
+ ## Quick Reference
212
+
213
+ | Situation | Handoff required? | Storage |
214
+ | --- | --- | --- |
215
+ | Tiny docs/typo Light Path | Usually no | Response summary if useful |
216
+ | Full Path behavior change | Yes at major phase boundaries | `.agents/handoff.md` when available |
217
+ | Debugging/failing CI | Yes after reproduction, before fix, and after verification | `.agents/handoff.md` |
218
+ | Boundary-sensitive refactor | Yes before boundary review and final verification | `.agents/handoff.md` |
219
+ | PR handoff to humans/review bots | Yes when useful | PR body/comment |
220
+ | True new session | Yes | Paste latest capsule into new session |