AI Skill Library

Effective AI Coding Prompts

How to write prompts that get accurate code from AI assistants.

aipromptingmeta
# Effective AI Coding Prompts

## Provide context first
- Tech stack (language, framework, version)
- Existing file structure / relevant snippets
- Constraints (browser support, perf budget, no new deps)

## State the goal, not the solution
Bad: "Add useState here"
Good: "When user clicks the row it should expand to show details; data is already in the parent."

## Specify acceptance criteria
- Inputs / outputs / edge cases
- Error handling expectations
- Tests required? Where?

## Anchor to real code
Paste the relevant function or share file paths. Don't make the AI guess naming conventions.

## Iterative refinement
1. Ask for a plan first ("List steps before coding").
2. Confirm assumptions.
3. Then request implementation.
4. Review diff; ask for fixes specifically.

## Useful prompt skeleton
```
Context: <stack, file path, snippet>
Task: <what to do>
Constraints: <perf, deps, style>
Acceptance: <how I'll know it's done>
```

## Anti-patterns
- "Make it better" (unbounded).
- Asking for code without sharing existing code.
- Mixing 5 changes in one prompt; reviewer can't isolate.

## Debugging with AI
Share: the exact error, full stack trace, what changed last, the minimal repro. Then ask for hypotheses ranked by likelihood before any fix.

API: /api/skills/cursor-prompting