skills/prompt-enhancer/SKILL.md
Enrich user prompts with relevant codebase context from the MCP codebase index server. Automatically detects task type and intensity level, then injects ranked code snippets, repo maps, recent changes, and dependency graphs. Works best with MCP server; degrades gracefully to built-in file tools when unavailable.
npx skillsauth add ngocsangyem/context-engineer-local prompt-enhancerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Enrich prompts with codebase context before execution. Uses MCP codebase index server when available; falls back to built-in file tools (Read, Grep, Glob) when not.
Step 0 — Check Indexing MCP availability (do this FIRST):
Before running anything, check if MCP codebase-index tools are available to you (e.g., search_codebase, get_file_summary). If NO MCP tools are available, skip this skill entirely — proceed with the user's task using built-in file tools (Read, Grep, Glob) directly.
Step 1 — Run the enhancement script:
Find enhance-prompt.py in this skill's scripts/ directory and run it:
python3 "SKILL_DIR/scripts/enhance-prompt.py" "USER_PROMPT_HERE"
Where SKILL_DIR is the absolute path to the directory containing this SKILL.md.
The script outputs an XML-structured enhanced prompt with tags like <tool_rules>, <objective>, <work_style>, <verification>, <done_criteria>, etc.
CRITICAL: The script output IS your working instructions. Follow these rules:
<tool_rules> tells you what tools to use, <objective> tells you what to do, <done_criteria> tells you when you're doneOptional flags: --task TYPE, --intensity LEVEL, --budget N, --provider gemini|ollama|openai
External AI is automatic: If
PROMPT_ENHANCER_PROVIDERis set in.env(e.g.,gemini,ollama,openai), the script automatically sends the prompt to that provider for improvement — no--providerflag needed. When the MCP codebase-index HTTP server is also running, it enriches the external AI call with real codebase context. No configuration needed beyond the.envfile.
Step 2 — Execute with codebase context:
<tool_rules> block to query MCP tools for relevant context<objective><done_criteria> and <verification> blocks| Keywords | Task Type | Primary MCP Tools | |----------|-----------|-------------------| | fix, bug, error, crash, fail | debug | search_codebase, get_recent_changes, get_file_summary, get_call_graph | | implement, add, create, build | coding | search_codebase, get_dependencies, search_symbols | | refactor, restructure, clean | refactor | get_dependencies, get_repo_map, search_codebase, get_call_graph | | review, audit, check | review | get_repo_map, get_file_summary | | explain, understand, how | research | get_repo_map, search_codebase |
Framework-aware queries: When the task targets a specific file, the file extension drives query strategy for the file-tool track. Vue/React/Svelte use <ComponentName> + import patterns; Python/Go/TS use symbol + import patterns. See references/task-type-strategies.md → "Framework-Aware Query Hints".
| Level | Triggers | Blocks Included | |-------|----------|-----------------| | light | "quick", "simple", "trivial", "rename", "typo" | tool_rules, work_style, concise_responses, objective, done_criteria | | standard | Default for most tasks | All light blocks + investigate, diagnosis, grounding, verification, parallel_tools, default_to_action, anti_overengineering (coding/refactor) | | deep | "careful", "thorough", "critical", "production", "security" | All standard blocks with stronger verification |
Enhanced prompts follow Anthropic's recommendation — longform context at top, query at bottom:
<tool_rules> — which MCP tools to call and how<use_parallel_tool_calls> — parallel execution (standard+, 2+ tools)<default_to_action> — bias to action (standard+)<investigate_before_answering> — prevent hallucination (standard+)<diagnosis> — analyze before acting: map responsibilities, find patterns (standard+)<anti_overengineering> — YAGNI/KISS (coding/refactor, standard+)<work_style> — task-type specific approach<grounding> — quote code before reasoning (standard+)<verification> — imperative self-check at meaningful checkpoints (standard+)<concise_responses> — skip preambles (all intensities)<objective> — narrative restatement with deliverable and success signal (BOTTOM)<done_criteria> — when to stopCRITICAL: The <objective> is ONE block within the full XML-structured prompt. ALL other blocks (context_budget, tool_rules, investigate, grounding, verification, work_style, done_criteria, etc.) MUST still be present. Never replace the full XML structure with just a narrative.
The <objective> block must restate the user's task as a structured narrative — not echo the raw prompt. Structure:
Keep under 4 sections for simple tasks. Use all 5 for complex/deep-intensity tasks.
Example (refactor task):
<objective>
Refactor customer-frontend/src/components/common/filters/AspireFilter.vue (~688 lines) to comply with the project's 200-line file size guideline.
Context:
- Component used in ~49 consumer files across transactions, cards, bills, accounting features
- Dual architecture: legacy state + unified state behind isUnifiedStateEnabled feature flag
- 20+ props, 4 emits, 2 slots define the public API
Constraints:
- Preserve exact public API (props, emits, slots) — zero changes to consumers
- Preserve legacy/unified dual-path unless feature flag status confirmed
- Follow YAGNI/KISS/DRY — extract, don't abstract
Deliverables:
1. Prioritized list of extractions with specific line-range references
2. Proposed file names and locations for each extraction
3. Risk assessment for each extraction
Verify all observations against the actual codebase before acting — use ~approximate numbers until confirmed.
Original request: Analyze and improve AspireFilter.vue
</objective>
When assembling enhanced prompts with codebase-specific context:
references/task-type-strategies.md)--budget 8192If MCP server cannot be reached:
If MCP tools return but results are poor, apply quality gates before injecting context:
| Tool | Quality Gate | Fallback Action |
|------|-------------|-----------------|
| search_codebase | All results score <0.3, OR top result <0.5 | Re-query with literal Grep pattern instead |
| get_file_summary | Returns only file path, no symbols/outline | Use Read + manual outline extraction |
| get_dependencies | Both imports and imported-by are empty | Use Grep for import statements + component usage |
| get_repo_map | Empty or single-entry result | Use Glob for directory listing + file structure |
Score behavior:
python3 scripts/enhance-prompt.py "Fix the auth timeout bug"
python3 scripts/enhance-prompt.py "Fix the auth timeout bug" --intensity deep
python3 scripts/enhance-prompt.py "Rename variable" --intensity light --budget 2048
python3 scripts/enhance-prompt.py "Refactor auth module" --task refactor
python3 scripts/enhance-prompt.py "Fix auth bug" --provider gemini
python3 scripts/enhance-prompt.py "Refactor auth" --provider ollama --intensity deep
Offload prompt improvement to an external AI instead of consuming Claude's context window. The deterministic prompt is built first, then optionally refined by an external model.
| Variable | Default | Description |
|----------|---------|-------------|
| PROMPT_ENHANCER_PROVIDER | none | Provider: gemini, ollama, openai, or none |
| GEMINI_API_KEY | — | Google API key (shared across skills) |
| GEMINI_MODEL | gemini-2.5-flash | Gemini model name |
| OLLAMA_BASE_URL | http://localhost:11434 | Ollama server URL |
| OLLAMA_MODEL | llama3.2 | Ollama model name |
| OPENAI_API_KEY | — | OpenAI or compatible API key |
| OPENAI_BASE_URL | https://api.openai.com/v1 | OpenAI-compatible base URL |
| OPENAI_MODEL | gpt-4o-mini | Model name |
| MCP_CODEBASE_URL | http://127.0.0.1:3847 | MCP codebase-index HTTP server URL (optional — enriches external AI with codebase context) |
Claude Code (.mcp.json):
{
"mcpServers": {
"codebase-index": {
"command": "node",
"args": ["path/to/mcp-codebase-index/dist/index.js", "--path", "/your/repo"],
"env": {
"PROMPT_ENHANCER_PROVIDER": "gemini",
"GEMINI_API_KEY": "your-key-here"
}
}
}
}
Cursor (~/.cursor/mcp.json) — same JSON format as Claude Code.
Windsurf (~/.codeium/windsurf/mcp_config.json) — same JSON format.
Via .env file (either location works):
# Option 1: Inside .claude/ (standard hierarchy)
# .claude/skills/prompt-enhancer/.env
# Option 2: Next to the skill (auto-detected fallback)
# skills/prompt-enhancer/.env
PROMPT_ENHANCER_PROVIDER=gemini
GEMINI_API_KEY=your-key-here
Ollama (local):
ollama pull llama3.2
# .claude/skills/prompt-enhancer/.env
PROMPT_ENHANCER_PROVIDER=ollama
OLLAMA_MODEL=llama3.2
OpenAI-compatible (vLLM, LM Studio, Groq, Together):
# .claude/skills/prompt-enhancer/.env
PROMPT_ENHANCER_PROVIDER=openai
OPENAI_BASE_URL=http://localhost:1234/v1 # LM Studio
OPENAI_API_KEY=lm-studio # LM Studio uses any string
OPENAI_MODEL=your-local-model
The enhancement pipeline never fails — it always returns a usable prompt.
python3 scripts/external-ai-enhance.py "Test prompt" --provider gemini
python3 scripts/external-ai-enhance.py "Test prompt" --provider ollama
tools
Use when work should span one or more detached tasks but still behave like one job with a single owner context. TaskFlow is the durable flow substrate under authoring layers like Lobster, ACPX, plugins, or plain code. Keep conditional logic in the caller; use TaskFlow for flow identity, child-task linkage, waiting state, revision-checked mutations, and user-facing emergence.
tools
# Lobster Lobster executes multi-step workflows with approval checkpoints. Use it when: - User wants a repeatable automation (triage, monitor, sync) - Actions need human approval before executing (send, post, delete) - Multiple tool calls should run as one deterministic operation ## When to use Lobster | User intent | Use Lobster? | | ------------------------------------------------------ | --------------------------
tools
# Lobster Lobster executes multi-step workflows with approval checkpoints. Use it when: - User wants a repeatable automation (triage, monitor, sync) - Actions need human approval before executing (send, post, delete) - Multiple tool calls should run as one deterministic operation ## When to use Lobster | User intent | Use Lobster? | | ------------------------------------------------------ | --------------------------
tools
A CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.