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,266 @@
1
+ ---
2
+ name: verification
3
+ description: Requires structured evidence of correctness before quality gates and pull requests.
4
+ version: 1.0.0
5
+ required: true
6
+ category: workflow
7
+ tools:
8
+ - claude
9
+ - copilot
10
+ - codex
11
+ - cursor
12
+ triggers:
13
+ - verification
14
+ - pre-pr
15
+ - quality-gates
16
+ - implementation-complete
17
+ routing:
18
+ load: conditional
19
+ ---
20
+
21
+ # Verification Protocol
22
+
23
+ **When to load:** Load this directive after completing the REFACTOR phase and before running final quality gates (GATES).
24
+
25
+ **Do not run GATES until verification output is produced.** Verification
26
+ catches issues that passing tests alone cannot: false positives, missing
27
+ edge cases, wrong configuration, and incomplete documentation.
28
+
29
+ ---
30
+
31
+ ## The Protocol
32
+
33
+ After REFACTOR and before GATES, the agent MUST produce a verification
34
+ summary. The summary is structured evidence that a reviewer can scan in
35
+ 30 seconds instead of reading the full implementation.
36
+
37
+ ### For New Features or Changes
38
+
39
+ Output all applicable sections. The protocol defines three sections that apply
40
+ to every new feature or change, plus conditional sections for architecture
41
+ boundaries, codebase health, and documentation when relevant.
42
+
43
+ #### 1. Functional Proof
44
+
45
+ Demonstrate the change does what it claims. Show:
46
+
47
+ - **Hit** — one input or scenario that produces the expected new behavior
48
+ - **Clean pass** — one input or scenario that should NOT be affected, proving
49
+ no false positive
50
+
51
+ _Example (adapt to your project):_
52
+
53
+ ```
54
+ ✅ Hit: calling createUser({ name: "Alice" }) returns { id: "usr_1", name: "Alice" }
55
+ ✅ Clean: calling createUser({}) returns validation error, no user created
56
+ ```
57
+
58
+ #### 2. Test Coverage Proof
59
+
60
+ List passing test cases grouped by:
61
+
62
+ - **Happy path** — expected inputs with expected outputs
63
+ - **Error cases** — invalid inputs, failure conditions
64
+ - **Edge cases** — null, undefined, empty, boundary values
65
+ - **Suggestion/fix cases** — autofix or suggestion output (if applicable)
66
+
67
+ _Example command (adapt to your project's test runner):_
68
+
69
+ ```bash
70
+ # For example, with vitest:
71
+ npx vitest run --reporter=verbose
72
+ ```
73
+
74
+ #### 3. Integration Proof
75
+
76
+ Confirm the change is wired into the project correctly. Output `[x]` for
77
+ confirmed, `[ ]` for missing:
78
+
79
+ - [ ] Exported/registered in the appropriate entry point
80
+ - [ ] Included in the relevant configuration or module
81
+ - [ ] Public API (types, function signatures) matches usage
82
+ - [ ] Error messages are clear and actionable
83
+
84
+ _Example (adapt to your project's structure):_
85
+
86
+ ```
87
+ [x] Exported from the appropriate entry point
88
+ [x] Registered in config module
89
+ [x] Public types match call sites
90
+ [x] Error messages follow project conventions
91
+ ```
92
+
93
+ #### 4. Architecture Boundary Proof (if applicable)
94
+
95
+ Required when the change touches imports, exports, package boundaries, shared
96
+ code, service boundaries, or folder/layer structure. Show:
97
+
98
+ - Modified zones/layers/packages
99
+ - Changed dependency edges
100
+ - Evidence that no upward, sideways, cyclic, or public-API-bypassing import was introduced
101
+ - Tool evidence when available, e.g. `npx fallow dead-code --boundary-violations`
102
+
103
+ _Example:_
104
+
105
+ ```md
106
+ [x] `feature/auth` imports only `shared` and public `domain` APIs
107
+ [x] No sibling feature internal imports
108
+ [x] `npx fallow dead-code --boundary-violations` reports 0 violations
109
+ ```
110
+
111
+ #### 5. Codebase Health Proof (if applicable)
112
+
113
+ For TypeScript/JavaScript refactors, cleanup, shared utilities, or AI-generated
114
+ changes where Fallow is available, include concise health evidence:
115
+
116
+ ```bash
117
+ npx fallow --summary
118
+ npx fallow dupes
119
+ npx fallow health
120
+ ```
121
+
122
+ Summarize only relevant findings: new dead code, duplication, complexity, cycles,
123
+ or boundary regressions. Separate pre-existing debt from issues introduced by
124
+ the change.
125
+
126
+ #### 6. Documentation Proof (if applicable)
127
+
128
+ - [ ] API documentation updated
129
+ - [ ] README or usage docs updated (if public-facing change)
130
+
131
+ _Example:_
132
+
133
+ ```
134
+ [x] JSDoc updated on changed functions
135
+ [x] README usage section updated
136
+ ```
137
+
138
+ #### 7. Scope Control Proof
139
+
140
+ Confirm the final diff stayed within the planned scope budget:
141
+
142
+ - Planned scope budget: paste or quote the exact scope budget line used for
143
+ comparison.
144
+ - Changed files match the stated scope, or scope expansion is explained with
145
+ evidence.
146
+ - No unrelated cleanup, opportunistic refactor, or drive-by formatting was
147
+ included.
148
+ - No new abstraction, helper layer, dependency, or configuration surface was
149
+ added unless required by current evidence.
150
+
151
+ For small tasks, one sentence is enough:
152
+
153
+ ```md
154
+ Planned scope budget: touch only `src/foo.ts` with a targeted guard-clause edit.
155
+ Scope control: changed only `src/foo.ts`; no unrelated cleanup or new abstraction added.
156
+ ```
157
+
158
+ ---
159
+
160
+ ### For Bug Fixes
161
+
162
+ After the fix, show:
163
+
164
+ 1. **The previously-failing test now passing** — paste the test name and result
165
+ 2. **The fix** — a one-paragraph summary of what changed in the logic
166
+ 3. **No regression** — all existing tests still pass
167
+
168
+ Run the project's test suite with verbose output to confirm.
169
+
170
+ ---
171
+
172
+ ### For Docs / Chore Changes
173
+
174
+ Show the relevant quality gate still passes:
175
+
176
+ Run the project's full quality-gate command suite (test, lint, build/type-check).
177
+
178
+ Paste the output. That IS the verification for non-code changes.
179
+
180
+ ---
181
+
182
+ ## Output Location: Pull Request Body
183
+
184
+ The verification summary MUST be included in the PR description when the
185
+ agent opens a pull request. This keeps the evidence next to the code it
186
+ verifies, and the reviewer can scan it in 30 seconds without leaving the PR.
187
+
188
+ When opening a PR, include a `## Verification` section in the PR body.
189
+ The summary should follow this structure:
190
+
191
+ ```markdown
192
+ ## Verification
193
+
194
+ ### Functional
195
+
196
+ ✅ Hit: calling createUser({ name: "Alice" }) → returns user with id
197
+ ✅ Clean: calling createUser({}) → validation error, no side effects
198
+
199
+ ### Tests (12 passing)
200
+
201
+ - Happy path (4): valid input, optional fields, default values, nested objects
202
+ - Error cases (5): missing required field, invalid type, duplicate key, null input, empty string
203
+ - Edge cases (2): max-length name, unicode characters
204
+ - Suggestions (1): suggests trim on whitespace-padded name
205
+
206
+ ### Integration
207
+
208
+ [x] Exported from src/users/create.ts
209
+ [x] Registered in user module
210
+ [x] Public types match call sites
211
+ [x] Error messages follow project conventions
212
+
213
+ ### Architecture Boundaries
214
+
215
+ [x] Modified files stay within allowed dependency direction
216
+ [x] No new circular dependencies or public API bypasses
217
+
218
+ ### Documentation
219
+
220
+ [x] JSDoc updated on createUser
221
+ [x] README usage section updated
222
+
223
+ ### Scope Control
224
+
225
+ Planned scope budget: touch `src/users/create.ts` and `tests/users/create.test.ts` for create-user validation only.
226
+ Scope control: changed only the planned files; no unrelated cleanup, new abstraction, dependency, or configuration surface added.
227
+ ```
228
+
229
+ If anything is `[ ]` or tests are missing, the implementation is not ready.
230
+ Do not open the PR until verification is complete.
231
+
232
+ For bug fixes and docs/chore changes, include a shorter verification
233
+ block in the same PR section.
234
+
235
+ ---
236
+
237
+ ## Quality Gate Feedback
238
+
239
+ Run the project-native gates selected by `directives/adaptive-routing.md`.
240
+ Treat test, lint, type-check, build, static-analysis, and review-bot output as
241
+ implementation feedback, not ceremony.
242
+
243
+ When a linter or static-analysis rule explains an issue, fix the underlying
244
+ pattern. Do not suppress the rule, weaken configuration, or make superficial
245
+ rewrites unless the project explicitly allows that exception and the reason is
246
+ documented.
247
+
248
+ If a finding is pre-existing or outside the task scope, state that classification
249
+ and show that the current change did not make it worse.
250
+
251
+ ---
252
+
253
+ ## Forbidden Patterns
254
+
255
+ | Pattern | Why Forbidden |
256
+ | -------------------------------------------- | ----------------------------------------------------- |
257
+ | "Tests pass, ship it" | Passing tests ≠ production-ready |
258
+ | Skipping functional proof | Must show both expected behavior AND no false positive |
259
+ | Skipping integration proof | Misconfigured code passes tests but fails in production |
260
+ | Skipping boundary proof for dependency changes | Passing tests do not prove architectural validity |
261
+ | Claiming verification without showing output | Evidence, not claims |
262
+ | Running GATES before verification | Verification catches issues GATES misses |
263
+
264
+ ---
265
+
266
+ _This directive is mandatory for all implementations, bug fixes, and configuration changes._
@@ -0,0 +1,219 @@
1
+ ---
2
+ name: workspace-isolation
3
+ description: Keeps mutable work in an isolated workspace by detecting existing isolation first, preferring native tools, and falling back to git worktrees only when needed.
4
+ version: 1.0.0
5
+ required: false
6
+ category: workflow
7
+ tools:
8
+ - claude
9
+ - codex
10
+ triggers:
11
+ - isolated-workspace
12
+ - worktree
13
+ - branch-isolation
14
+ - feature-work
15
+ routing:
16
+ load: conditional
17
+ applies_to:
18
+ - implementation
19
+ - debugging
20
+ ---
21
+
22
+ # Workspace Isolation Directive
23
+
24
+ **When to load:** Load this directive before implementation or invasive debugging
25
+ when the task will mutate a git-backed repository and the current workspace may be
26
+ shared, protected, dirty, or otherwise not isolated.
27
+
28
+ The goal is simple: protect the current workspace from task-specific edits unless
29
+ there is a good reason to work in place. Detect existing isolation first. Prefer
30
+ native workspace tools when the platform provides them. Use `git worktree` only
31
+ as a fallback.
32
+
33
+ ---
34
+
35
+ ## Core Rules
36
+
37
+ 1. **Detect before creating.** Confirm whether the current checkout is already an
38
+ isolated workspace before creating anything.
39
+ 2. **Prefer native tools.** If the platform already manages isolated workspaces,
40
+ use that tool instead of manual `git worktree` commands.
41
+ 3. **Ask before creating a new workspace when preference is unknown.** If the
42
+ user has not already asked for isolation and project instructions do not
43
+ declare a preference, ask for consent before creating a new workspace.
44
+ 4. **Treat protected or shared checkouts as isolation candidates.** If the agent
45
+ is on `main`, `master`, `trunk`, another protected/default branch, or a
46
+ checkout with unrelated local changes, prefer isolation rather than editing in
47
+ place.
48
+ 5. **Baseline after isolation.** Setup and baseline verification belong in the
49
+ workspace where the task will actually run.
50
+
51
+ ---
52
+
53
+ ## Step 0: Detect Existing Isolation
54
+
55
+ Before creating anything, determine whether the current checkout is already an
56
+ isolated workspace:
57
+
58
+ ```bash
59
+ git rev-parse --is-inside-work-tree >/dev/null 2>&1 || {
60
+ echo "Repository is not git-backed; workspace-isolation directive does not apply."
61
+ exit 0
62
+ }
63
+
64
+ GIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P)
65
+ GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P)
66
+ BRANCH=$(git branch --show-current)
67
+ ```
68
+
69
+ If `GIT_DIR != GIT_COMMON`, you may already be in a linked worktree. Guard
70
+ against submodules before concluding that:
71
+
72
+ ```bash
73
+ git rev-parse --show-superproject-working-tree 2>/dev/null
74
+ ```
75
+
76
+ If the command returns empty output, the checkout is **not** a submodule. If it
77
+ returns a path, the checkout **is** a submodule of that superproject and should
78
+ be treated as a normal checkout for this directive rather than as an already
79
+ isolated worktree.
80
+
81
+ - If `GIT_DIR != GIT_COMMON` **and** the checkout is not a submodule, treat the
82
+ current location as already isolated. Do not create another worktree.
83
+ - If `GIT_DIR == GIT_COMMON`, you are in the main checkout and should evaluate
84
+ whether a separate workspace is warranted.
85
+ - If the repository is not git-backed, this directive does not apply; state that
86
+ clearly and continue with the routed workflow.
87
+
88
+ Report the result before moving on:
89
+
90
+ - On a branch: `Already in isolated workspace at <path> on branch <name>.`
91
+ - Detached HEAD: `Already in isolated workspace at <path> (detached HEAD; branch creation may be needed later).`
92
+ - Normal checkout: `Current checkout is not isolated; deciding whether to create one before editing.`
93
+
94
+ ---
95
+
96
+ ## Step 1: Choose the Isolation Mechanism
97
+
98
+ ### 1a. Native Workspace Tools (preferred)
99
+
100
+ If the platform already provides a native worktree/workspace mechanism, use it.
101
+ Native tools often manage placement, naming, cleanup, and integration better than
102
+ manual git commands.
103
+
104
+ Do **not** bypass a native isolation tool with `git worktree add` unless the
105
+ platform explicitly requires the git fallback.
106
+
107
+ ### 1b. Git Worktree Fallback
108
+
109
+ Use `git worktree` only when no native workspace tool is available.
110
+
111
+ #### Directory selection
112
+
113
+ Use this priority order:
114
+
115
+ 1. An explicit user or project-instruction preference
116
+ 2. An existing project-local `.worktrees/`
117
+ 3. An existing project-local `worktrees/`
118
+ 4. An outside-repo worktree location
119
+ 5. A new project-local `.worktrees/` only when it is already ignored or the user explicitly approves changing ignore rules
120
+
121
+ #### Ignore verification
122
+
123
+ For project-local worktree directories, verify the directory is ignored before
124
+ creating the worktree. Check the directory you actually selected in the previous
125
+ step:
126
+
127
+ ```bash
128
+ git check-ignore -q "$CHOSEN_DIR" 2>/dev/null
129
+ ```
130
+
131
+ If the chosen directory is not ignored, do **not** silently modify tracked repo
132
+ files before isolation. Prefer an already-ignored directory, add an untracked
133
+ rule in `.git/info/exclude`, or use an outside-repo location. Ask for explicit
134
+ user consent before changing `.gitignore`.
135
+
136
+ #### Create the worktree
137
+
138
+ ```bash
139
+ git worktree add "<path>" -b "<branch-name>"
140
+ cd "<path>"
141
+ ```
142
+
143
+ If worktree creation fails because the environment blocks it (for example,
144
+ permission or sandbox restrictions), say so explicitly and continue in place only
145
+ with a documented fallback.
146
+
147
+ ---
148
+
149
+ ## Step 2: Project Setup in the Chosen Workspace
150
+
151
+ Run the project's documented setup commands in the workspace where the task will
152
+ execute. Prefer project instructions over generic ecosystem guesses.
153
+
154
+ Minimum expectations:
155
+
156
+ - Ensure the branch/workspace is the one you plan to edit
157
+ - Run only the setup commands needed to make that workspace ready
158
+ - Re-check `git status --short` so the baseline is understood in the actual work area
159
+
160
+ ---
161
+
162
+ ## Step 3: Baseline Proof Before Editing
163
+
164
+ Before implementation starts, show that the chosen workspace is ready:
165
+
166
+ - What workspace/path is active
167
+ - What branch is active
168
+ - Whether the workspace began clean or had pre-existing changes
169
+ - Which baseline command(s) were run for this repository
170
+
171
+ If baseline tests or checks fail, report that and ask whether to proceed. Do not
172
+ silently treat a broken baseline as acceptable.
173
+
174
+ ---
175
+
176
+ ## Step 4: Proceed or Fall Back
177
+
178
+ Once isolation and baseline are established:
179
+
180
+ - Proceed with the routed workflow in the isolated workspace, or
181
+ - State the fallback clearly if you must work in place
182
+
183
+ Fallbacks are acceptable only when:
184
+
185
+ - the user explicitly prefers in-place work,
186
+ - the repository is not git-backed,
187
+ - a native or git-based isolation mechanism is unavailable, or
188
+ - the environment blocks workspace creation and the user still wants work to continue
189
+
190
+ ---
191
+
192
+ ## Forbidden Patterns
193
+
194
+ | Pattern | Why Forbidden |
195
+ | --- | --- |
196
+ | Creating a new worktree without checking whether one already exists | Risks nested or duplicate workspaces |
197
+ | Using `git worktree add` when a native workspace tool is available | Fights the platform/harness |
198
+ | Editing a protected/default branch or dirty shared checkout without considering isolation | Needlessly risks unrelated work |
199
+ | Creating a project-local worktree directory without ignore verification | Pollutes repo status and can leak files into commits |
200
+ | Running setup or baseline in one checkout, then editing a different one | Evidence no longer matches reality |
201
+ | Treating environment failures as silent permission to continue | Hides risk and makes later debugging harder |
202
+
203
+ ---
204
+
205
+ ## Quick Reference
206
+
207
+ | Situation | Action |
208
+ | --- | --- |
209
+ | Already in a linked worktree | Reuse it; do not create another |
210
+ | In a normal checkout on a shared/default branch | Prefer isolation before editing |
211
+ | User already asked for isolation | Create or enter the isolated workspace without re-asking |
212
+ | Preference unknown | Ask before creating a new workspace |
213
+ | Native workspace tool exists | Use it before git fallback |
214
+ | No native tool exists | Use `git worktree` with ignore verification |
215
+ | Worktree creation is blocked | State the fallback and continue only with explicit justification |
216
+ | Baseline is failing | Report it and get direction before proceeding |
217
+
218
+ _This directive complements adaptive routing: the router decides **when** isolation
219
+ matters, and this directive governs **how** to establish it safely._
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}