Skip to content
AI Dev Toolkit.
Esc
  • AI Token CounterCount tokens for GPT, Claude, Gemini, DeepSeek, Qwen and more.Tool
  • LLM API Cost CalculatorEstimate per-request, daily and monthly API costs.Tool
  • AI Model ComparisonCompare prices, context windows and features across models.Tool
  • AI Model Pricing PagesSpecs, real costs and cheaper alternatives for popular models.Tool
  • Context Window CheckerSee whether your text fits each model’s context window.Tool
  • Subscription vs API CalculatorFind out whether a chat plan or the API is cheaper for you.Tool
  • GPU / VRAM CalculatorCheck how much VRAM a local model needs and which GPUs fit.Tool
  • Prompt Caching CalculatorEstimate savings from prompt caching.Tool

System prompt · Coding

Coding assistant system prompt for a TypeScript and React stack

Use this for a chat-based coding helper inside your team: an internal bot, an IDE extension or a code-review sidekick. Generic coding prompts produce generic code: a different test framework from the one you use, a new dependency for something the standard library does, or confident claims about a file the model never saw. This prompt pins the stack and conventions, tells the model to say what it would need to read rather than guess, and asks for changes as small, reviewable diffs with the command that proves they work.

Prompt

The system prompt

371 tokens with OpenAI o200k_base (gpt-tokenizer 4.0.0), placeholders unfilled. Original writing, free to copy and adapt.

System prompt · 371 tokens
You are a senior engineer pairing with a developer on a {{product}} codebase. The stack is TypeScript (strict mode), React {{react_version}}, {{framework}} and Node.js {{node_version}}. Tests use {{test_runner}}. Package manager: {{package_manager}}.

<conventions>
- Prefer the platform and existing dependencies. Suggest a new package only when it saves real work, and say what it adds.
- Use functional React components and hooks. Keep components small; move logic into plain, testable functions.
- No "any". Model data with types, and validate anything from outside the program (requests, files, environment) at the boundary.
- Match the style of the code you're shown: naming, file layout, error handling.
</conventions>

<grounding>
- Only make claims about code you have been shown. If the answer depends on a file you haven't seen, name the file and ask for it rather than guessing its contents.
- If you're unsure an API exists in the versions above, say so and suggest how to check.
</grounding>

<changes>
- Make the smallest change that solves the problem. Don't refactor unrelated code unless asked.
- Show changes as a unified diff, or as complete small files when a diff would be harder to read.
- After the change, give the command that verifies it (a test, a type check, a curl call) and add or update a test when behaviour changes.
- Point out any security issue you notice, such as injection, unsafe HTML or secrets in code, even if it's outside the question.
</changes>

<answers>
Start with the answer or the fix. Explain only what isn't obvious from the code. When there are real trade-offs between approaches, give the two best options in a sentence each and recommend one.
</answers>

Variables

What to fill in

Fill these once per deployment. Anything that changes per request, such as the user’s name or today’s date, belongs in the user message so the system prompt stays identical and cacheable.

{{product}}
What the codebase is.
e.g. B2B invoicing web app
{{react_version}}
React major version.
e.g. 19
{{framework}}
Framework and router.
e.g. Next.js App Router
{{node_version}}
Node.js major version.
e.g. 22
{{test_runner}}
Test framework.
e.g. Vitest and Playwright
{{package_manager}}
npm, pnpm, yarn or bun.
e.g. pnpm

Design notes

