From prompt-optimization-claude-45
Optimizes CLAUDE.md files and Skills for Claude Code CLI using Anthropic prompt best practices like positive framing, specificity, and examples. Use for reviewing or improving system prompts.
npx claudepluginhub jamie-bitflight/claude_skillsThis skill uses the workspace's default tool permissions.
Optimize CLAUDE.md files and Agent Skills for Claude Code CLI using Anthropic's official prompt engineering best practices.
Provides UI/UX resources: 50+ styles, color palettes, font pairings, guidelines, charts for web/mobile across React, Next.js, Vue, Svelte, Tailwind, React Native, Flutter. Aids planning, building, reviewing interfaces.
Fetches up-to-date documentation from Context7 for libraries and frameworks like React, Next.js, Prisma. Use for setup questions, API references, and code examples.
Builds 3-5 year financial models for startups with cohort revenue projections, cost structures, cash flow, headcount plans, burn rate, runway, and scenario analysis.
Optimize CLAUDE.md files and Agent Skills for Claude Code CLI using Anthropic's official prompt engineering best practices.
Models attend to key nouns/concepts. "NEVER use cat" still activates "use cat". Negation requires an extra logical step that can get lost during generation.
| Instead of | Write |
|---|---|
| "Never use X" | "Use Y instead [because reason]" |
| "Don't include X" | "Include only Y" |
| "Avoid X" | "Prefer Y" |
| "X is forbidden" | "Use Y for this operation" |
| "Don't explain" | "Output only the result" |
From Anthropic's memory best practices: "Use 2-space indentation" is better than "Format code properly".
| Vague | Specific |
|---|---|
| "Format code properly" | "Use 2-space indentation for all code" |
| "Write good commit messages" | "Use conventional commits: type(scope): description" |
| "Handle errors correctly" | "Catch exceptions only when you have a specific recovery action" |
| "Be concise" | "Lead with observations, state facts, omit preamble" |
Claude generalizes better when it understands WHY. Each instruction benefits from a brief reason.
## Python Environment
Use `uv run` for all Python execution.
**Reason**: Manages virtual environments and dependencies automatically.
Group related instructions under descriptive headings. Format each memory as a bullet point.
## File Operations
- Read files with `Read()` tool (handles encoding, large files)
- Search patterns with `Grep()` tool (returns structured matches)
- Find files with `Glob()` tool (respects gitignore)
## Communication Style
- Lead with findings and observations
- State facts directly without hedging
- Acknowledge dependencies when uncertain about duration
Key instructions placed early receive more attention. Put critical behaviors at the top of CLAUDE.md.
3-5 diverse, relevant examples dramatically improve accuracy and consistency. Wrap in <example> tags.
## Commit Message Format
<examples>
<example>
feat(auth): add OAuth2 support for GitHub login
</example>
<example>
fix(api): handle null response in user endpoint
</example>
<example>
docs(readme): update installation instructions
</example>
</examples>
Scan for prohibition markers:
For each prohibition, ask: "What SHOULD Claude do instead?"
| Prohibition | Desired Behavior |
|---|---|
| "Never use bare python commands" | "Run Python with uv run script.py" |
| "Don't use cat, head, tail" | "Use Read() tool for file content" |
| "Never state timelines" | "Acknowledge dependencies when uncertain" |
| "Avoid performative gratitude" | "Lead with observations and findings" |
Prohibition markers are used only with very explicit absolute examples.
For each instruction, provide a brief reason:
## Tool Selection
| Operation | Tool | Reason |
|-----------|------|--------|
| Read files | `Read()` | Handles encoding, large files, binary detection |
| Search patterns | `Grep()` | Returns structured matches with context |
| Write files | `Write()` | Atomic writes, preserves permissions |
| Run Python | `Bash(uv run ...)` | Manages venv and dependencies correctly |
Replace abstract descriptions with multishot examples:
## Error Handling Pattern
Catch exceptions only when you have a specific recovery action:
<example>
def get_user(id):
return db.query(User, id) # Errors surface naturally
def get_user_with_fallback(id):
try:
return db.query(User, id)
except ConnectionError:
logger.warning("DB unavailable, using cache")
return cache.get(f"user:{id}") # Specific recovery
</example>
Organize instructions into logical groups:
## Tool Usage
## Communication Style
## Code Standards
## Verification Process
## Project-Specific Context
Claude 4.5 models follow instructions precisely. Be explicit about actions:
| Indirect | Direct |
|---|---|
| "Can you suggest changes?" | "Make these changes" |
| "It might be good to..." | "Implement this feature" |
| "Consider adding..." | "Add X to Y" |
Claude 4.5 fires multiple tool calls simultaneously. Structure instructions to enable this:
## Research Tasks
When investigating an issue:
1. Search codebase for related patterns (Grep)
2. Read relevant configuration files (Read)
3. Check test files for expected behavior (Glob + Read)
Execute independent operations simultaneously for efficiency.
Claude 4.5 is more concise by default. Reinforce this:
## Response Style
- Lead with findings, not process descriptions
- State facts directly without hedging language
- Skip summaries after tool operations unless explicitly requested
- Provide code changes, not descriptions of changes
For complex reasoning tasks:
## Complex Analysis
For multi-step problems, think through the full approach before acting.
Consider multiple solutions and select the most robust.
Verify your solution with test cases before declaring complete.
The description is critical for Claude to discover when to use your Skill. Include both WHAT and WHEN:
---
name: code-reviewer
description: Review code for best practices, security issues, and potential bugs. Use when reviewing PRs, analyzing code quality, or checking implementations before merge.
---
Use allowed-tools for focused Skills:
---
name: safe-file-reader
description: Read and search files without modifications. Use for code review or analysis tasks requiring read-only access.
allowed-tools: Read, Grep, Glob
---
Keep SKILL.md focused. Reference supporting files for details:
# Code Review Skill
## Quick Checklist
1. Security vulnerabilities
2. Error handling
3. Performance concerns
4. Test coverage
For detailed patterns, see [patterns.md](patterns.md).
For security checklist, see [security.md](security.md).
Before:
## FORBIDDEN ACTIONS
β NEVER use bare python commands
β NEVER use cat, head, tail, sed, awk
β NEVER state timelines or estimates
β NEVER use performative gratitude
After:
## Tool Selection
| Operation | Tool | Reason |
|-----------|------|--------|
| Run Python | `Bash(uv run ...)` | Manages venv and dependencies |
| Read files | `Read()` | Handles encoding and large files |
| Search files | `Grep()` | Structured matches with context |
## Communication Style
- Lead with observations and findings
- State facts directly
- Acknowledge dependencies when uncertain about duration
Before:
Write good code and handle errors properly.
After:
## Error Handling
Catch exceptions only when you have a specific recovery action.
Let all other errors propagate to surface issues early.
<example>
# Good: specific recovery action
try:
return db.query(User, id)
except ConnectionError:
return cache.get(f"user:{id}")
# Good: let errors propagate
def process(data):
return transform(data) # Errors surface naturally
</example>
Before:
Always use conventional commits.
After:
## Commit Messages
Use conventional commits format: `type(scope): description`
**Reason**: Enables automated changelog generation and semantic versioning.
Types: `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore`
| Pattern | Problem | Solution |
|---|---|---|
| "NEVER X" | Activates X concept | "Use Y instead" |
| "Don't do X" | Unclear alternative | "Do Y" with example |
| "Avoid X" | Vague guidance | "Prefer Y because Z" |
| "X is forbidden" | No positive action | Table mapping operations to tools |
| Long prohibition list | Cognitive overload | Positive tool/action table |
| Vague quality terms | Inconsistent results | Concrete examples |
| Missing motivation | Brittle compliance | "Reason:" annotations |
| Buried key instructions | Ignored guidance | Front-load priorities |
After optimization, verify:
When encountering unique names, tool references, or technical jargon (e.g., "WebFetch", "Exa", "Ref", "Context7"):
Example:
WebFetch to retrieve specific web content." (Verified term)Web resource access, definitive guide for getting accurate data for high quality results
When CLAUDE.md or Skill files grow too large, apply these density optimizations. Use judiciouslyβover-compression can reduce compliance.
| Verbose Pattern | Compressed Form |
|---|---|
| "You might want to" | Direct imperative |
| "Consider doing X when Y" | "IF Y THEN X" |
| "It's important to remember" | "CONSTRAINT:" |
| "One approach is to" | Numbered step |
| "For example, when X happens" | "IF X THEN [action]" |
| "It would be great if you could" | Direct imperative |
| "Please make sure to" | Direct imperative |
Strip these elements when compressing:
Always keep:
Simple Protocol (<50 lines):
## [Protocol Name]
TRIGGER: [When this applies]
PROCEDURE:
1. [Action]
2. [Action]
3. [Action]
CONSTRAINTS:
- [Required behavior]
- [Required behavior]
OUTPUT: [Expected deliverable]
**/*.{ts,js} not "all TypeScript and JavaScript files"^ERROR:\s+ not "lines starting with ERROR followed by spaces"Read(), Grep(), Glob()For large multi-step workflows with conditions and parallel execution, Mermaid diagrams encode exact logic far more clearly than prose. Prose breaks down quickly when describing concurrent paths and join conditions.
Parallel execution example:
flowchart TD
A[Start PR Review] --> B{Files changed?}
B -->|Code| C[Run tests]
B -->|Code| D[Run linter]
B -->|Docs| E[Check links]
B -->|Config| F[Validate schema]
C --> G{All passed?}
D --> G
E --> G
F --> G
G -->|Yes| H[Approve]
G -->|No| I[Request changes]
Complex workflow with conditions:
flowchart TD
A[Deploy Request] --> B{Environment?}
B -->|prod| C[Require 2 approvals]
B -->|staging| D[Require 1 approval]
B -->|dev| E[Auto-approve]
C --> F{Approved?}
D --> F
E --> G[Run migrations]
F -->|Yes| G
F -->|No| H[Block deploy]
G --> I[Deploy containers]
I --> J[Health check]
J -->|Fail| K[Rollback]
J -->|Pass| L[Update DNS]
K --> M[Alert oncall]
Best for:
Why it works: Claude can trace graph edges precisely. Prose like "run tests and linting in parallel, then wait for both before proceeding" requires Claude to mentally reconstruct the DAG. The diagram makes the DAG explicit.
Before (67 words):
When you complete work that resolves any of the items in this audit,
you should really make sure to update the file so everyone knows
what's been done. First, find the item in the file. Then change its
status to resolved and add today's date. It's also helpful to add a
note about which file you changed.
After (28 words):
TRIGGER: Resolved drift item X.Y
PROCEDURE:
1. Edit item X.Y: status β `β
RESOLVED (YYYY-MM-DD)`
2. Add resolution evidence: file:line
3. Commit: `docs: resolve drift item X.Y`
| Document Type | Target |
|---|---|
| Single-purpose protocol | <50 lines |
| Agent task instructions | <100 lines |
| Complex workflow | <200 lines |
| Full CLAUDE.md | <500 lines |
Over-compression risks:
Balance: Compress structure and phrasing, preserve motivations and 2-3 key examples.