Use when improving CLAUDE.md or AGENTS.md project memory files.
Analyzes and optimizes project memory files for improved AI assistant performance and instruction following.
npx claudepluginhub agent-sh/enhanceThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Analyze project memory files (CLAUDE.md, AGENTS.md) for optimization.
Searches for project memory files in order:
CLAUDE.md (Claude Code):
| Location | Scope |
|---|---|
~/.claude/CLAUDE.md | Global (all projects) |
.claude/CLAUDE.md or ./CLAUDE.md | Project root |
src/.claude/CLAUDE.md | Directory-specific |
AGENTS.md (OpenCode, Codex, and other AI tools):
| Location | Scope |
|---|---|
~/.config/opencode/AGENTS.md or ~/.codex/AGENTS.md | Global (all projects) |
.opencode/AGENTS.md or ./AGENTS.md | Project root |
src/AGENTS.md | Directory-specific |
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.
## Critical Rules or similarBased on prompt engineering research, Claude follows instructions better when:
Research shows LLMs have "lost in the middle" problem - they recall START and END better than MIDDLE.
1. Critical Rules (START - highest attention)
2. Architecture/Structure
3. Commands/Workflows
4. Examples/References
5. Reminders/Constraints (END - high attention)
[text](path) and `path/to/file.ext`npm run <script> and npm <command>characters / 4 or words * 1.3*WHY: explanation* or indented explanation<critical-rules>, <architecture>, <constraints> improve parsingIf file defines custom agents or skills:
### agent-name
Model: claude-sonnet-4-20250514
Description: What this agent does and when to use it
Tools: Read, Grep, Glob
Instructions: Specific behavioral instructions
Required fields: Description (when to use), Tools (restricted set) Optional: Model, Instructions
.claude/.opencode/, .codex/${STATE_DIR}/ or document variations# Project Memory Analysis: {filename}
**File**: {path}
**Type**: {CLAUDE.md | AGENTS.md}
## Metrics
| Metric | Value |
|--------|-------|
| Estimated Tokens | {tokens} |
| README Overlap | {percent}% |
## Summary
| Certainty | Count |
|-----------|-------|
| HIGH | {n} |
| MEDIUM | {n} |
### Structure Issues ({n})
| Issue | Fix | Certainty |
### Instruction Issues ({n})
| Issue | Fix | Certainty |
### Positioning Issues ({n})
| Issue | Fix | Certainty |
### Reference Issues ({n})
| Issue | Fix | Certainty |
### Efficiency Issues ({n})
| Issue | Fix | Certainty |
### Cross-Platform Issues ({n})
| Issue | Fix | Certainty |
| Category | Patterns | Certainty |
|---|---|---|
| Structure | 3 | HIGH |
| Instruction Effectiveness | 3 | HIGH |
| Content Positioning | 2 | HIGH |
| Reference | 2 | HIGH |
| Efficiency | 3 | MEDIUM |
| Quality | 3 | MEDIUM |
| Agent/Skill Definitions | 2 | MEDIUM |
| Cross-Platform | 2 | MEDIUM/HIGH |
| Total | 20 | - |
<bad_example>
## Rules
1. Always run tests before committing
2. Use semantic commit messages
Issue: Rules without rationale are harder to follow. </bad_example>
<good_example>
## Critical Rules
1. **Always run tests before committing**
*WHY: Catches regressions before they reach main branch.*
Why it's good: Motivation makes compliance easier. </good_example>
<bad_example>
- Don't use console.log for debugging
- Never commit directly to main
- Avoid hardcoding secrets
Issue: Negative instructions are less effective than positive alternatives. </bad_example>
<good_example>
- Use the logger utility for all debug output
- Create feature branches and submit PRs for all changes
- Store secrets in environment variables or .env files
Why it's good: Tells what TO do, not just what to avoid. </good_example>
<bad_example>
- You should probably run tests before pushing
- Try to use TypeScript when possible
- Consider adding error handling
Issue: Weak language ("should", "try", "consider") reduces compliance. </bad_example>
<good_example>
- **MUST** run tests before pushing (CI will reject failures)
- **ALWAYS** use TypeScript for new files
- **REQUIRED**: All async functions must have error handling
Why it's good: Strong language ensures critical rules are followed. </good_example>
<bad_example>
## Project Overview
[Long description...]
## Installation
[Setup steps...]
## Critical Rules
1. Never push to main directly
2. Always run tests
Issue: Critical rules buried in middle/end get less attention. </bad_example>
<good_example>
## Critical Rules (Read First)
1. **Never push to main directly** - Use PRs
2. **Always run tests** - CI enforces this
## Project Overview
[Description...]
## Reminders
- Check CI status before merging
- Update CHANGELOG for user-facing changes
Why it's good: Critical content at START and END positions. </good_example>
<bad_example>
State files are stored in `.claude/tasks.json`
Issue: Hardcoded paths exclude other AI tools. </bad_example>
<good_example>
State files are stored in `${STATE_DIR}/tasks.json`
(`.claude/` for Claude Code, `.opencode/` for OpenCode)
Why it's good: Works across multiple AI assistants. </good_example>
<bad_example>
## Agents
- security-reviewer: reviews security
- test-writer: writes tests
Issue: Missing required fields (Tools, when to use). </bad_example>
<good_example>
## Custom Agents
### security-reviewer
Model: claude-sonnet-4-20250514
Description: Reviews code for security vulnerabilities. Use for PRs touching auth, API, or data handling.
Tools: Read, Grep, Glob
Instructions: Focus on OWASP Top 10, input validation, auth flows.
### test-writer
Model: claude-haiku-4
Description: Writes unit tests. Use after implementing new functions.
Tools: Read, Write, Bash(npm test:*)
Instructions: Use Jest patterns. Aim for >80% coverage.
Why it's good: Complete definition with when to use, restricted tools. </good_example> </examples>
Best practices derived from:
agent-docs/PROMPT-ENGINEERING-REFERENCE.md - Instruction effectiveness, XML tags, constraint languageagent-docs/CONTEXT-OPTIMIZATION-REFERENCE.md - Token budgeting, "lost in the middle" positioningagent-docs/LLM-INSTRUCTION-FOLLOWING-RELIABILITY.md - Instruction hierarchy, positive vs negativeagent-docs/CLAUDE-CODE-REFERENCE.md - File hierarchy, agent definitions, skills formatYou MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.