Why each part is there

  1. Role and stack line

    Pins exact versions and tools. A model that knows you use Vitest and pnpm won’t answer with Jest and npm. Anthropic compares the model to a brilliant new employee who lacks context on your norms; the stack line is that context.

    Follows: Anthropic: Prompting best practices · OpenAI: Prompt engineering

  2. <conventions>

    Short, specific rules with a reason where it isn’t obvious (“say what it adds”). Google recommends clear, specific instructions and explicit constraints over general advice like “write good code”.

    Follows: Google: Prompt design strategies · Anthropic: Prompting best practices

  3. <grounding>

    Adapted from Anthropic’s advice on minimising hallucinations in coding: never speculate about code you haven’t opened. In a chat without file access, “ask for the file” is the equivalent of “read it first”.

    Follows: Anthropic: Prompting best practices · Anthropic: Reduce hallucinations

  4. <changes>

    Small diffs plus a verification command make every suggestion reviewable. Asking for a test when behaviour changes follows Anthropic’s agentic coding advice to verify work rather than assume it.

    Follows: Anthropic: Prompting best practices

  5. <answers>

    Answer first, then trade-offs in two lines. This keeps replies scannable and stops long tutorials when the developer wanted a fix.

    Follows: OpenAI: Prompt engineering

Try it

A message to test it with

First user message
This component re-renders on every keystroke and the list is slow. How do I fix it?

```tsx
export function Search({ items }: { items: Item[] }) {
  const [q, setQ] = useState("");
  const filtered = items.filter((i) => i.name.toLowerCase().includes(q.toLowerCase()));
  return (<><input value={q} onChange={(e) => setQ(e.target.value)} /><List items={filtered} /></>);
}
```

Adapt

How to adapt it

  • Swap the stack line for yours; keep exact versions, since API differences between major versions are where models go wrong most.
  • Paste your three most important team rules into <conventions>. More than about ten rules and the less important ones start to dilute the rest.
  • If the assistant has file-reading tools, change <grounding> to “read the file before answering” and give it the tool.
  • For Python, Go or another stack, keep the structure and replace the conventions; the grounding and change rules work for any language.

Failure modes

Common failure modes

It suggests libraries you don’t use.
Check the stack variables are filled in. Add “existing dependencies:” with your main packages if it keeps happening.
It invents functions in your codebase.
The grounding rule helps, but the real fix is context: send the relevant files, or give the model a search tool.
Answers are long explanations without code.
Ask for the diff first in <answers>, and lower max_tokens for chat use.

Cost

What it costs to send with every request

The prompt alone (371 tokens), sent with 10,000 requests a day over 12 hours, for a month. User messages and replies are extra. Prices from our daily data, updated 2026-10-15.
ModelWithout cachingWith caching
Claude Sonnet 5.5estimate: this model’s tokenizer isn’t public, so its count may differ$225.69Not cached: under the 512-token minimum
Claude Haiku 5.5estimate: this model’s tokenizer isn’t public, so its count may differ$11.28Not cached: under the 512-token minimum
GPT-6.1 Solo200k_base count; OpenAI hasn’t published this model’s tokenizer$225.69Not cached: under the 1,024-token minimum
Gemini 3.8 Flashestimate: this model’s tokenizer isn’t public, so its count may differ$84.63Not cached: under the 4,096-token minimum

A prompt under a provider’s minimum is still billed in full on every call. Tool definitions sit before the system prompt in the cached prefix, so together they may cross it. Price it at your own traffic.

Placement

Where it goes in each API

Put the prompt first and the code the developer pastes in the user turn. Coding chats run long, so the system prompt is a small share of each request after a few turns, but it is resent every time. For tools such as Claude Code or Cursor, this content belongs in the project’s memory file (CLAUDE.md, AGENTS.md or rules) rather than a system prompt.

APIWhere the system prompt goesWorth knowing
OpenAI Responses APIinstructionsApplies to that request only: with previous_response_id, send it again every turn.
OpenAI Chat Completionsa developer message first in messagesReplaces the system role for o1 and newer models; developer messages take priority over user messages.
Anthropic Messages APItop-level systemNo system role inside messages. Pass it as a text block with cache_control to cache it.
Gemini generateContentsystemInstructionText only. Still supported; Google recommends the Interactions API for new work.
Gemini Interactions APItop-level system_instructionSent beside model and input. Applies to that interaction only: with previous_interaction_id, send it again every turn.

Related

CLAUDE.md generatorAI rules converterChoosing a model for coding agentsAll system prompts