Coding Prompts for Cursor: Write a Spec, Not a Wish
A spec-driven method for getting safer, reviewable code changes from Cursor and other AI coding assistants.
Why one-line coding requests drift
“Add authentication” sounds clear to a human who already knows the repository. An AI assistant still has to guess the framework, identity provider, session model, persistence layer, protected routes, failure behavior, and migration constraints.
Every guess increases the chance of a plausible but incompatible implementation. A good coding prompt works like a small issue specification: it identifies the change boundary and the evidence required before the change can be accepted.
Describe the repository before the task
Start with the facts that constrain implementation. Mention the language and framework versions, package manager, relevant directories, persistence layer, and existing patterns that should be reused.
- Runtime and framework versions.
- Files or modules that are in scope.
- Existing utilities, APIs, and conventions to reuse.
- Files, dependencies, and public interfaces that must not change.
This is a Next.js App Router project using TypeScript, Upstash Redis, and server-side signed sessions. Authentication helpers live in lib/auth.ts. Do not introduce an ORM, a second datastore, or a new auth framework.
Define behavior with acceptance criteria
Implementation instructions tell the assistant what to type. Acceptance criteria tell it what must be true. Favor observable behavior: response status, UI state, persistence result, accessibility behavior, and test outcome.
- Given/when/then behavior for the happy path.
- Expected validation and error states.
- Authorization rules and data ownership.
- Performance, accessibility, or compatibility constraints.
- Tests and commands that must pass.
Require inspection before editing
In an established codebase, the assistant should inspect adjacent files before choosing an implementation. Tell it to identify the current pattern, state assumptions, and ask when a decision would materially change the architecture.
This reduces the common failure mode where the generated code is locally reasonable but duplicates an existing abstraction or violates a repository rule.
Before editing, inspect the existing session creation, API error helper, and account page. Reuse established patterns. Preserve unrelated working-tree changes. After implementation, run the focused unit tests, lint, and production build; report any check you could not run.
Keep the change reviewable
Ask for the smallest coherent change, not the fewest lines. A coherent change may include code, tests, documentation, and migration handling, but it should avoid unrelated cleanup.
For risky work, split the request into inspect, plan, implement, and verify phases. Review the plan before allowing migrations, dependency replacements, permission changes, or destructive commands.
- Name explicit out-of-scope work.
- Require backward compatibility when relevant.
- Ask for tests that fail before the fix and pass after it.
- Request a concise handoff listing changed files and residual risks.
Turn the method into a usable prompt
Enter a rough idea and PromptSmith will add structure, constraints, and an output format.
Optimize a prompt free →Apply the method with a ready template
A repository-aware debugging prompt that asks the coding assistant to inspect evidence, identify the root cause, make a focused fix, and verify it.
A code-review prompt that prioritizes correctness, security, regressions, and missing tests over cosmetic comments.