System Prompt for Coding Agent: 12 Rules Templates
12 system prompt templates for coding agents: tool policies, test gates, refusal rules, and eval sets from your stack notes. No invented CI or secrets.

A system prompt for coding agent setups should encode your stack, repo rules, allowed tools, test commands, and secret handling before the agent touches files. Use these templates to draft policies, refusal lists, and mini evals. Do not invent CI scripts or print env secrets into chat. Below are 12 copy-paste prompts plus a flagship compiler.
Prefer modern Cursor project rules as .cursor/rules/*.mdc files when you use Cursor; a single legacy .cursorrules file is the older format. Use rule types "Apply to Specific Files" and "Apply Intelligently" when you split rules.
Prompts for the core system prompt
1. Role and stack lock
Write a system prompt opening that locks stack [stack] and repo layout [layout]. Forbid inventing other frameworks.
2. Imperative repo rules
Turn these standards into short imperatives for an agent: [rules]. No polite filler.
3. Definition of done
Done when: [criteria]. Expand into a checklist the agent must run, including commands [tests].
Prompts for tools and safety
4. Tool allowlist
Allowed tools: [tools]. For each, write when to use and when not to. Forbidden: [forbidden].
5. Secrets policy block
Write a secrets section from [policy]. Include refusal language for printing .env values.
6. Git safety
Draft rules for branch names, commit style [style], and bans on force-push to [protected branches].
7. Dependency installs
Package manager [pm]. Write rules for adding deps, lockfile updates, and refusing global installs.
Prompts for evals and hosting
8. Mini eval set
Create 5 tasks for [repo type] with pass/fail checks tied to [test commands]. Include one refusal task.
9. Cursor rules split
Split this system prompt [paste] into .cursor/rules/*.mdc ideas: one always-on, one Apply to Specific Files for [globs], one Apply Intelligently for refactors. Note that .cursorrules is legacy.
10. Output contract
Specify how the agent reports files changed, commands, test results, and residual risks.
11. Incident refusal drills
List 8 dangerous user requests (secret dump, prod deploy, disable auth). Write one-line refusals.
12. Diff budget
Write rules that cap unrelated refactors and require asking before renaming public APIs.
Build the full system prompt with the flagship
The Coding Agent System Prompt: Repo Rules, Tools, Tests compiles stack, rules, tools, tests, refusals, and a mini eval set. Its FastAPI + uv example requires ruff and pytest, forbids printing .env values, and omits CI vendors that were not in the inputs.
Related prompts
See the code review agent system prompt with severity rules, AI chatbot system prompt from business facts, System Prompt for AI Chatbot, and Claude Code Prompts for Security.
Related: How to write Cursor rules (.mdc) from a repo brief and keeping one AGENTS.md for Cursor, Claude, and Copilot.
Find more in the Agents category, look through Browse, or post your own on Share.