agentsys 5.2.1 → 5.3.1
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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.cursor/commands/audit-project-agents.md +454 -0
- package/.cursor/commands/audit-project-github.md +141 -0
- package/.cursor/commands/audit-project.md +330 -0
- package/.cursor/commands/consult.md +417 -0
- package/.cursor/commands/debate.md +381 -0
- package/.cursor/commands/delivery-approval.md +334 -0
- package/.cursor/commands/deslop.md +142 -0
- package/.cursor/commands/drift-detect.md +259 -0
- package/.cursor/commands/enhance.md +172 -0
- package/.cursor/commands/learn.md +165 -0
- package/.cursor/commands/next-task.md +519 -0
- package/.cursor/commands/perf.md +464 -0
- package/.cursor/commands/repo-map.md +124 -0
- package/.cursor/commands/ship-ci-review-loop.md +468 -0
- package/.cursor/commands/ship-deployment.md +348 -0
- package/.cursor/commands/ship-error-handling.md +265 -0
- package/.cursor/commands/ship.md +517 -0
- package/.cursor/commands/sync-docs.md +171 -0
- package/.cursor/commands/web-ctl.md +101 -0
- package/.cursor/skills/consult/SKILL.md +425 -0
- package/.cursor/skills/debate/SKILL.md +316 -0
- package/.cursor/skills/deslop/SKILL.md +204 -0
- package/.cursor/skills/discover-tasks/SKILL.md +297 -0
- package/.cursor/skills/drift-analysis/SKILL.md +324 -0
- package/.cursor/skills/enhance-agent-prompts/SKILL.md +277 -0
- package/.cursor/skills/enhance-claude-memory/SKILL.md +387 -0
- package/.cursor/skills/enhance-cross-file/SKILL.md +110 -0
- package/.cursor/skills/enhance-docs/SKILL.md +298 -0
- package/.cursor/skills/enhance-hooks/SKILL.md +554 -0
- package/.cursor/skills/enhance-orchestrator/SKILL.md +255 -0
- package/.cursor/skills/enhance-plugins/SKILL.md +319 -0
- package/.cursor/skills/enhance-prompts/SKILL.md +340 -0
- package/.cursor/skills/enhance-skills/SKILL.md +436 -0
- package/.cursor/skills/learn/SKILL.md +349 -0
- package/.cursor/skills/orchestrate-review/SKILL.md +260 -0
- package/.cursor/skills/perf-analyzer/SKILL.md +37 -0
- package/.cursor/skills/perf-baseline-manager/SKILL.md +30 -0
- package/.cursor/skills/perf-benchmarker/SKILL.md +52 -0
- package/.cursor/skills/perf-code-paths/SKILL.md +32 -0
- package/.cursor/skills/perf-investigation-logger/SKILL.md +41 -0
- package/.cursor/skills/perf-profiler/SKILL.md +42 -0
- package/.cursor/skills/perf-theory-gatherer/SKILL.md +35 -0
- package/.cursor/skills/perf-theory-tester/SKILL.md +36 -0
- package/.cursor/skills/repo-mapping/SKILL.md +83 -0
- package/.cursor/skills/sync-docs/SKILL.md +351 -0
- package/.cursor/skills/validate-delivery/SKILL.md +186 -0
- package/.cursor/skills/web-auth/SKILL.md +177 -0
- package/.cursor/skills/web-browse/SKILL.md +516 -0
- package/.kiro/agents/agent-enhancer.json +12 -0
- package/.kiro/agents/ci-fixer.json +13 -0
- package/.kiro/agents/ci-monitor.json +12 -0
- package/.kiro/agents/claudemd-enhancer.json +12 -0
- package/.kiro/agents/consult-agent.json +13 -0
- package/.kiro/agents/cross-file-enhancer.json +12 -0
- package/.kiro/agents/debate-orchestrator.json +13 -0
- package/.kiro/agents/delivery-validator.json +12 -0
- package/.kiro/agents/deslop-agent.json +12 -0
- package/.kiro/agents/docs-enhancer.json +12 -0
- package/.kiro/agents/exploration-agent.json +12 -0
- package/.kiro/agents/hooks-enhancer.json +11 -0
- package/.kiro/agents/implementation-agent.json +13 -0
- package/.kiro/agents/learn-agent.json +12 -0
- package/.kiro/agents/map-validator.json +11 -0
- package/.kiro/agents/perf-analyzer.json +12 -0
- package/.kiro/agents/perf-code-paths.json +11 -0
- package/.kiro/agents/perf-investigation-logger.json +12 -0
- package/.kiro/agents/perf-orchestrator.json +13 -0
- package/.kiro/agents/perf-theory-gatherer.json +12 -0
- package/.kiro/agents/perf-theory-tester.json +13 -0
- package/.kiro/agents/plan-synthesizer.json +12 -0
- package/.kiro/agents/planning-agent.json +12 -0
- package/.kiro/agents/plugin-enhancer.json +12 -0
- package/.kiro/agents/prompt-enhancer.json +12 -0
- package/.kiro/agents/reviewer-perf-test.json +11 -0
- package/.kiro/agents/reviewer-quality-security.json +11 -0
- package/.kiro/agents/simple-fixer.json +13 -0
- package/.kiro/agents/skills-enhancer.json +11 -0
- package/.kiro/agents/sync-docs-agent.json +13 -0
- package/.kiro/agents/task-discoverer.json +12 -0
- package/.kiro/agents/test-coverage-checker.json +12 -0
- package/.kiro/agents/web-session.json +12 -0
- package/.kiro/agents/worktree-manager.json +13 -0
- package/.kiro/skills/consult/SKILL.md +425 -0
- package/.kiro/skills/debate/SKILL.md +316 -0
- package/.kiro/skills/deslop/SKILL.md +204 -0
- package/.kiro/skills/discover-tasks/SKILL.md +297 -0
- package/.kiro/skills/drift-analysis/SKILL.md +324 -0
- package/.kiro/skills/enhance-agent-prompts/SKILL.md +277 -0
- package/.kiro/skills/enhance-claude-memory/SKILL.md +387 -0
- package/.kiro/skills/enhance-cross-file/SKILL.md +110 -0
- package/.kiro/skills/enhance-docs/SKILL.md +298 -0
- package/.kiro/skills/enhance-hooks/SKILL.md +554 -0
- package/.kiro/skills/enhance-orchestrator/SKILL.md +255 -0
- package/.kiro/skills/enhance-plugins/SKILL.md +319 -0
- package/.kiro/skills/enhance-prompts/SKILL.md +340 -0
- package/.kiro/skills/enhance-skills/SKILL.md +436 -0
- package/.kiro/skills/learn/SKILL.md +349 -0
- package/.kiro/skills/orchestrate-review/SKILL.md +260 -0
- package/.kiro/skills/perf-analyzer/SKILL.md +37 -0
- package/.kiro/skills/perf-baseline-manager/SKILL.md +30 -0
- package/.kiro/skills/perf-benchmarker/SKILL.md +52 -0
- package/.kiro/skills/perf-code-paths/SKILL.md +32 -0
- package/.kiro/skills/perf-investigation-logger/SKILL.md +41 -0
- package/.kiro/skills/perf-profiler/SKILL.md +42 -0
- package/.kiro/skills/perf-theory-gatherer/SKILL.md +35 -0
- package/.kiro/skills/perf-theory-tester/SKILL.md +36 -0
- package/.kiro/skills/repo-mapping/SKILL.md +83 -0
- package/.kiro/skills/sync-docs/SKILL.md +351 -0
- package/.kiro/skills/validate-delivery/SKILL.md +186 -0
- package/.kiro/skills/web-auth/SKILL.md +177 -0
- package/.kiro/skills/web-browse/SKILL.md +516 -0
- package/.kiro/steering/audit-project-agents.md +459 -0
- package/.kiro/steering/audit-project-github.md +146 -0
- package/.kiro/steering/audit-project.md +330 -0
- package/.kiro/steering/consult.md +422 -0
- package/.kiro/steering/debate.md +386 -0
- package/.kiro/steering/delivery-approval.md +339 -0
- package/.kiro/steering/deslop.md +149 -0
- package/.kiro/steering/drift-detect.md +264 -0
- package/.kiro/steering/enhance.md +177 -0
- package/.kiro/steering/learn.md +166 -0
- package/.kiro/steering/next-task.md +481 -0
- package/.kiro/steering/perf.md +469 -0
- package/.kiro/steering/repo-map.md +126 -0
- package/.kiro/steering/ship-ci-review-loop.md +473 -0
- package/.kiro/steering/ship-deployment.md +353 -0
- package/.kiro/steering/ship-error-handling.md +270 -0
- package/.kiro/steering/ship.md +522 -0
- package/.kiro/steering/sync-docs.md +178 -0
- package/.kiro/steering/web-ctl.md +106 -0
- package/AGENTS.md +5 -3
- package/CHANGELOG.md +25 -1
- package/README.md +6 -5
- package/agent-knowledge/AGENTS.md +32 -2
- package/agent-knowledge/acp-with-codex-gemini-copilot-claude.md +504 -0
- package/agent-knowledge/kiro-supervised-autopilot.md +400 -0
- package/agent-knowledge/resources/acp-with-codex-gemini-copilot-claude-sources.json +408 -0
- package/agent-knowledge/resources/kiro-supervised-autopilot-sources.json +135 -0
- package/bin/cli.js +176 -9
- package/lib/adapter-transforms.js +224 -1
- package/lib/cross-platform/index.js +9 -3
- package/lib/discovery/index.js +22 -0
- package/lib/platform/state-dir.js +16 -2
- package/package.json +1 -1
- package/scripts/dev-install.js +137 -1
- package/scripts/gen-adapters.js +66 -4
- package/site/content.json +1 -1
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: enhance-agent-prompts
|
|
3
|
+
description: "Use when improving agent prompts, frontmatter, and tool restrictions."
|
|
4
|
+
version: 5.1.0
|
|
5
|
+
argument-hint: "[path] [--fix] [--verbose]"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# enhance-agent-prompts
|
|
9
|
+
|
|
10
|
+
Analyze agent prompt files for prompt engineering best practices.
|
|
11
|
+
|
|
12
|
+
## Parse Arguments
|
|
13
|
+
|
|
14
|
+
```javascript
|
|
15
|
+
const args = '$ARGUMENTS'.split(' ').filter(Boolean);
|
|
16
|
+
const targetPath = args.find(a => !a.startsWith('--')) || '.';
|
|
17
|
+
const fix = args.includes('--fix');
|
|
18
|
+
const verbose = args.includes('--verbose');
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Agent File Locations
|
|
22
|
+
|
|
23
|
+
| Platform | Global | Project |
|
|
24
|
+
|----------|--------|---------|
|
|
25
|
+
| Claude Code | `~/.claude/agents/*.md` | `.claude/agents/*.md` |
|
|
26
|
+
| OpenCode | `~/.config/opencode/agents/*.md` | `.opencode/agents/*.md` |
|
|
27
|
+
| Codex | `~/.codex/skills/` | `AGENTS.md` |
|
|
28
|
+
|
|
29
|
+
## Workflow
|
|
30
|
+
|
|
31
|
+
1. **Discover** - Find agent .md files
|
|
32
|
+
2. **Parse** - Extract frontmatter, analyze content
|
|
33
|
+
3. **Check** - Run 30 pattern checks
|
|
34
|
+
4. **Report** - Generate markdown output
|
|
35
|
+
5. **Fix** - Apply auto-fixes if --fix flag
|
|
36
|
+
|
|
37
|
+
## Detection Patterns
|
|
38
|
+
|
|
39
|
+
### 1. Frontmatter (HIGH)
|
|
40
|
+
|
|
41
|
+
```yaml
|
|
42
|
+
---
|
|
43
|
+
name: agent-name # Required: kebab-case
|
|
44
|
+
description: "What and when" # Required: WHEN to use (see "Intern Test")
|
|
45
|
+
tools: Read, Glob, Grep # Required: restricted list
|
|
46
|
+
model: sonnet # Optional: opus | sonnet | haiku
|
|
47
|
+
---
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Model Selection:**
|
|
51
|
+
- **opus**: Complex reasoning, errors compound
|
|
52
|
+
- **sonnet**: Most agents, validation
|
|
53
|
+
- **haiku**: Mechanical execution, no judgment
|
|
54
|
+
|
|
55
|
+
**Tool Syntax:** `Read`, `Read(src/**)`, `Bash(git:*)`, `Bash(npm:*)`
|
|
56
|
+
|
|
57
|
+
**The "Intern Test"** - Can someone invoke this agent given only its description?
|
|
58
|
+
```yaml
|
|
59
|
+
# Bad
|
|
60
|
+
description: Reviews code
|
|
61
|
+
|
|
62
|
+
# Good - triggers, capabilities, exclusions
|
|
63
|
+
description: Reviews code for security vulnerabilities. Use for PRs touching auth, API, data handling. Not for style reviews.
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 2. Structure (HIGH)
|
|
67
|
+
|
|
68
|
+
**Required sections:** Role ("You are..."), Output format, Constraints
|
|
69
|
+
|
|
70
|
+
**Position-aware order** (LLMs recall START/END better than MIDDLE):
|
|
71
|
+
1. Role/Identity (START)
|
|
72
|
+
2. Capabilities, Workflow, Examples
|
|
73
|
+
3. Constraints (END)
|
|
74
|
+
|
|
75
|
+
### 3. Instruction Effectiveness (HIGH)
|
|
76
|
+
|
|
77
|
+
**Positive over negative:**
|
|
78
|
+
- Bad: "Don't assume file paths exist"
|
|
79
|
+
- Good: "Verify file paths using Glob before reading"
|
|
80
|
+
|
|
81
|
+
**Strong constraint language:**
|
|
82
|
+
- Bad: "should", "try to", "consider"
|
|
83
|
+
- Good: "MUST", "ALWAYS", "NEVER"
|
|
84
|
+
|
|
85
|
+
**Include WHY** for important rules - motivation improves compliance.
|
|
86
|
+
|
|
87
|
+
### 4. Tool Configuration (HIGH)
|
|
88
|
+
|
|
89
|
+
**Principle of Least Privilege:**
|
|
90
|
+
| Agent Type | Tools |
|
|
91
|
+
|------------|-------|
|
|
92
|
+
| Read-only | `Read, Glob, Grep` |
|
|
93
|
+
| Code modifier | `Read, Edit, Write, Glob, Grep` |
|
|
94
|
+
| Git ops | `Bash(git:*)` |
|
|
95
|
+
| Build/test | `Bash(npm:*), Bash(node:*)` |
|
|
96
|
+
|
|
97
|
+
**Issues:**
|
|
98
|
+
- `Bash` without scope → should be `Bash(git:*)`
|
|
99
|
+
- `Task` in subagent → subagents cannot spawn subagents
|
|
100
|
+
- >20 tools → increases error rates ("Less-is-More")
|
|
101
|
+
|
|
102
|
+
### 5. Subagent Config (MEDIUM)
|
|
103
|
+
|
|
104
|
+
```yaml
|
|
105
|
+
context: fork # Isolated context for verbose output
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
- Subagents cannot spawn subagents (no `Task` in tools)
|
|
109
|
+
- Return summaries, not full output
|
|
110
|
+
|
|
111
|
+
**Cross-platform modes:**
|
|
112
|
+
| Platform | Primary | Subagent |
|
|
113
|
+
|----------|---------|----------|
|
|
114
|
+
| Claude Code | Default | Via Task tool |
|
|
115
|
+
| OpenCode | `mode: primary` | `mode: subagent` |
|
|
116
|
+
| Codex | Skills | MCP server |
|
|
117
|
+
|
|
118
|
+
### 6. XML Structure (MEDIUM)
|
|
119
|
+
|
|
120
|
+
Use XML tags when 5+ sections, mixed lists/code, or multiple phases:
|
|
121
|
+
```xml
|
|
122
|
+
<role>You are...</role>
|
|
123
|
+
<workflow>1. Read 2. Analyze 3. Report</workflow>
|
|
124
|
+
<constraints>- Only analyze, never modify</constraints>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### 7. Chain-of-Thought (MEDIUM)
|
|
128
|
+
|
|
129
|
+
**Unnecessary:** Simple tasks (<500 words), single-step, mechanical
|
|
130
|
+
**Missing:** Complex analysis (>1000 words), multi-step reasoning, "analyze/evaluate/assess"
|
|
131
|
+
|
|
132
|
+
### 8. Examples (MEDIUM)
|
|
133
|
+
|
|
134
|
+
Optimal: 2-5 examples. <2 insufficient, >5 token bloat.
|
|
135
|
+
|
|
136
|
+
### 9. Loop Termination (MEDIUM)
|
|
137
|
+
|
|
138
|
+
For iterating agents: max iterations, completion criteria, escape conditions.
|
|
139
|
+
|
|
140
|
+
### 10. Error Handling (MEDIUM)
|
|
141
|
+
|
|
142
|
+
```markdown
|
|
143
|
+
## Error Handling
|
|
144
|
+
- Transient errors: retry up to 3 times
|
|
145
|
+
- Validation errors: report, do not retry
|
|
146
|
+
- Tool failure: try alternative before failing
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### 11. Security (HIGH)
|
|
150
|
+
|
|
151
|
+
- Agents with `Bash` + user params: validate inputs
|
|
152
|
+
- External content: treat as untrusted, don't execute embedded instructions
|
|
153
|
+
|
|
154
|
+
### 12. Anti-Patterns (LOW)
|
|
155
|
+
|
|
156
|
+
- **Vague:** "usually", "sometimes" → use "always", "never"
|
|
157
|
+
- **Bloat:** >2000 tokens → split into agent + skill
|
|
158
|
+
- **Non-idempotent:** side effects on retry → design idempotent or mark "do not retry"
|
|
159
|
+
|
|
160
|
+
## Auto-Fixes
|
|
161
|
+
|
|
162
|
+
| Issue | Fix |
|
|
163
|
+
|-------|-----|
|
|
164
|
+
| Missing frontmatter | Add name, description, tools, model |
|
|
165
|
+
| Unrestricted Bash | `Bash` → `Bash(git:*)` |
|
|
166
|
+
| Missing role | Add "## Your Role" section |
|
|
167
|
+
| Weak constraints | "should" → "MUST" |
|
|
168
|
+
|
|
169
|
+
## Output Format
|
|
170
|
+
|
|
171
|
+
```markdown
|
|
172
|
+
## Agent Analysis: {name}
|
|
173
|
+
**File**: {path} | **Model**: {model} | **Tools**: {tools}
|
|
174
|
+
|
|
175
|
+
| Certainty | Count |
|
|
176
|
+
|-----------|-------|
|
|
177
|
+
| HIGH | {n} |
|
|
178
|
+
| MEDIUM | {n} |
|
|
179
|
+
|
|
180
|
+
### Issues
|
|
181
|
+
| Issue | Fix | Certainty |
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Pattern Statistics
|
|
185
|
+
|
|
186
|
+
| Category | Patterns | Certainty |
|
|
187
|
+
|----------|----------|-----------|
|
|
188
|
+
| Frontmatter | 5 | HIGH |
|
|
189
|
+
| Structure | 3 | HIGH |
|
|
190
|
+
| Instructions | 3 | HIGH |
|
|
191
|
+
| Tools | 4 | HIGH |
|
|
192
|
+
| Security | 2 | HIGH |
|
|
193
|
+
| Subagent | 3 | MEDIUM |
|
|
194
|
+
| XML/CoT/Examples | 4 | MEDIUM |
|
|
195
|
+
| Error/Loop | 3 | MEDIUM |
|
|
196
|
+
| Anti-Patterns | 3 | LOW |
|
|
197
|
+
| **Total** | **30** | - |
|
|
198
|
+
|
|
199
|
+
<examples>
|
|
200
|
+
### Unrestricted Bash
|
|
201
|
+
<bad_example>
|
|
202
|
+
```yaml
|
|
203
|
+
tools: Read, Bash
|
|
204
|
+
```
|
|
205
|
+
</bad_example>
|
|
206
|
+
<good_example>
|
|
207
|
+
```yaml
|
|
208
|
+
tools: Read, Bash(git:*), Bash(npm:test)
|
|
209
|
+
```
|
|
210
|
+
</good_example>
|
|
211
|
+
|
|
212
|
+
### Description Trigger
|
|
213
|
+
<bad_example>
|
|
214
|
+
```yaml
|
|
215
|
+
description: Reviews code
|
|
216
|
+
```
|
|
217
|
+
</bad_example>
|
|
218
|
+
<good_example>
|
|
219
|
+
```yaml
|
|
220
|
+
description: Reviews code for security. Use for PRs touching auth, API, data. Not for style.
|
|
221
|
+
```
|
|
222
|
+
</good_example>
|
|
223
|
+
|
|
224
|
+
### Model Selection
|
|
225
|
+
<bad_example>
|
|
226
|
+
```yaml
|
|
227
|
+
name: json-formatter
|
|
228
|
+
model: opus # Overkill for mechanical task
|
|
229
|
+
```
|
|
230
|
+
</bad_example>
|
|
231
|
+
<good_example>
|
|
232
|
+
```yaml
|
|
233
|
+
name: json-formatter
|
|
234
|
+
model: haiku # Simple, mechanical
|
|
235
|
+
```
|
|
236
|
+
</good_example>
|
|
237
|
+
|
|
238
|
+
### Constraint Language
|
|
239
|
+
<bad_example>
|
|
240
|
+
```markdown
|
|
241
|
+
- Try to validate inputs when possible
|
|
242
|
+
```
|
|
243
|
+
</bad_example>
|
|
244
|
+
<good_example>
|
|
245
|
+
```markdown
|
|
246
|
+
- MUST validate all inputs before processing
|
|
247
|
+
```
|
|
248
|
+
</good_example>
|
|
249
|
+
|
|
250
|
+
### Subagent Tools
|
|
251
|
+
<bad_example>
|
|
252
|
+
```yaml
|
|
253
|
+
context: fork
|
|
254
|
+
tools: Read, Glob, Task # Task not allowed
|
|
255
|
+
```
|
|
256
|
+
</bad_example>
|
|
257
|
+
<good_example>
|
|
258
|
+
```yaml
|
|
259
|
+
context: fork
|
|
260
|
+
tools: Read, Glob, Grep
|
|
261
|
+
```
|
|
262
|
+
</good_example>
|
|
263
|
+
</examples>
|
|
264
|
+
|
|
265
|
+
## References
|
|
266
|
+
|
|
267
|
+
- `agent-docs/PROMPT-ENGINEERING-REFERENCE.md` - Instructions, XML, examples
|
|
268
|
+
- `agent-docs/CLAUDE-CODE-REFERENCE.md` - Frontmatter, tools, subagents
|
|
269
|
+
- `agent-docs/FUNCTION-CALLING-TOOL-USE-REFERENCE.md` - "Intern Test", security
|
|
270
|
+
- `agent-docs/OPENCODE-REFERENCE.md` - Modes, permissions
|
|
271
|
+
- `agent-docs/CODEX-REFERENCE.md` - Skill triggers
|
|
272
|
+
|
|
273
|
+
## Constraints
|
|
274
|
+
|
|
275
|
+
- Auto-fix only HIGH certainty issues
|
|
276
|
+
- Preserve existing frontmatter when adding fields
|
|
277
|
+
- Never remove content, only suggest improvements
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: enhance-claude-memory
|
|
3
|
+
description: "Use when improving CLAUDE.md or AGENTS.md project memory files."
|
|
4
|
+
version: 5.1.0
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# enhance-claude-memory
|
|
8
|
+
|
|
9
|
+
Analyze project memory files (CLAUDE.md, AGENTS.md) for optimization.
|
|
10
|
+
|
|
11
|
+
## Cross-Tool Detection
|
|
12
|
+
|
|
13
|
+
Searches for project memory files in order:
|
|
14
|
+
1. CLAUDE.md (Claude Code)
|
|
15
|
+
2. AGENTS.md (OpenCode, Codex)
|
|
16
|
+
3. .github/CLAUDE.md
|
|
17
|
+
4. .github/AGENTS.md
|
|
18
|
+
|
|
19
|
+
## File Hierarchy (Reference)
|
|
20
|
+
|
|
21
|
+
**CLAUDE.md** (Claude Code):
|
|
22
|
+
| Location | Scope |
|
|
23
|
+
|----------|-------|
|
|
24
|
+
| `~/.claude/CLAUDE.md` | Global (all projects) |
|
|
25
|
+
| `.claude/CLAUDE.md` or `./CLAUDE.md` | Project root |
|
|
26
|
+
| `src/.claude/CLAUDE.md` | Directory-specific |
|
|
27
|
+
|
|
28
|
+
**AGENTS.md** (OpenCode, Codex, and other AI tools):
|
|
29
|
+
| Location | Scope |
|
|
30
|
+
|----------|-------|
|
|
31
|
+
| `~/.config/opencode/AGENTS.md` or `~/.codex/AGENTS.md` | Global (all projects) |
|
|
32
|
+
| `.opencode/AGENTS.md` or `./AGENTS.md` | Project root |
|
|
33
|
+
| `src/AGENTS.md` | Directory-specific |
|
|
34
|
+
|
|
35
|
+
Both files serve the same purpose: project memory for AI assistants. Use CLAUDE.md for Claude Code projects, AGENTS.md for cross-tool compatibility, or both for maximum coverage.
|
|
36
|
+
|
|
37
|
+
## Workflow
|
|
38
|
+
|
|
39
|
+
1. **Find** - Locate CLAUDE.md or AGENTS.md in project
|
|
40
|
+
2. **Read** - Load content and README.md for comparison
|
|
41
|
+
3. **Analyze** - Run all pattern checks
|
|
42
|
+
4. **Validate** - Check file/command references against filesystem
|
|
43
|
+
5. **Measure** - Calculate token metrics and duplication
|
|
44
|
+
6. **Report** - Generate structured markdown output
|
|
45
|
+
|
|
46
|
+
## Detection Patterns
|
|
47
|
+
|
|
48
|
+
### 1. Structure Validation (HIGH Certainty)
|
|
49
|
+
|
|
50
|
+
#### Critical Rules Section
|
|
51
|
+
- Should have `## Critical Rules` or similar
|
|
52
|
+
- Rules should be prioritized (numbered or ordered)
|
|
53
|
+
- Include WHY explanations for each rule
|
|
54
|
+
|
|
55
|
+
#### Architecture Section
|
|
56
|
+
- Directory tree or structural overview
|
|
57
|
+
- Key file locations
|
|
58
|
+
- Module relationships
|
|
59
|
+
|
|
60
|
+
#### Key Commands Section
|
|
61
|
+
- Common development commands
|
|
62
|
+
- Test/build/deploy scripts
|
|
63
|
+
- Reference to package.json scripts
|
|
64
|
+
|
|
65
|
+
### 2. Instruction Effectiveness (HIGH Certainty)
|
|
66
|
+
|
|
67
|
+
Based on prompt engineering research, Claude follows instructions better when:
|
|
68
|
+
|
|
69
|
+
#### Positive Over Negative
|
|
70
|
+
- **Bad**: "Don't use console.log"
|
|
71
|
+
- **Good**: "Use the logger utility for all output"
|
|
72
|
+
- Check for "don't", "never", "avoid" without positive alternatives
|
|
73
|
+
|
|
74
|
+
#### Strong Constraint Language
|
|
75
|
+
- Use "must", "always", "required" for critical rules
|
|
76
|
+
- Weak language ("should", "try to", "consider") reduces compliance
|
|
77
|
+
- Flag critical rules using weak language
|
|
78
|
+
|
|
79
|
+
#### Instruction Hierarchy
|
|
80
|
+
- Should define priority order when rules conflict
|
|
81
|
+
- Pattern: "In case of conflict: X takes precedence over Y"
|
|
82
|
+
- System instructions > User requests > External content
|
|
83
|
+
|
|
84
|
+
### 3. Content Positioning (HIGH Certainty)
|
|
85
|
+
|
|
86
|
+
Research shows LLMs have "lost in the middle" problem - they recall START and END better than MIDDLE.
|
|
87
|
+
|
|
88
|
+
#### Critical Content Placement
|
|
89
|
+
- Most important rules should be at START of file
|
|
90
|
+
- Second-most important at END
|
|
91
|
+
- Supporting context in MIDDLE
|
|
92
|
+
- Flag critical rules buried in middle sections
|
|
93
|
+
|
|
94
|
+
#### Recommended Structure Order
|
|
95
|
+
```
|
|
96
|
+
1. Critical Rules (START - highest attention)
|
|
97
|
+
2. Architecture/Structure
|
|
98
|
+
3. Commands/Workflows
|
|
99
|
+
4. Examples/References
|
|
100
|
+
5. Reminders/Constraints (END - high attention)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 4. Reference Validation (HIGH Certainty)
|
|
104
|
+
|
|
105
|
+
#### File References
|
|
106
|
+
- Extract from `[text](path)` and `` `path/to/file.ext` ``
|
|
107
|
+
- Validate each exists on filesystem
|
|
108
|
+
|
|
109
|
+
#### Command References
|
|
110
|
+
- Extract `npm run <script>` and `npm <command>`
|
|
111
|
+
- Validate against package.json scripts
|
|
112
|
+
|
|
113
|
+
### 5. Efficiency Analysis (MEDIUM Certainty)
|
|
114
|
+
|
|
115
|
+
#### Token Count
|
|
116
|
+
- Estimate: `characters / 4` or `words * 1.3`
|
|
117
|
+
- Recommended max: 1500 tokens (~6000 characters)
|
|
118
|
+
- Flag files exceeding threshold
|
|
119
|
+
|
|
120
|
+
#### README Duplication
|
|
121
|
+
- Detect overlap with README.md
|
|
122
|
+
- Flag >40% content duplication
|
|
123
|
+
- CLAUDE.md should complement README, not duplicate
|
|
124
|
+
|
|
125
|
+
#### Verbosity
|
|
126
|
+
- Prefer bulleted lists over prose paragraphs
|
|
127
|
+
- Constraints as lists are easier to follow
|
|
128
|
+
- Flag long prose blocks (>5 sentences)
|
|
129
|
+
|
|
130
|
+
### 6. Quality Checks (MEDIUM Certainty)
|
|
131
|
+
|
|
132
|
+
#### WHY Explanations
|
|
133
|
+
- Rules should explain rationale
|
|
134
|
+
- Pattern: `*WHY: explanation*` or indented explanation
|
|
135
|
+
- Flag rules without explanations
|
|
136
|
+
|
|
137
|
+
#### Structure Depth
|
|
138
|
+
- Avoid deep nesting (>3 levels)
|
|
139
|
+
- Keep hierarchy scannable
|
|
140
|
+
- Flat structures parse better
|
|
141
|
+
|
|
142
|
+
#### XML-Style Tags (Optional Enhancement)
|
|
143
|
+
- Claude was trained on XML tags
|
|
144
|
+
- `<critical-rules>`, `<architecture>`, `<constraints>` improve parsing
|
|
145
|
+
- Not required but can improve instruction following
|
|
146
|
+
|
|
147
|
+
### 7. Agent/Skill Definitions (MEDIUM Certainty)
|
|
148
|
+
|
|
149
|
+
If file defines custom agents or skills:
|
|
150
|
+
|
|
151
|
+
#### Agent Definition Format
|
|
152
|
+
```markdown
|
|
153
|
+
### agent-name
|
|
154
|
+
Model: claude-sonnet-4-20250514
|
|
155
|
+
Description: What this agent does and when to use it
|
|
156
|
+
Tools: Read, Grep, Glob
|
|
157
|
+
Instructions: Specific behavioral instructions
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Required fields: Description (when to use), Tools (restricted set)
|
|
161
|
+
Optional: Model, Instructions
|
|
162
|
+
|
|
163
|
+
#### Skill References
|
|
164
|
+
- Skills should have clear trigger descriptions
|
|
165
|
+
- "Use when..." pattern helps auto-invocation
|
|
166
|
+
|
|
167
|
+
### 8. Cross-Platform Compatibility (MEDIUM/HIGH Certainty)
|
|
168
|
+
|
|
169
|
+
#### State Directory
|
|
170
|
+
- Don't hardcode `.claude/`
|
|
171
|
+
- Support `.opencode/`, `.codex/`
|
|
172
|
+
- Use `${STATE_DIR}/` or document variations
|
|
173
|
+
|
|
174
|
+
#### Terminology
|
|
175
|
+
- Avoid Claude-specific language for shared files
|
|
176
|
+
- Use "AI assistant" generically
|
|
177
|
+
- Or explicitly note "Claude Code" vs "OpenCode" differences
|
|
178
|
+
|
|
179
|
+
## Output Format
|
|
180
|
+
|
|
181
|
+
```markdown
|
|
182
|
+
# Project Memory Analysis: {filename}
|
|
183
|
+
|
|
184
|
+
**File**: {path}
|
|
185
|
+
**Type**: {CLAUDE.md | AGENTS.md}
|
|
186
|
+
|
|
187
|
+
## Metrics
|
|
188
|
+
| Metric | Value |
|
|
189
|
+
|--------|-------|
|
|
190
|
+
| Estimated Tokens | {tokens} |
|
|
191
|
+
| README Overlap | {percent}% |
|
|
192
|
+
|
|
193
|
+
## Summary
|
|
194
|
+
| Certainty | Count |
|
|
195
|
+
|-----------|-------|
|
|
196
|
+
| HIGH | {n} |
|
|
197
|
+
| MEDIUM | {n} |
|
|
198
|
+
|
|
199
|
+
### Structure Issues ({n})
|
|
200
|
+
| Issue | Fix | Certainty |
|
|
201
|
+
|
|
202
|
+
### Instruction Issues ({n})
|
|
203
|
+
| Issue | Fix | Certainty |
|
|
204
|
+
|
|
205
|
+
### Positioning Issues ({n})
|
|
206
|
+
| Issue | Fix | Certainty |
|
|
207
|
+
|
|
208
|
+
### Reference Issues ({n})
|
|
209
|
+
| Issue | Fix | Certainty |
|
|
210
|
+
|
|
211
|
+
### Efficiency Issues ({n})
|
|
212
|
+
| Issue | Fix | Certainty |
|
|
213
|
+
|
|
214
|
+
### Cross-Platform Issues ({n})
|
|
215
|
+
| Issue | Fix | Certainty |
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Pattern Statistics
|
|
219
|
+
|
|
220
|
+
| Category | Patterns | Certainty |
|
|
221
|
+
|----------|----------|-----------|
|
|
222
|
+
| Structure | 3 | HIGH |
|
|
223
|
+
| Instruction Effectiveness | 3 | HIGH |
|
|
224
|
+
| Content Positioning | 2 | HIGH |
|
|
225
|
+
| Reference | 2 | HIGH |
|
|
226
|
+
| Efficiency | 3 | MEDIUM |
|
|
227
|
+
| Quality | 3 | MEDIUM |
|
|
228
|
+
| Agent/Skill Definitions | 2 | MEDIUM |
|
|
229
|
+
| Cross-Platform | 2 | MEDIUM/HIGH |
|
|
230
|
+
| **Total** | **20** | - |
|
|
231
|
+
|
|
232
|
+
<examples>
|
|
233
|
+
### Example: Missing WHY Explanations
|
|
234
|
+
|
|
235
|
+
<bad_example>
|
|
236
|
+
```markdown
|
|
237
|
+
## Rules
|
|
238
|
+
1. Always run tests before committing
|
|
239
|
+
2. Use semantic commit messages
|
|
240
|
+
```
|
|
241
|
+
**Issue**: Rules without rationale are harder to follow.
|
|
242
|
+
</bad_example>
|
|
243
|
+
|
|
244
|
+
<good_example>
|
|
245
|
+
```markdown
|
|
246
|
+
## Critical Rules
|
|
247
|
+
1. **Always run tests before committing**
|
|
248
|
+
*WHY: Catches regressions before they reach main branch.*
|
|
249
|
+
```
|
|
250
|
+
**Why it's good**: Motivation makes compliance easier.
|
|
251
|
+
</good_example>
|
|
252
|
+
|
|
253
|
+
### Example: Negative vs Positive Instructions
|
|
254
|
+
|
|
255
|
+
<bad_example>
|
|
256
|
+
```markdown
|
|
257
|
+
- Don't use console.log for debugging
|
|
258
|
+
- Never commit directly to main
|
|
259
|
+
- Avoid hardcoding secrets
|
|
260
|
+
```
|
|
261
|
+
**Issue**: Negative instructions are less effective than positive alternatives.
|
|
262
|
+
</bad_example>
|
|
263
|
+
|
|
264
|
+
<good_example>
|
|
265
|
+
```markdown
|
|
266
|
+
- Use the logger utility for all debug output
|
|
267
|
+
- Create feature branches and submit PRs for all changes
|
|
268
|
+
- Store secrets in environment variables or .env files
|
|
269
|
+
```
|
|
270
|
+
**Why it's good**: Tells what TO do, not just what to avoid.
|
|
271
|
+
</good_example>
|
|
272
|
+
|
|
273
|
+
### Example: Weak vs Strong Constraint Language
|
|
274
|
+
|
|
275
|
+
<bad_example>
|
|
276
|
+
```markdown
|
|
277
|
+
- You should probably run tests before pushing
|
|
278
|
+
- Try to use TypeScript when possible
|
|
279
|
+
- Consider adding error handling
|
|
280
|
+
```
|
|
281
|
+
**Issue**: Weak language ("should", "try", "consider") reduces compliance.
|
|
282
|
+
</bad_example>
|
|
283
|
+
|
|
284
|
+
<good_example>
|
|
285
|
+
```markdown
|
|
286
|
+
- **MUST** run tests before pushing (CI will reject failures)
|
|
287
|
+
- **ALWAYS** use TypeScript for new files
|
|
288
|
+
- **REQUIRED**: All async functions must have error handling
|
|
289
|
+
```
|
|
290
|
+
**Why it's good**: Strong language ensures critical rules are followed.
|
|
291
|
+
</good_example>
|
|
292
|
+
|
|
293
|
+
### Example: Content Positioning
|
|
294
|
+
|
|
295
|
+
<bad_example>
|
|
296
|
+
```markdown
|
|
297
|
+
## Project Overview
|
|
298
|
+
[Long description...]
|
|
299
|
+
|
|
300
|
+
## Installation
|
|
301
|
+
[Setup steps...]
|
|
302
|
+
|
|
303
|
+
## Critical Rules
|
|
304
|
+
1. Never push to main directly
|
|
305
|
+
2. Always run tests
|
|
306
|
+
```
|
|
307
|
+
**Issue**: Critical rules buried in middle/end get less attention.
|
|
308
|
+
</bad_example>
|
|
309
|
+
|
|
310
|
+
<good_example>
|
|
311
|
+
```markdown
|
|
312
|
+
## Critical Rules (Read First)
|
|
313
|
+
1. **Never push to main directly** - Use PRs
|
|
314
|
+
2. **Always run tests** - CI enforces this
|
|
315
|
+
|
|
316
|
+
## Project Overview
|
|
317
|
+
[Description...]
|
|
318
|
+
|
|
319
|
+
## Reminders
|
|
320
|
+
- Check CI status before merging
|
|
321
|
+
- Update CHANGELOG for user-facing changes
|
|
322
|
+
```
|
|
323
|
+
**Why it's good**: Critical content at START and END positions.
|
|
324
|
+
</good_example>
|
|
325
|
+
|
|
326
|
+
### Example: Cross-Platform Compatibility
|
|
327
|
+
|
|
328
|
+
<bad_example>
|
|
329
|
+
```markdown
|
|
330
|
+
State files are stored in `.claude/tasks.json`
|
|
331
|
+
```
|
|
332
|
+
**Issue**: Hardcoded paths exclude other AI tools.
|
|
333
|
+
</bad_example>
|
|
334
|
+
|
|
335
|
+
<good_example>
|
|
336
|
+
```markdown
|
|
337
|
+
State files are stored in `${STATE_DIR}/tasks.json`
|
|
338
|
+
(`.claude/` for Claude Code, `.opencode/` for OpenCode)
|
|
339
|
+
```
|
|
340
|
+
**Why it's good**: Works across multiple AI assistants.
|
|
341
|
+
</good_example>
|
|
342
|
+
|
|
343
|
+
### Example: Agent Definition
|
|
344
|
+
|
|
345
|
+
<bad_example>
|
|
346
|
+
```markdown
|
|
347
|
+
## Agents
|
|
348
|
+
- security-reviewer: reviews security
|
|
349
|
+
- test-writer: writes tests
|
|
350
|
+
```
|
|
351
|
+
**Issue**: Missing required fields (Tools, when to use).
|
|
352
|
+
</bad_example>
|
|
353
|
+
|
|
354
|
+
<good_example>
|
|
355
|
+
```markdown
|
|
356
|
+
## Custom Agents
|
|
357
|
+
|
|
358
|
+
### security-reviewer
|
|
359
|
+
Model: claude-sonnet-4-20250514
|
|
360
|
+
Description: Reviews code for security vulnerabilities. Use for PRs touching auth, API, or data handling.
|
|
361
|
+
Tools: Read, Grep, Glob
|
|
362
|
+
Instructions: Focus on OWASP Top 10, input validation, auth flows.
|
|
363
|
+
|
|
364
|
+
### test-writer
|
|
365
|
+
Model: claude-haiku-4
|
|
366
|
+
Description: Writes unit tests. Use after implementing new functions.
|
|
367
|
+
Tools: Read, Write, Bash(npm test:*)
|
|
368
|
+
Instructions: Use Jest patterns. Aim for >80% coverage.
|
|
369
|
+
```
|
|
370
|
+
**Why it's good**: Complete definition with when to use, restricted tools.
|
|
371
|
+
</good_example>
|
|
372
|
+
</examples>
|
|
373
|
+
|
|
374
|
+
## Research References
|
|
375
|
+
|
|
376
|
+
Best practices derived from:
|
|
377
|
+
- `agent-docs/PROMPT-ENGINEERING-REFERENCE.md` - Instruction effectiveness, XML tags, constraint language
|
|
378
|
+
- `agent-docs/CONTEXT-OPTIMIZATION-REFERENCE.md` - Token budgeting, "lost in the middle" positioning
|
|
379
|
+
- `agent-docs/LLM-INSTRUCTION-FOLLOWING-RELIABILITY.md` - Instruction hierarchy, positive vs negative
|
|
380
|
+
- `agent-docs/CLAUDE-CODE-REFERENCE.md` - File hierarchy, agent definitions, skills format
|
|
381
|
+
|
|
382
|
+
## Constraints
|
|
383
|
+
|
|
384
|
+
- Always validate file references before reporting broken
|
|
385
|
+
- Consider context when flagging efficiency issues
|
|
386
|
+
- Cross-platform suggestions are advisory, not required
|
|
387
|
+
- Positioning suggestions are HIGH certainty but may have valid exceptions
|