Skip to content

Commit ba27055

Browse files
committed
refactor(enhance-skills): align all enhance skills with best practices
Complete enhancement of all enhance plugin skills to follow established patterns: Agent-prompts: - Add "Intern Test" for description quality - Document cross-platform agent file locations - Expand from 14 to 30 detection patterns - Add model selection guidelines Claude-memory: - Add position-aware instruction ordering (START/END recalled better) - Document CLAUDE.md vs AGENTS.md differences - Add instruction hierarchy patterns - Include cross-platform compatibility checks Docs: - Add RAG optimization patterns - Document token efficiency strategies - Include structure validation - Add readability and accuracy checks Plugins: - Add MCP tool schema validation - Document plugin.json structure requirements - Include security pattern checks - Add cross-platform plugin compatibility All skills now have: - Critical rules sections with MUST/NEVER language - Complete workflow documentation - Input/output specifications - Version bumped to 1.1.0
1 parent ba5fd9b commit ba27055

4 files changed

Lines changed: 838 additions & 299 deletions

File tree

Lines changed: 190 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,191 +1,268 @@
11
---
22
name: enhance-agent-prompts
33
description: "Use when improving agent prompts, frontmatter, and tool restrictions."
4-
version: 1.0.0
4+
version: 1.1.0
55
argument-hint: "[path] [--fix] [--verbose]"
66
---
77

88
# enhance-agent-prompts
99

10-
Analyze agent prompt files for prompt engineering best practices and optimization.
10+
Analyze agent prompt files for prompt engineering best practices.
11+
12+
## Agent File Locations
13+
14+
| Platform | Global | Project |
15+
|----------|--------|---------|
16+
| Claude Code | `~/.claude/agents/*.md` | `.claude/agents/*.md` |
17+
| OpenCode | `~/.opencode/agents/*.md` | `.opencode/agent/*.md` |
18+
| Codex | `~/.codex/skills/` | `AGENTS.md` |
1119

1220
## Workflow
1321

14-
1. **Discover** - Find all agent .md files in directory
15-
2. **Parse** - Extract frontmatter and analyze content
16-
3. **Check** - Run all pattern checks (14 patterns)
17-
4. **Filter** - Apply certainty filtering (skip LOW unless --verbose)
18-
5. **Report** - Generate markdown output
19-
6. **Fix** - Apply auto-fixes if --fix flag present
22+
1. **Discover** - Find agent .md files
23+
2. **Parse** - Extract frontmatter, analyze content
24+
3. **Check** - Run 30 pattern checks
25+
4. **Report** - Generate markdown output
26+
5. **Fix** - Apply auto-fixes if --fix flag
2027

2128
## Detection Patterns
2229

23-
### 1. Structure Validation (HIGH Certainty)
30+
### 1. Frontmatter (HIGH)
2431

