| name | prompt-engineering |
| description | Craft effective prompts and instructions for AI coding assistants. Use when creating rules, agents, skills, or system prompts for Cursor or other LLM-based tools. |
Skill: Prompt Engineering
Trigger
When the user needs to write, improve, or review prompts, system instructions, agent definitions, Cursor rules, or any text intended to guide AI behavior.
Steps
- Clarify the goal — Identify what the prompt should make the AI do (generate code, review, explain, follow a pattern).
- Define the persona — Specify the role, expertise level, and constraints (e.g. "You are a senior backend engineer specializing in Node.js").
- Structure the prompt — Organize with clear sections:
- Context: Background the AI needs
- Instructions: What to do (use imperative mood)
- Constraints: What NOT to do (use NEVER/ALWAYS for hard rules)
- Output format: Expected shape of the response (code, bullet points, table)
- Examples: One good and one bad example when possible
- Apply prompt patterns — Use established techniques:
- Few-shot: Provide 2–3 examples of desired input/output
- Chain of thought: Ask the AI to think step-by-step for complex reasoning
- Negative constraints: Explicitly state anti-patterns to avoid
- Structured output: Specify exact format (JSON, markdown, code block)
- Review and iterate — Test the prompt; refine based on output quality.
Rules
- Use imperative mood for instructions ("Use X", "Never do Y")
- Bold critical constraints: ALWAYS, NEVER, CRITICAL
- Keep instructions atomic — one rule per bullet point
- Order from most important to least important
- Use tables for structured data (comparisons, configurations)
- Include escape hatches: what to do when the instruction doesn't apply
- Avoid vague language ("try to", "maybe", "consider") — be decisive
- Test with edge cases: what happens if the user asks something unexpected?
Prompt Quality Checklist
Anti-patterns
- Walls of text without structure — use headers and bullet points
- Conflicting rules (e.g. "be concise" AND "explain everything in detail")
- Too many rules — prioritize; AI follows top rules more reliably
- Vague instructions: "write good code" vs "use TypeScript strict mode, define interfaces for all inputs"
- Missing context: assuming the AI knows your project without telling it
Prerequisites
Completion Checklist
If Step Fails
- AI ignores a rule: Move it higher in the prompt; bold it; add "CRITICAL"
- Output is wrong format: Add an explicit example of the expected format
- AI hallucinates: Add "Only use information from the provided context"
- Too verbose: Add "Keep responses under N sentences/lines"
- Too terse: Add "Explain your reasoning" or "Include code examples"
Example
Task: Create a Cursor rule for error handling.
- Persona: "You are a backend engineer ensuring consistent error handling."
- Structure: Section for error classes, section for HTTP mapping, section for logging.
- Constraints: "NEVER expose stack traces to API consumers", "ALWAYS include correlationId".
- Format:
.mdc file with YAML frontmatter, markdown body.
- Test: Apply to a sample handler and verify output matches expectations.