Best for
- Use when reviewing, creating, or improving system prompts, CLAUDE.
Jamie-BitFlight/claude_skills/plugins/plugin-creator/skills/prompt-optimization/SKILL.md
Optimize CLAUDE.md files and Skills for Claude Code CLI. Use when reviewing, creating, or improving system prompts, CLAUDE.md configurations, or Skill files. Transforms negative instructions into positive patterns following Anthropic's official best practices.
Decision brief
Optimize CLAUDE.md files and Agent Skills for Claude Code CLI using Anthropic's official prompt engineering best practices.
Compatibility matrix
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Declared | Source record | Install path and trigger |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/Jamie-BitFlight/claude_skills --skill "plugins/plugin-creator/skills/prompt-optimization"Inspect the Agent Skill "prompt-optimization" from https://github.com/Jamie-BitFlight/claude_skills/blob/a00194f25fec502d3d659b7d610369614967251e/plugins/plugin-creator/skills/prompt-optimization/SKILL.md at commit a00194f25fec502d3d659b7d610369614967251e. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
Scan for prohibition markers:
Scan for prohibition markers:
For each prohibition, ask: "What SHOULD Claude do instead?"
For each instruction, provide a brief reason:
Replace abstract descriptions with multishot examples:
Permission review
The documentation asks the agent to run terminal commands or scripts.
| "Never use bare python commands" | "Run Python with `uv run script.py`" |The documentation asks the agent to read local files, directories, or repositories.
| "Don't use cat, head, tail" | "Use `Read()` tool for file content" |The documentation asks the agent to create, modify, or delete local files.
you should really make sure to update the file so everyone knowsEvidence record
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 94/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 64 | Source | Repository attention, not individual Skill quality |
| Compatibility | 1 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
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)
references/accessing_online_resources.md
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.
references/example-claude-md-boris-cherny.md— well-structured configuration demonstrating numbered workflow principles, actionable bullet points, balanced guidance with scope limiters, and self-referential learning loops.
Frequently asked questions
Optimize CLAUDE.md files and Agent Skills for Claude Code CLI using Anthropic's official prompt engineering best practices.
The source record exposes this install command: npx skills add https://github.com/Jamie-BitFlight/claude_skills --skill "plugins/plugin-creator/skills/prompt-optimization". Inspect the command and pinned source before running it.
The pinned source record declares support for: claude code.
Static rules flagged exec-script, read-files, write-files in the source; the page lists the matching lines and excerpts.
Alternatives
Jamie-BitFlight/claude_skills
Hook recipes and working examples — plugin hooks, frontmatter hooks in skills/agents/commands, prompt-based LLM hooks, and complete code examples in Python and Node.js. Use when building hook scripts, integrating hooks into plugins, implementing prompt-based hooks, or looking for hook configuration patterns.
PramodDutta/qaskills
Generate optimized test combinations using pairwise (all-pairs) testing algorithms to achieve maximum coverage with minimum test cases across multiple input parameters
PramodDutta/qaskills
Automatically generate comprehensive test cases from user stories and acceptance criteria using BDD patterns, equivalence partitioning, and risk-based prioritization
athola/claude-night-market
Guide creating Claude Code hooks with security-first design. Use for validation and enforcement.