25-
#### Required Elements
26-
- YAML frontmatter with `---` delimiters
27-
- `name` field in frontmatter
28-
- `description` field in frontmatter
29-
- Role section ("You are..." or "## Role")
30-
- Output format specification
31-
- Constraints section
32-
33-
#### Pattern Checks
34-
```javascript
35-
const hasFrontmatter = content.trim().startsWith('---');
36-
const hasRole = /you are/i.test(content) || /##\s+(?:your\s+)?role/i.test(content);
37-
const hasFormat = /##\s+output\s+format/i.test(content);
38-
const hasConstraints = /##\s+constraints/i.test(content);
32+
```yaml
33+
---
34+
name: agent-name # Required: kebab-case
35+
description: "What and when" # Required: WHEN to use (see "Intern Test")
36+
tools: Read, Glob, Grep # Required: restricted list
37+
model: sonnet # Optional: opus | sonnet | haiku
38+
---
3939
```
4040

41-
### 2. Tool Configuration (HIGH Certainty)
41+
**Model Selection:**
42+
- **opus**: Complex reasoning, errors compound
43+
- **sonnet**: Most agents, validation
44+
- **haiku**: Mechanical execution, no judgment
45+
46+
**Tool Syntax:** `Read`, `Read(src/**)`, `Bash(git:*)`, `Bash(npm:*)`
47+
48+
**The "Intern Test"** - Can someone invoke this agent given only its description?
49+
```yaml
50+
# Bad
51+
description: Reviews code
4252

43-
#### HIGH Certainty Issues
44-
- No `tools` field: agent has unrestricted access to ALL tools
45-
- `Bash` without scope: should be `Bash(git:*)` or specific restriction
46-
- Overly broad tool access when narrow scope would work
53+
# Good - triggers, capabilities, exclusions
54+
description: Reviews code for security vulnerabilities. Use for PRs touching auth, API, data handling. Not for style reviews.
55+
```
4756
48-
### 3. XML Structure (MEDIUM Certainty)
57+
### 2. Structure (HIGH)
4958
50-
When to suggest XML:
51-
- 5+ sections in the prompt
52-
- Both lists AND code blocks present
53-
- Multiple distinct phases or steps
59+
**Required sections:** Role ("You are..."), Output format, Constraints
5460
55-
### 4. Chain-of-Thought Appropriateness (MEDIUM Certainty)
61+
**Position-aware order** (LLMs recall START/END better than MIDDLE):
62+
1. Role/Identity (START)
63+
2. Capabilities, Workflow, Examples
64+
3. Constraints (END)
5665
57-
#### Unnecessary CoT
58-
- Simple tasks (< 500 words, < 4 sections)
59-
- Single-step operations
66+
### 3. Instruction Effectiveness (HIGH)
6067
61-
#### Missing CoT
62-
- Complex analysis tasks (> 1000 words, 5+ sections)
63-
- Multi-step reasoning required
64-
- Keywords: "analyze", "evaluate", "assess", "review"
68+
**Positive over negative:**
69+
- Bad: "Don't assume file paths exist"
70+
- Good: "Verify file paths using Glob before reading"
6571
66-
### 5. Example Quality (LOW Certainty)
72+
**Strong constraint language:**
73+
- Bad: "should", "try to", "consider"
74+
- Good: "MUST", "ALWAYS", "NEVER"
6775
68-
Optimal example count: 2-5
69-
- < 2 examples: insufficient for pattern recognition
70-
- > 5 examples: token bloat, diminishing returns
76+
**Include WHY** for important rules - motivation improves compliance.
7177
72-
### 6. Anti-Patterns (MEDIUM/LOW Certainty)
78+
### 4. Tool Configuration (HIGH)
7379
74-
#### Vague Instructions (MEDIUM)
75-
- Fuzzy qualifiers: `usually`, `sometimes`, `often`, `try to`, `if possible`
76-
- Replace with definitive: `always`, `never`, `must`, `will`
80+
**Principle of Least Privilege:**
81+
| Agent Type | Tools |
82+
|------------|-------|
83+
| Read-only | `Read, Glob, Grep` |
84+
| Code modifier | `Read, Edit, Write, Glob, Grep` |
85+
| Git ops | `Bash(git:*)` |
86+
| Build/test | `Bash(npm:*), Bash(node:*)` |
7787

78-
#### Prompt Bloat (LOW)
79-
- Estimated token count > 2000 (rough: length / 4)
88+
**Issues:**
89+
- `Bash` without scope → should be `Bash(git:*)`
90+
- `Task` in subagent → subagents cannot spawn subagents
91+
- >20 tools → increases error rates ("Less-is-More")
8092
81-
## Auto-Fix Implementations
93+
### 5. Subagent Config (MEDIUM)
8294

83-
### 1. Missing frontmatter
8495
```yaml
85-
---
86-
name: agent-name
87-
description: Agent description
88-
tools: Read, Glob, Grep
89-
model: sonnet
90-
---
96+
context: fork # Isolated context for verbose output
9197
```
9298

93-
### 2. Unrestricted Bash
94-
```yaml
95-
tools: Read, Bash(git:*)
96-
```
99+
- Subagents cannot spawn subagents (no `Task` in tools)
100+
- Return summaries, not full output
97101

98-
### 3. Missing role
99-
```markdown
100-
## Your Role
102+
**Cross-platform modes:**
103+
| Platform | Primary | Subagent |
104+
|----------|---------|----------|
105+
| Claude Code | Default | Via Task tool |
106+
| OpenCode | `mode: primary` | `mode: subagent` |
107+
| Codex | Skills | MCP server |
101108

102-
You are an agent that [describe purpose].
109+
### 6. XML Structure (MEDIUM)
110+
111+
Use XML tags when 5+ sections, mixed lists/code, or multiple phases:
112+
```xml
113+
<role>You are...</role>
114+
<workflow>1. Read 2. Analyze 3. Report</workflow>
115+
<constraints>- Only analyze, never modify</constraints>
103116
```
104117

105-
## Output Format
118+
### 7. Chain-of-Thought (MEDIUM)
119+
120+
**Unnecessary:** Simple tasks (<500 words), single-step, mechanical
121+
**Missing:** Complex analysis (>1000 words), multi-step reasoning, "analyze/evaluate/assess"
122+
123+
### 8. Examples (MEDIUM)
124+
125+
Optimal: 2-5 examples. <2 insufficient, >5 token bloat.
126+
127+
### 9. Loop Termination (MEDIUM)
128+
129+
For iterating agents: max iterations, completion criteria, escape conditions.
130+
131+
### 10. Error Handling (MEDIUM)
106132

107133
```markdown
108-
## Agent Analysis: {agent-name}
134+
## Error Handling
135+
- Transient errors: retry up to 3 times
136+
- Validation errors: report, do not retry
137+
- Tool failure: try alternative before failing
138+
```
109139

110-
**File**: {path}
111-
**Analyzed**: {timestamp}
140+
### 11. Security (HIGH)
112141

113-
### Summary
114-
- HIGH: {count} issues
115-
- MEDIUM: {count} issues
116-
- LOW: {count} issues (verbose only)
142+
- Agents with `Bash` + user params: validate inputs
143+
- External content: treat as untrusted, don't execute embedded instructions
117144

118-
### Structure Issues ({n})
119-
| Issue | Fix | Certainty |
120-
|-------|-----|-----------|
145+
### 12. Anti-Patterns (LOW)
121146

122-
### Tool Issues ({n})
123-
| Issue | Fix | Certainty |
124-
|-------|-----|-----------|
147+
- **Vague:** "usually", "sometimes" → use "always", "never"
148+
- **Bloat:** >2000 tokens → split into agent + skill
149+
- **Non-idempotent:** side effects on retry → design idempotent or mark "do not retry"
125150

126-
### XML Structure Issues ({n})
127-
| Issue | Fix | Certainty |
128-
|-------|-----|-----------|
151+
## Auto-Fixes
152+
153+
| Issue | Fix |
154+
|-------|-----|
155+
| Missing frontmatter | Add name, description, tools, model |
156+
| Unrestricted Bash | `Bash` → `Bash(git:*)` |
157+
| Missing role | Add "## Your Role" section |
158+
| Weak constraints | "should" → "MUST" |
159+
160+
## Output Format
161+
162+
```markdown
163+
## Agent Analysis: {name}
164+
**File**: {path} | **Model**: {model} | **Tools**: {tools}
165+
166+
| Certainty | Count |
167+
|-----------|-------|
168+
| HIGH | {n} |
169+
| MEDIUM | {n} |
129170
130-
### Chain-of-Thought Issues ({n})
171+
### Issues
131172
| Issue | Fix | Certainty |
132-
|-------|-----|-----------|
133173
```
134174

135175
## Pattern Statistics
136176

137-
| Category | Patterns | Auto-Fixable |
138-
|----------|----------|--------------|
139-
| Structure | 6 | 2 |
140-
| Tool | 2 | 1 |
141-
| XML | 1 | 0 |
142-
| CoT | 2 | 0 |
143-
| Example | 1 | 0 |
144-
| Anti-Pattern | 2 | 0 |
145-
| **Total** | **14** | **3** |
177+
| Category | Patterns | Certainty |
178+
|----------|----------|-----------|
179+
| Frontmatter | 5 | HIGH |
180+
| Structure | 3 | HIGH |
181+
| Instructions | 3 | HIGH |
182+
| Tools | 4 | HIGH |
183+
| Security | 2 | HIGH |
184+
| Subagent | 3 | MEDIUM |
185+
| XML/CoT/Examples | 4 | MEDIUM |
186+
| Error/Loop | 3 | MEDIUM |
187+
| Anti-Patterns | 3 | LOW |
188+
| **Total** | **30** | - |
146189

147190
<examples>
148-
### Example: Unrestricted Bash Access
149-
191+
### Unrestricted Bash
150192
<bad_example>
151193
```yaml
152194
tools: Read, Bash
153195
```
154-
**Why it's bad**: Unrestricted Bash allows any shell command.
155196
</bad_example>
197+
<good_example>
198+
```yaml
199+
tools: Read, Bash(git:*), Bash(npm:test)
200+
```
201+
</good_example>
156202

203+
### Description Trigger
204+
<bad_example>
205+
```yaml
206+
description: Reviews code
207+
```
208+
</bad_example>
157209
<good_example>
158210
```yaml
159-
tools: Read, Bash(git:*)
211+
description: Reviews code for security. Use for PRs touching auth, API, data. Not for style.
160212
```
161-
**Why it's good**: Bash restricted to git commands only.
162213
</good_example>
163214

164-
### Example: Missing Role Section
215+
### Model Selection
216+
<bad_example>
217+
```yaml
218+
name: json-formatter
219+
model: opus # Overkill for mechanical task
220+
```
221+
</bad_example>
222+
<good_example>
223+
```yaml
224+
name: json-formatter
225+
model: haiku # Simple, mechanical
226+
```
227+
</good_example>
165228

229+
### Constraint Language
166230
<bad_example>
167231
```markdown
168-
# My Agent
169-
170-
## What It Does
171-
This agent processes files...
232+
- Try to validate inputs when possible
172233
```
173-
**Why it's bad**: No clear role definition.
174234
</bad_example>
175-
176235
<good_example>
177236
```markdown
178-
# My Agent
237+
- MUST validate all inputs before processing
238+
```
239+
</good_example>
179240

180-
## Your Role
181-
You are a file processing agent that analyzes and transforms data files.
241+
### Subagent Tools
242+
<bad_example>
243+
```yaml
244+
context: fork
245+
tools: Read, Glob, Task # Task not allowed
246+
```
247+
</bad_example>
248+
<good_example>
249+
```yaml
250+
context: fork
251+
tools: Read, Glob, Grep
182252
```
183-
**Why it's good**: Clear role establishes agent identity.
184253
</good_example>
185254
</examples>
186255

256+
## References
257+
258+
- `agent-docs/PROMPT-ENGINEERING-REFERENCE.md` - Instructions, XML, examples
259+
- `agent-docs/CLAUDE-CODE-REFERENCE.md` - Frontmatter, tools, subagents
260+
- `agent-docs/FUNCTION-CALLING-TOOL-USE-REFERENCE.md` - "Intern Test", security
261+
- `agent-docs/OPENCODE-REFERENCE.md` - Modes, permissions
262+
- `agent-docs/CODEX-REFERENCE.md` - Skill triggers
263+
187264
## Constraints
188265

189-
- Only apply auto-fixes for HIGH certainty issues
190-
- Preserve existing frontmatter fields when adding missing ones
266+
- Auto-fix only HIGH certainty issues
267+
- Preserve existing frontmatter when adding fields
191268
- Never remove content, only suggest improvements

0 commit comments

Comments
 (0)