Claude-skill-registry ai-prompt-engineer
AI engineering skill for prompt optimization, context inference, and intelligent command routing across different models and use cases
git clone https://github.com/majiayu000/claude-skill-registry
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/ai-prompt-engineer" ~/.claude/skills/majiayu000-claude-skill-registry-ai-prompt-engineer && rm -rf "$T"
skills/data/ai-prompt-engineer/SKILL.mdAI Prompt Engineer
An AI engineering skill focused on optimizing prompts, improving context collection, and intelligently routing requests across different models, purposes, and layers of the agent loop.
Purpose
This skill addresses the core challenge: users shouldn't need to over-provide information. Caro should infer context intelligently and serve users with minimal friction. This skill guides the systematic improvement of:
- Query Understanding - Categorize and understand user intent from minimal input
- Context Inference - Extract maximum signal from available cues (file types, platform, cwd, history)
- Tool Routing - Map inferred context to appropriate tools and commands
- Prompt Optimization - Craft prompts tailored to specific models and use cases
When to Use This Skill
Invoke this skill when working on:
- Analyzing user query patterns to improve command generation
- Optimizing prompts for different model sizes (SmolLM, larger models)
- Building context inference logic that reduces user input requirements
- Creating file-type-to-tool mappings for intelligent recommendations
- Improving platform-aware command routing
- Designing prompt templates for specific use case categories
- Evaluating prompt effectiveness across different scenarios
Core Concepts
Query Taxonomy
User queries fall into distinct categories that require different handling:
| Category | Description | Examples | Key Signals |
|---|---|---|---|
| Terminal Exploration | Navigating, listing, searching the filesystem | "what's in this folder", "find large files" | Navigation verbs, location references |
| Runbook Execution | Project-specific workflows based on history | "run the build", "deploy to staging" | Project context, command history patterns |
| Language Development | Language-specific development tasks | "compile this", "run tests" | File extensions, project markers (Cargo.toml, package.json) |
| DevOps Flow | Deployment, CI/CD, infrastructure | "push to prod", "check k8s pods" | DevOps tools (docker, kubectl), env references |
| Casual Scripting | Quick one-off tasks | "unzip this file", "rename these files" | Simple verbs, single file/pattern references |
| CLI Tool Interaction | Using specific command-line tools | "git status", "npm install" | Tool names, tool-specific vocabulary |
Context Inference Hierarchy
Extract context in priority order:
- Explicit Reference - User mentions a file, tool, or path directly
- File Type Signals - Extension hints at appropriate tools
- Platform Context - OS determines available commands and conventions
- Working Directory - Project type, available tools, recent activity
- Session History - Patterns in previous commands suggest intent
- Default Conventions - Platform/community standard practices
The File Type Principle
"The file type is the strongest hint for tool selection"
When a user references a file, the extension often determines the appropriate tool:
Archive Example:
,.tar.gz
→.tgz
(Linux/macOS)tar -xzf
→.zip
(macOS),unzip
or7z x
(Windows)Expand-Archive
→.rar
(requires installation)unrar
→.7z
(requires 7-zip)7z x
The Anti-Pattern:
User on macOS: "extract this archive" File: document.zip BAD: tar -xzf document.zip (wrong tool for file type) GOOD: unzip document.zip (matches file type + platform)
Workflow
Phase 1: Analyze Query Pattern
1. Read the user query 2. Identify category from Query Taxonomy 3. Extract explicit references (files, tools, paths) 4. Note implicit signals (verbs, modifiers, context words) 5. Document the analysis
Phase 2: Gather Context Signals
1. Check if file reference exists → extract extension 2. Detect platform from ExecutionContext 3. Identify project type from cwd markers 4. Review session history for patterns 5. Build context signal map
Phase 3: Map to Tool/Command Space
1. Use file-type-to-tool mappings (see references/file-tool-map.md) 2. Filter by platform availability 3. Consider user preferences if known 4. Rank options by confidence 5. If ambiguous, prepare clarifying question
Phase 4: Optimize Prompt
1. Select appropriate prompt template for category 2. Inject inferred context 3. Constrain output space based on mappings 4. Add platform-specific rules 5. Format for target model (SmolLM ChatML, etc.)
Phase 5: Evaluate & Iterate
1. Run against test cases in evaluation harness 2. Measure improvement vs baseline 3. Document patterns that work 4. Update mappings and templates 5. Create regression tests for fixed cases
Reference Materials
| Document | Purpose |
|---|---|
| Detailed breakdown of query categories with detection signals |
| File extension to tool mappings by platform |
| Patterns for inferring context from minimal input |
| Category-specific prompt optimization templates |
| Real-world optimization examples |
Integration Points
This skill integrates with:
- Prompt building and capability profiling/src/prompts/
- Execution context detection/src/context/mod.rs
- Testing improvements against baseline/src/evaluation/
- Test case datasets/tests/evaluation/dataset.yaml
Success Metrics
- Inference Accuracy - Correct tool/command selection without explicit user specification
- Context Hit Rate - Percentage of queries where useful context was inferred
- Clarification Rate - Reduction in "what do you mean?" responses
- Cross-Platform Correctness - Right tool for right platform
Example Session
Scenario: User on macOS in a Rust project asks "extract the dependency archive"
Query Analysis: - Category: Casual Scripting (simple verb, file reference) - Explicit: "dependency archive" - Implicit: extraction intent Context Signals: - Platform: macOS (BSD tools, unzip available) - CWD: /Users/dev/myproject (Cargo.toml present → Rust project) - Files matching "archive": vendor.tar.gz, deps.zip Ambiguity Detection: - Multiple archive files found - Different formats require different tools Resolution Options: 1. Ask: "Which archive? vendor.tar.gz or deps.zip?" 2. Or list both commands with explanations If deps.zip selected: - Tool: unzip (matches .zip + macOS) - Command: unzip deps.zip - NOT: tar -xzf deps.zip (wrong tool!)
Anti-Patterns to Avoid
- Platform Mismatch - Using GNU flags on BSD, tar for zip files
- Over-Assumption - Guessing without sufficient signals
- Under-Inference - Asking for info that's already determinable
- Tool Hallucination - Suggesting tools not installed/available
- Context Blindness - Ignoring obvious cues from file types, cwd
Next Steps for Development
- Expand
with more file types and edge casesfile-tool-map.md - Build query classifier that maps natural language to taxonomy categories
- Create "context score" metric for measuring inference quality
- Develop prompt templates optimized for each category
- Add test cases to evaluation harness for new patterns