Prompt & Context Engineering
Analyze a draft prompt, identify gaps, map it to available agent components,
and output an optimized prompt the user can paste and run.
2026 note: The field has evolved from "prompt engineering" to "context engineering" — managing the full context window (system prompts, retrieved data, tool schemas, conversation history) rather than just optimizing the wording of a single prompt.
When to Use
- User asks to optimize, improve, or rewrite a prompt
- User asks "what's the best way to ask the agent to..."
- User pastes a draft prompt and asks for feedback
When to Skip
- User wants the task executed directly ("just do it")
- User asks to optimize code or performance (that's a refactoring task)
How It Works
Advisory only — output analysis and an optimized prompt. Do not execute the task.
Phase 1: Project Detection
Before analyzing the prompt, detect context from the working directory:
- Read
CLAUDE.md / AGENTS.md for project conventions
- Detect tech stack from config files:
package.json → Node / TypeScript / React / Next.js
go.mod → Go
pyproject.toml / requirements.txt → Python
Cargo.toml → Rust
build.gradle / pom.xml → Java / Kotlin
- Note the detected stack for component matching and missing-context analysis
If no project files found, flag "tech stack unknown" and proceed.
Phase 2: Intent Classification
Classify the user's task:
| Category |
Signal Words |
Example |
| New Feature |
build, create, add, implement |
"Build a login page" |
| Bug Fix |
fix, broken, not working, error |
"Fix the auth flow" |
| Refactor |
refactor, clean up, restructure |
"Refactor the API layer" |
| Research |
how to, what is, explore |
"How to add SSO" |
| Testing |
test, coverage, verify |
"Add tests for the cart" |
| Review |
review, audit, check |
"Review my PR" |
| Documentation |
document, update docs |
"Update the API docs" |
| Infrastructure |
deploy, CI, docker, database |
"Set up CI/CD pipeline" |
Phase 3: Scope Assessment
| Scope |
Heuristic |
Approach |
| Trivial |
Single file, < 50 lines |
Direct execution |
| Low |
Single component or module |
Single skill or tool |
| Medium |
Multiple components, same domain |
Chained steps + verification |
| High |
Cross-domain, 5+ files |
Plan first, then phased execution |
| Epic |
Multi-session, architectural shift |
Multi-session plan with checkpoints |
Phase 4: Component Mapping
Map intent + scope to available agent components:
| Intent |
Skills |
Agents |
| New Feature |
dev, dev-frontend/backend, dev-scaffolding |
planner, code-reviewer |
| Bug Fix |
dev-testing, dev-debugging |
tdd-guide |
| Refactor |
dev-code-reviewer |
code-reviewer |
| Research |
search, rag |
explore agent |
| Testing |
dev-testing |
test runner |
| Review |
dev-code-reviewer |
code-reviewer |
| Documentation |
documentation |
doc writer |
| Infrastructure |
dev-backend |
architect |
For project-specific skills, check .agents/skills/ to find applicable ones.
Phase 5: Missing Context Detection
Scan the prompt for missing information:
If 3+ items are missing, ask the user up to 3 clarification questions before
generating the optimized prompt.
Phase 6: Generate Optimized Prompt
Produce two versions:
Full version (inside a fenced code block):
- Clear task description with context
- Tech stack (detected or specified)
- Acceptance criteria
- Verification steps
- Scope boundaries (what to exclude)
- Relevant skills/agents to invoke
Quick version (one-liner patterns):
| Intent |
Pattern |
| New Feature |
Plan [feature]. Implement with tests. Review. Verify. |
| Bug Fix |
Write failing test for [bug]. Fix to green. Verify. |
| Refactor |
Refactor [scope]. Review. Verify no regressions. |
| Research |
Search for [topic]. Summarize findings with citations. |
| Testing |
Add tests for [module]. Target [coverage]% coverage. |
Prompt & Context Quality Principles
- Specificity over vagueness: name files, modules, endpoints
- Acceptance criteria: define "done" before starting
- Scope boundaries: state what to exclude to prevent drift
- Existing patterns: reference existing code the agent should follow
- Verification step: end with a concrete check (test, build, curl)
- Component awareness: invoke skills/agents by name when applicable
- Context assembly: include relevant code, docs, and data — not just the question
- Self-reflection: ask the model to verify its own reasoning (CoT) before final output
- Treat prompts like code: version control prompts, run evals, iterate based on metrics
- Tool-augmented prompting: when a prompt involves factual lookup, direct the model to use search/MCP tools rather than relying on training data
Output Format
### Prompt Diagnosis
**Strengths**: (what the original does well)
**Issues**: (table: issue | impact | fix)
**Needs Clarification**: (numbered questions)
### Recommended Components
(table: type | component | purpose)
### Optimized Prompt — Full
(fenced code block, ready to paste)
### Optimized Prompt — Quick
(one-liner)
### Enhancement Rationale
(table: what was added | why)
Constraints
- Advisory only — produce prompts, not implementations
- Respond in the same language as the user's input
- When referencing skills, verify they exist in
.agents/skills/ first
- Keep optimized prompts self-contained and copy-pasteable
1---2name: prompt-engineering3description: Analyze and optimize prompts for AI coding agents. Decompose tasks into components (skills/commands/agents), detect missing context, and produce ready-to-paste improved prompts. Advisory only — outputs prompts, not code. Triggers: "optimize prompt", "improve my prompt", "rewrite this prompt", "how to write a prompt for", "help me prompt"4---56# Prompt & Context Engineering78Analyze a draft prompt, identify gaps, map it to available agent components,9and output an optimized prompt the user can paste and run.1011> **2026 note**: The field has evolved from "prompt engineering" to **"context engineering"** — managing the full context window (system prompts, retrieved data, tool schemas, conversation history) rather than just optimizing the wording of a single prompt.1213## When to Use1415- User asks to optimize, improve, or rewrite a prompt16- User asks "what's the best way to ask the agent to..."17- User pastes a draft prompt and asks for feedback1819## When to Skip2021- User wants the task executed directly ("just do it")22- User asks to optimize code or performance (that's a refactoring task)2324## How It Works2526Advisory only — output analysis and an optimized prompt. Do not execute the task.2728### Phase 1: Project Detection2930Before analyzing the prompt, detect context from the working directory:31321. Read `CLAUDE.md` / `AGENTS.md` for project conventions332. Detect tech stack from config files:34 - `package.json` → Node / TypeScript / React / Next.js35 - `go.mod` → Go36 - `pyproject.toml` / `requirements.txt` → Python37 - `Cargo.toml` → Rust38 - `build.gradle` / `pom.xml` → Java / Kotlin393. Note the detected stack for component matching and missing-context analysis4041If no project files found, flag "tech stack unknown" and proceed.4243### Phase 2: Intent Classification4445Classify the user's task:4647| Category | Signal Words | Example |48|----------|-------------|---------|49| New Feature | build, create, add, implement | "Build a login page" |50| Bug Fix | fix, broken, not working, error | "Fix the auth flow" |51| Refactor | refactor, clean up, restructure | "Refactor the API layer" |52| Research | how to, what is, explore | "How to add SSO" |53| Testing | test, coverage, verify | "Add tests for the cart" |54| Review | review, audit, check | "Review my PR" |55| Documentation | document, update docs | "Update the API docs" |56| Infrastructure | deploy, CI, docker, database | "Set up CI/CD pipeline" |5758### Phase 3: Scope Assessment5960| Scope | Heuristic | Approach |61|-------|-----------|----------|62| Trivial | Single file, < 50 lines | Direct execution |63| Low | Single component or module | Single skill or tool |64| Medium | Multiple components, same domain | Chained steps + verification |65| High | Cross-domain, 5+ files | Plan first, then phased execution |66| Epic | Multi-session, architectural shift | Multi-session plan with checkpoints |6768### Phase 4: Component Mapping6970Map intent + scope to available agent components:7172| Intent | Skills | Agents |73|--------|--------|--------|74| New Feature | dev, dev-frontend/backend, dev-scaffolding | planner, code-reviewer |75| Bug Fix | dev-testing, dev-debugging | tdd-guide |76| Refactor | dev-code-reviewer | code-reviewer |77| Research | search, rag | explore agent |78| Testing | dev-testing | test runner |79| Review | dev-code-reviewer | code-reviewer |80| Documentation | documentation | doc writer |81| Infrastructure | dev-backend | architect |8283For project-specific skills, check `.agents/skills/` to find applicable ones.8485### Phase 5: Missing Context Detection8687Scan the prompt for missing information:8889- [ ] **Tech stack** — detected or needs user input?90- [ ] **Target scope** — files, directories, or modules specified?91- [ ] **Acceptance criteria** — how to know the task is done?92- [ ] **Error handling** — edge cases and failure modes addressed?93- [ ] **Security requirements** — auth, validation, secrets?94- [ ] **Testing expectations** — unit, integration, E2E?95- [ ] **Existing patterns** — reference files or conventions to follow?96- [ ] **Scope boundaries** — what to exclude?9798If 3+ items are missing, ask the user up to 3 clarification questions before99generating the optimized prompt.100101### Phase 6: Generate Optimized Prompt102103Produce two versions:104105**Full version** (inside a fenced code block):106- Clear task description with context107- Tech stack (detected or specified)108- Acceptance criteria109- Verification steps110- Scope boundaries (what to exclude)111- Relevant skills/agents to invoke112113**Quick version** (one-liner patterns):114115| Intent | Pattern |116|--------|---------|117| New Feature | `Plan [feature]. Implement with tests. Review. Verify.` |118| Bug Fix | `Write failing test for [bug]. Fix to green. Verify.` |119| Refactor | `Refactor [scope]. Review. Verify no regressions.` |120| Research | `Search for [topic]. Summarize findings with citations.` |121| Testing | `Add tests for [module]. Target [coverage]% coverage.` |122123## Prompt & Context Quality Principles1241251. **Specificity over vagueness**: name files, modules, endpoints1262. **Acceptance criteria**: define "done" before starting1273. **Scope boundaries**: state what to exclude to prevent drift1284. **Existing patterns**: reference existing code the agent should follow1295. **Verification step**: end with a concrete check (test, build, curl)1306. **Component awareness**: invoke skills/agents by name when applicable1317. **Context assembly**: include relevant code, docs, and data — not just the question1328. **Self-reflection**: ask the model to verify its own reasoning (CoT) before final output1339. **Treat prompts like code**: version control prompts, run evals, iterate based on metrics13410. **Tool-augmented prompting**: when a prompt involves factual lookup, direct the model to use search/MCP tools rather than relying on training data135136## Output Format137138```139### Prompt Diagnosis140**Strengths**: (what the original does well)141**Issues**: (table: issue | impact | fix)142**Needs Clarification**: (numbered questions)143144### Recommended Components145(table: type | component | purpose)146147### Optimized Prompt — Full148(fenced code block, ready to paste)149150### Optimized Prompt — Quick151(one-liner)152153### Enhancement Rationale154(table: what was added | why)155```156157## Constraints158159- Advisory only — produce prompts, not implementations160- Respond in the same language as the user's input161- When referencing skills, verify they exist in `.agents/skills/` first162- Keep optimized prompts self-contained and copy-pasteable