Claude Code / Codex
Instruction Prompts & Template Collection
30 CLAUDE.md / AGENTS.md / Cursor Rules templates. Paste a prompt into chat to have them generated, or paste a finished file directly. Either way works.
AI coding agents (Claude Code, OpenAI Codex, Cursor, and others) read the instruction file at the root of your repository (CLAUDE.md / AGENTS.md) to learn "this project's rules." But when those instructions are vague, the AI happily ignores them. An effective instruction file looks like this: short imperative sentences, explicit prohibitions, and a clear "definition of done" with verification steps.
For why they get ignored and how to fix it, see "Why AI Ignores Your .md Rules, and How to Fix It" .
Just paste the prompt straight into the chat box of Claude Code / Codex / Cursor. The AI inspects your repository and writes out an instruction file with your real commands in it.
Almost no manual editing needed. Use this to also audit and improve existing instruction files, or convert them into AGENTS.md / Cursor format.
Copy a finished instruction file and save it as CLAUDE.md at the root of your repository. Replace just a few placeholders like <name> with your own environment.
For people who want to understand and manage the contents themselves, or who want a starting template for a specific language/framework.
Just paste into chat (generate & improve prompts)
Generate an instruction file from scratch (CLAUDE.md / AGENTS.md, auto-inspects the repo)★
The easiest option. Paste it into chat and the AI inspects your repository and writes out an instruction file with your real commands in it. Almost no manual editing needed.
Inspect this entire repository and create, at the root, the instruction file
that you (this agent) load automatically
(Claude Code uses `CLAUDE.md`, Codex uses `AGENTS.md`, Cursor uses `.cursor/rules/`).
Include:
- Project overview (what the app does, the tech stack)
- Commands (dev server / build / test / lint). Identify the real commands
from actual files like package.json or Makefile (do not guess)
- Coding conventions (match the actual style you read from the existing code)
- Absolute rules: never commit secrets or .env / never reformat unrelated lines /
never push unless told to
- Definition of done: do not report "done" until lint and test pass
(include the real command names)
Do not fill gaps with guesses; ask me when something is unclear.
Finally, write it all out as the instruction file described above.
Why it works:Having the AI read and write your own repo is the fastest path. Leaving the filename up to the tool (CLAUDE.md / AGENTS.md, etc.) means it works as-is in both Claude and Codex. And because it pins commands and paths down from your actual files, no manual editing is needed.
Audit an existing instruction file and rewrite it into an "effective" form
For when you already have an instruction file (CLAUDE.md / AGENTS.md) but the AI won't follow it. Have it point out the weak spots, then rewrite it with imperative phrasing and verification steps.
Read the instruction file you (this agent) load (CLAUDE.md / AGENTS.md, etc.),
point out the weak spots that AI agents tend to ignore, and then rewrite it
into an effective form.
Things to look at:
- Turn vague wording into imperatives (always do X / never do Y)
- Add a "definition of done" and verification steps (running lint / test)
- Make prohibitions concrete down to the target (directory names, command names)
- If it is too long, cut it down to just the core you want enforced
First list the weak spots as bullet points, then output the full rewritten
version and apply it to that instruction file.
Why it works:An "ineffective instruction file" is usually vague, has no verification steps, and names prohibitions only in the abstract. Having the AI state the weak spots itself before fixing them makes the improvements concrete.
Add a "definition of done" tailored to your current repo
Add the single most important block, with your real commands, to stop the AI from quitting when it only thinks it is finished.
After identifying this repository's actual build / test / lint commands,
add a "Definition of Done" section to the instruction file you load
(CLAUDE.md / AGENTS.md, etc.).
Requirements:
- Make it a checklist in the form "do not report done until all of the following are met"
- State the real lint and test commands explicitly
- Include: leave no TODOs or debug logs in changed files, and re-read your own diff
Do not break the existing content; only add the section.
Why it works:When the completion criteria are vague, the AI stops out of self-satisfaction. Just adding a checklist with real commands gets the self-verification loop running. Specifying "add, don't break the existing content" is the safe approach.
Auto-detect the language/framework and add rules
Have it detect the stack and add the right rules, e.g. Server/Client boundaries for Next.js.
Automatically detect this repository's language and framework, and add the
corresponding best-practice rules to the instruction file you load
(CLAUDE.md / AGENTS.md, etc.).
Examples:
- Next.js: Server/Client boundary (default is Server, keep use client minimal)
- Laravel: validation via Form Requests, migration conventions
- Python: type annotations, never overwrite or fabricate raw data
Add a one-line note on the basis for your detection (which files you judged from)
before appending. Do not duplicate anything already written.
Why it works:The failure points differ by language. Having the AI auto-detect and add only the relevant rules is more accurate than a generic template, and easier to maintain.
Add absolute rules for security / Git / testing
Add a set of "absolute rules" that prevent irreversible accidents.
Add the following "absolute rules" to the instruction file you load
(CLAUDE.md / AGENTS.md, etc.), tailored to this repository's setup.
- Never commit secrets, .env, or credentials
- Never push / force-push unless told to
- Validate input at the boundary / never loosen authentication or authorization on your own
- Never run destructive commands (DROP / TRUNCATE / migrate:fresh, etc.) on the production DB
- Whenever you change behavior, always add or update tests
If similar rules already exist, do not duplicate them; only fill in what is missing.
Why it works:Accidents cluster around "leaked secrets, unsolicited pushes, destructive DB operations." Adding these as named absolute rules stops the AI from running off the rails at the entry point.
Convert CLAUDE.md to AGENTS.md (Codex) format
Recreate the same content for Codex. For people who use multiple AI tools together.
Convert the contents of this `CLAUDE.md` into the `AGENTS.md` format for
OpenAI Codex and write it out.
- Keep the meaning, but reshape it into a structure that is easy for Codex
to read (headings, bullet points)
- Keep the commands, absolute rules, and definition of done as-is
- Output it as `AGENTS.md` at the root
Why it works:CLAUDE.md and AGENTS.md share almost all of their content. Treating one as the source of truth and converting from it cuts the effort of maintaining two files.
Convert to Cursor Rules (.mdc) format
Into Cursor's Project Rules format. Outputs always-applied rules and file-type-scoped rules separately.
Convert the contents of this `CLAUDE.md` into Cursor's Project Rules format
(`.mdc` files under `.cursor/rules/`).
- Split the rules into meaningful units
- Separate the rules that should always apply from the rules that apply
only to specific file types
- Set the appropriate apply conditions (globs, etc.) at the top of each file
Why it works:Cursor works better with .mdc files split by purpose than with one big rule sheet. Leaving the split decisions to the AI is also faster.
Generate split instruction files for a monorepo
Auto-distributes common rules to the root and stack-specific rules to each package.
Inspect this monorepo's structure and create the instruction files you
(this agent) load (Claude Code uses CLAUDE.md, Codex uses AGENTS.md, etc.),
split as follows.
- At the root: rules common to the whole repo
(commit conventions, secret protection, the overall definition of done)
- In each package/app directory: only the rules and commands specific to that stack
Avoid duplication, and add a one-line note in each package saying "follow the
common rules at the root." At the end, report a list of what you placed in which directory.
Why it works:A monorepo breaks down under one giant instruction file. Splitting common rules to the root and specific rules to each package lets the AI read the right rules for the context it is in.
Ready-to-paste finished files - Basics & rules
Universal base (for any project)
Your first file. A minimal setup with project overview, commands, conventions, and absolute rules. When in doubt, start here and add or remove.
# Project: <name>
## What this is
A one-paragraph overview of the app. What it does, who uses it, and the tech
stack (language, framework, DB, runtime).
## Commands
- Dev server: `npm run dev`
- Build: `npm run build`
- Test: `npm test`
- Lint: `npm run lint`
## Conventions
- Language is TypeScript (strict). Do not use `any`.
- Match the style of the file you are currently editing. Always pass Lint before finishing.
- Keep changes minimal; do not touch unrelated lines (no unrelated reformatting).
## Absolute rules (strictly enforced)
- Before reporting done, always run the tests and Lint above and make them pass.
- Never, ever commit secrets, .env, or build artifacts.
- Prefer editing existing files over creating new ones.
- When requirements are vague, ask exactly one clarifying question before making a large change.
## Off-limits (unless told otherwise)
- CI config, dependency versions, infrastructure setup.
Why it works:Putting "Commands" first gives the AI a way to verify its work. Writing the absolute rules as short imperatives (always / never) makes them harder to ignore. The "off-limits" section blocks run-away changes up front.
"Definition of done" block that gets rules followed★
The most important one. Stops the AI from quitting when it only thinks it is finished. A generic block you can paste into any instruction file.
## Definition of done (always read before reporting)
Treat the work as "done" only when all of the following are met:
1. `npm run lint` passes with exit code 0
2. `npm test` passes with exit code 0
3. No TODO / FIXME / debug logs are left in the changed files
4. You have re-read your own diff and confirmed it matches the request
If even one is not met, keep working. Do not report "done."
## Absolute rules (strictly enforced)
- Do not edit files under `legacy/` or `vendor/`.
- Do not add, remove, or update dependencies.
- Do not reformat lines you did not change.
- Do not delete or disable tests just to make the build pass.
## When in doubt
Do not proceed on guesses; ask exactly one concise question.
A wrong, large change is far worse than a clarifying question.
Why it works:When the "completion criteria" are vague, the AI stops out of self-satisfaction. Turning it into a checklist plus stating "if not met, keep going; don't say done" gets the self-verification loop running. Naming prohibitions down to the path works.
Minimal version (just a few lines)
For projects that dislike long instruction files. The bare minimum core that still cuts the accident rate substantially.
# <name>
- Stack: <e.g. Next.js + TypeScript + PostgreSQL>
- Always run before finishing: `npm run lint` and `npm test` (both must pass)
- Match the existing style. Do not reformat unrelated lines.
- Do not commit secrets or .env. Do not push until told to.
- When vague, do not guess; ask exactly one question.
Why it works:Longer is not better for instruction files. Narrowing it to just the core you want enforced (verification, reformatting restraint, secret protection, no pushing, asking) lets the AI remember it all the way through.
Ready-to-paste finished files - By language & framework
Next.js / TypeScript
Assumes App Router. Pins down the Server/Client boundary and data-fetching style for the AI.
# Next.js (App Router) + TypeScript
## Stack
Next.js (App Router), TypeScript strict, Tailwind CSS, <your-ORM>
## Commands
- Dev: `npm run dev`
- Build: `npm run build` # must pass with no type errors
- Lint: `npm run lint`
- Test: `npm test`
## Architecture rules
- Default to Server Components. Add "use client" only when state, effects, or
browser APIs are needed. Keep Client Components small and at the leaves.
- Fetch data in Server Components or Route Handlers.
Do not fetch initial data in useEffect.
- Co-locate components with their route segment. Shared UI goes in `components/`.
- Always schema-validate external input at the boundary (e.g. Zod).
## Conventions
- No `any`. Give public functions explicit return types.
- Use the existing design tokens / Tailwind classes. Do not add colors on your own.
- Keep `page.tsx` thin; push logic into functions and components.
## Definition of done
`npm run build`, `npm run lint`, and `npm test` all pass with exit code 0.
No `any`, no unused exports, no leftover console.log.
Why it works:Next.js is the top example of the AI getting the "Server vs Client decision" wrong. Spelling out "default to Server, keep use client minimal" dramatically cuts down on accidents.
React (Vite) SPA
For Vite-based SPAs. Pins down the state management and component design approach.
# React (Vite) + TypeScript
## Commands
- Dev: `npm run dev`
- Build: `npm run build`
- Lint: `npm run lint`
- Test: `npm test` (Vitest + Testing Library)
## Rules
- Function components and Hooks only. Do not use class components.
- Keep state to the minimum, in the order "local -> Context -> state library."
Do not lift state up to global needlessly.
- Confine side effects to useEffect, and write the dependency array correctly.
- Separate UI from logic. Group data fetching into dedicated hooks (useXxx).
- Accessibility: give interactive elements appropriate roles and keyboard operation.
## Conventions
- No `any`. Define props with types.
- Match the style of the existing components and styles.
## Definition of done
`npm run build`, `npm run lint`, and `npm test` pass with exit code 0.
Why it works:In React, the classic accidents are "lifting state to global too soon" and "wrong useEffect dependencies." Spelling out the promotion order and dependency-array rule keeps things stable.
Node.js API (Express / Hono)
For backend APIs. Puts up guardrails for validation, error handling, and secret management.
# Node.js API (Express / Hono) + TypeScript
## Commands
- Dev: `npm run dev`
- Build: `npm run build`
- Test: `npm test`
- Lint: `npm run lint`
## Rules
- Schema-validate all input (body, query, params, headers) at the boundary.
- Do not swallow errors. Return them typed through a central error handler.
- Read secrets from environment variables. Do not hardcode them in code.
- Layer DB access (route -> service -> repository).
- Return a consistent JSON shape (unify the success and failure shapes).
## Absolute rules
- Do not skip or loosen authentication / authorization logic on your own.
- Always verify authorization when adding a publicly exposed endpoint.
- Do not log personal information, tokens, or passwords.
## Definition of done
`npm test` (happy path + error cases) and `npm run lint` pass.
Why it works:For APIs, the big three accident causes are "unvalidated input," "swallowed errors," and "secrets in logs." Making boundary validation and authorization checks absolute rules makes them more likely to be followed.
Laravel / PHP
Gets the AI accustomed to a convention-first framework: Eloquent, migrations, and conventions.
# Laravel + PHP
## Commands
- Serve: `php artisan serve`
- Migrate: `php artisan migrate`
- Test: `php artisan test`
- Format: `./vendor/bin/pint` # run before finishing
## Conventions (follow the Laravel way)
- Use Eloquent relations. Avoid raw SQL without a clear reason.
- Validate input in Form Request classes. Do not do it inside controllers.
- Keep controllers thin. Push business logic into Services / Actions.
- Every schema change gets a new migration. Do not edit ones already run.
- Use named routes and route model binding.
## Absolute rules
- Never, ever commit `.env` or real credentials.
- Do not run destructive commands like `migrate:fresh` against the production DB.
- Whenever you change behavior, always add or update tests (`php artisan test`).
## Definition of done
Both `php artisan test` and `./vendor/bin/pint --test` pass.
Why it works:For a "convention-first" framework, spelling out "follow the framework's conventions" plus banning destructive commands is the safe move. Banning edits to already-run migrations also matters.
Python / data analysis
Emphasizes types, virtual environments, and reproducibility. Puts the "don't break or fabricate data" rules first.
# Python / data analysis
## Environment
- Use the project venv `.venv`. Do not install globally.
- Install: `pip install -r requirements.txt`
- Run: `python -m src.main`
- Test: `pytest`
- Format: `ruff check .` and `ruff format .`
## Conventions
- Add type annotations to every function signature. Run `mypy src` if configured.
- Do not put logic in notebooks. Reusable code goes in `src/`.
- Fix the seed for anything using randomness, so results are reproducible.
## Absolute data rules (most important)
- Do not silently fill in or fabricate missing values. If there are missing
values, report them and confirm how to handle them.
- Do not overwrite raw data files. Write output to `data/processed/`.
- Document all assumptions (filters, excluded rows, units) in code comments.
## Definition of done
`pytest` passes, `ruff check .` is clean, and the results reproduce from a clean state.
Why it works:In analysis, the AI's biggest mistakes are "silently filling missing values" and "overwriting raw data." Just explicitly banning these makes the results far more trustworthy.
Go
Gets the AI to follow the Go way, which values simplicity and explicit error handling.
# Go
## Commands
- Build: `go build ./...`
- Test: `go test ./...`
- Format: `gofmt -w .` and `go vet ./...`
## Conventions
- Do not swallow errors. Always handle them with `if err != nil`, and return
them with context (`fmt.Errorf("...: %w", err)`).
- Keep nesting shallow with early returns.
- Use concurrency only when needed. Watch for goroutine leaks and races
(make `go test -race` pass).
- Comment exported symbols. Prefer the standard library.
## Absolute rules
- Do not add unnecessary abstractions or interfaces (create them when needed).
- Before adding a dependency, first check whether the standard library suffices.
## Definition of done
`go build ./...`, `go vet ./...`, and `go test -race ./...` all pass.
Why it works:In Go, "over-abstraction" and "swallowed errors" are the accident sources. Spelling out early returns, %w wrapping, and -race produces safe, idiomatic Go code.
Rust
Prevents overuse of unwrap and unsafe, and makes it handle Result/Option correctly.
# Rust
## Commands
- Build: `cargo build`
- Test: `cargo test`
- Lint: `cargo clippy -- -D warnings`
- Format: `cargo fmt`
## Conventions
- Do not casually use `unwrap()` / `expect()` in production code.
Handle `Result` / `Option` correctly with `?` or match.
- `unsafe` is banned in principle. If truly necessary, state the reason in a comment.
- Follow the compiler on borrowing and lifetimes. Rethink the design before
escaping with `clone()`.
- Make error types meaningful with `thiserror` / `anyhow`, etc.
## Definition of done
`cargo build` and `cargo test` pass, and
`cargo clippy -- -D warnings` reports zero warnings.
Why it works:In Rust, when the AI gets stuck it tends to escape with `unwrap()` and `clone()`. Discouraging these and making clippy pass with -D warnings preserves quality.
Ruby on Rails
Keep it "on the rails." Avoid fat models/controllers and follow the conventions.
# Ruby on Rails
## Commands
- Serve: `bin/rails server`
- Migrate: `bin/rails db:migrate`
- Test: `bin/rails test` (or `bundle exec rspec`)
- Format: `bundle exec rubocop -A`
## Conventions (follow the Rails way)
- Respect "convention over configuration"; do not invent your own structure.
- Avoid fat controllers / models. Push logic into Services / Concerns.
- Restrict input with strong parameters.
- Avoid N+1 (use `includes`).
- Schema changes get a new migration. Do not edit ones already run.
## Absolute rules
- Never, ever commit `.env` or credentials.
- Do not run destructive commands against the production DB.
- When you change behavior, add or update tests.
## Definition of done
Tests and `bundle exec rubocop` pass.
Why it works:Rails becomes unmaintainable fast once you stray from convention. Spelling out "stay on the rails," "avoid fat," and "avoid N+1" preserves Rails idioms.
SQL / DB migrations
Don't break the data; only reversible changes. Safety guardrails for migrations.
# SQL / database migrations
## Absolute rules (data protection comes first)
- Do not run destructive operations against production data on your own
(DROP / TRUNCATE / unconditional DELETE or UPDATE).
- Migrations must provide a rollback procedure, not just the forward direction.
- Do not edit migrations already run. Always add new ones.
- Drop or rename columns in stages ("add -> migrate -> retire"); do not do it in one shot.
## Query conventions
- Avoid `SELECT *`; specify the columns you need.
- Confirm that WHERE / JOIN conditions can use an index.
- Split large updates into batches to keep lock time short.
- For destructive verification queries, first confirm the affected count with a `SELECT` before running.
## Definition of done
Both apply and rollback succeed in a staging-equivalent environment, and you
have confirmed no unintended changes to existing data.
Why it works:The DB is the most "irreversible" area of all. Spelling out a ban on destructive operations, staged schema changes, and required rollbacks is the lifeline.
Ready-to-paste finished files - By workflow
Test-driven (TDD)
Enforces "don't put tests off" and "don't make it pass by deleting tests."
# Test-driven approach
When changing behavior, follow this loop every time:
1. Write a "failing test" that expresses the desired behavior first.
2. Run the test and confirm it fails for the right reason.
3. Write the minimum code needed to make the test pass.
4. Run the full test suite and confirm everything is green.
5. Refactor while keeping it green.
## Absolute rules
- Do not delete or skip tests to make the suite pass.
- Do not weaken assertions to make things green.
- If a test really is wrong, explain why before changing it.
- New code without tests is not "done."
## Definition of done
The full suite passes, coverage has not dropped, and reverting the
implementation makes the new test fail (i.e. it is a meaningful test).
Why it works:When stuck, the AI sometimes deletes tests and says "it passed." Writing out "don't delete, don't weaken, confirm it fails on revert" closes off the loopholes.
Debugging-focused
Prevents guess-and-check fixes. Enforces the discipline of root-cause identification then a minimal fix.
# Debugging approach
Proceed in this order. Do not fix by guessing:
1. Establish the reproduction steps (how to trigger the bug).
2. Write out the expected behavior and the actual behavior, one sentence each.
3. Form a hypothesis. Verify it with logs or a minimal repro before fixing.
4. Once you have identified the cause, apply the minimal fix.
5. After fixing, confirm the bug is gone via the repro steps and that existing tests pass.
6. If possible, add a regression test that catches this bug.
## Absolute rules
- Do not change multiple places at once while the cause is unknown.
- Do not stop at "it works for now." Explain why it was fixed.
- Do not mix unrelated refactoring into debugging.
Why it works:When stuck on a bug, the AI tends to rewrite multiple places at once and make things worse. Forcing the order "reproduce -> hypothesize -> verify -> minimal fix -> regression test" reliably fixes it.
Refactoring-focused
Makes "don't change behavior" the absolute condition. Safe improvement backed by green tests.
# Refactoring approach
## Core principle
Do not change externally observable behavior. Do not change outputs or side
effects for any input at all.
## Steps
1. Confirm first that tests exist for the target area and are green.
If not, write characterization tests that pin down the current behavior first.
2. Change in small, single steps, running the tests after each step.
3. Keep one commit = one kind of improvement.
## Absolute rules
- Do not mix feature additions or bug fixes into refactoring (make them separate work).
- If a test turns red, stop right there. Do not proceed.
- Do not change public API signatures on your own (confirm first if needed).
## Definition of done
All tests stay green, and the code is more readable with less duplication.
Why it works:For refactoring, "don't change behavior" is everything. Without making this the core principle and backing it with green tests, the AI will happily break features. Banning mixing in feature additions also matters.
Writing specs / design documents
Don't let it implement right away; have it write out the design in prose first. Drastically reduces rework.
# How to write a design document
Before implementing, first write out the following in prose (do not write code):
## 1. Goal
The problem to solve, and the conditions for calling it achieved (success criteria).
## 2. Current state and constraints
The existing setup, dependencies, and constraints to respect (performance, compatibility, deadline).
## 3. Design proposal
- The chosen approach, and the approaches you considered and rejected (and why).
- The data flow, the key interfaces, and the files to change.
## 4. Risks and open questions
What could break, the assumptions that need confirming, and the points needing a decision.
## 5. Plan
Break the implementation into small steps, ordered into verifiable units.
## Rules
- Do not start implementing until this design is approved.
- List unknowns under "open questions"; do not fill them with your own assumptions.
Why it works:The AI jumps straight to implementation and mass-produces wrong directions. Just inserting "write the design first, don't implement until approved" drastically reduces rework.
Staging large changes
Prevents a giant all-at-once change. Has it split into small, reviewable units.
# How to make large changes
## Core principle
Avoid one giant change. Split it so each step is independently reviewable,
testable, and (ideally) deployable.
## Steps
1. Decompose the changes leading to the final form into a sequence of small,
independent steps, and present it.
2. For each step, write "what / why / scope of impact" in 1-2 lines.
3. After each step, run the full test suite and confirm green before moving on.
4. Proceed while preserving backward compatibility (add -> migrate -> retire the old path).
## Absolute rules
- Do not rewrite a wide area at once and "test it all together later."
- If a step grows too large, split it further.
- Keep each step at a granularity that can be reverted.
## Definition of done
Tests are green after all steps complete, and every intermediate commit is also not broken.
Why it works:The AI tends to do big overhauls as "rewrite everything at once," and when it breaks, isolating the cause becomes impossible. Splitting into stages and forcing green at each one lets you do big overhauls safely.
Ready-to-paste finished files - Operations & governance
Code-review specialized
Prevents a flood of trivial nitpicks; has it report in severity order. Pins down review criteria.
# Code review instructions
Review the changes, group them by severity, and report in this order:
1. CRITICAL - security holes, data loss, crashes, broken authentication
2. HIGH - logic bugs, race conditions, missing error handling
3. MEDIUM - performance issues, missing tests, confusing names
4. LOW - minor style nitpicks (only if there are no higher issues)
## How to report
- For each finding: file:line / what is wrong / why it matters / a concrete fix.
- Quote only the smallest relevant snippet. Do not paste the whole file.
- If a change is correct, say so explicitly. Do not fabricate problems.
## Things not to do
- Do not bury real bugs under a pile of LOW nitpicks.
- Do not rewrite whole files. Propose the smallest diff.
- Unless there is real harm, do not flag lines outside the diff's scope.
## Output
End with a one-line verdict: APPROVE / REQUEST CHANGES / BLOCK, with a reason.
Why it works:Left alone, a review AI mass-produces trivial nitpicks. Specifying severity order plus "say so if there's no problem" and "don't fabricate" removes the noise and makes it usable.
Commit / PR operation rules
Prevents unsolicited pushes, giant commits, and leaked secrets. Safety guardrails for Git operations.
# Git / PR rules
## Commits
- Use Conventional Commits: `type(scope): summary`
type: feat, fix, refactor, test, docs, chore.
- One commit = one logical change. Keep it small and reviewable.
- In the body, write the "why" rather than the "what."
## Absolute rules
- Do not `git push` unless told to.
- Do not force-push, rebase, or amend on shared branches / main.
- Do not commit secrets, .env, credentials, or large binaries.
- Add files by name. Do not sweep everything in with `git add -A`.
## Pull requests
- Title within 70 characters. Body is "Summary" + "Test plan (checklist)."
- Note any breaking changes.
- Do not merge. Create the PR and report the URL.
Why it works:Git operations are prone to "irreversible accidents." Naming and banning pushes, force-pushes, and secret leaks with "never do X" is what works.
Security-review specialized
Has it sweep for vulnerabilities by category. Prioritizes avoiding misses over false positives.
# Security review instructions
Check the changes in order against the following angles, and report any
problems found with a severity rating:
- Missing input validation (injection: SQL / command / XSS / SSRF)
- Authentication/authorization gaps (missing permission checks, privilege escalation)
- Secret exposure (hardcoded keys/tokens, output to logs)
- Insecure defaults (excessive exposure, lax CORS, unvalidated redirects)
- Known vulnerabilities in dependencies, insecure crypto / RNG usage
## How to report
- For each finding: location / attack scenario (how it could be exploited) / a concrete fix.
- Flag suspicions you are not certain of as "needs confirmation" (do not silently skip them).
- If there is no problem, state "no issues" along with the angles you checked.
## Things not to do
- Do not generate actual attack code or exploitation steps (show fixes only).
Why it works:In security, a "miss" is the most costly. Listing the angles and saying "flag suspicions as needs-confirmation" prevents the behavior of staying silent out of fear of false positives.
Docker / infra safety guardrails
Prevents irreversible accidents in container and infrastructure operations.
# Docker / infrastructure work rules
## Absolute rules (preventing destruction comes first)
- Do not run destructive commands against production or shared environments on your own
(`docker system prune`, deleting volumes, `down -v`, etc.).
- Pin images to fixed tags. Do not rely on `latest`.
- Pass secrets via environment variables / secret management.
Do not bake them into the Dockerfile or image.
- Keep exposed ports and privileges (privileged, etc.) to the minimum necessary.
## Conventions
- Keep Dockerfiles small with multi-stage builds, mindful of layer caching.
- Run as a non-root user.
- After changes, build and start locally to verify before reporting.
## Definition of done
`docker build` passes, the container starts, and the health check / basic
operation can be confirmed.
Why it works:Infrastructure is an area where you can destroy an environment in one shot. Spelling out a ban on destructive commands, avoiding latest dependence, and not baking in secrets forms the safety guardrails.
Dependency update rules
Prevents unauthorized dependency additions and major updates. Tightens the supply-chain entry point.
# Dependency rules
## Absolute rules
- Before adding a dependency, check whether the standard library or an existing
dependency suffices.
- When adding a new dependency, add a one-line note on its purpose, alternatives,
and maintenance status.
- Do not bump major versions on your own (only when told to).
- Do not regenerate lock files (package-lock.json, etc.) on your own.
- Avoid packages of dubious origin or with extremely few stars or poor maintenance.
## Steps
1. State the reason for the addition or update.
2. After adding it, confirm the build and tests pass.
3. Confirm the license does not conflict with your use case.
## Definition of done
Build and tests pass after the dependency change, and you can explain the diff in the lock file.
Why it works:Careless dependency additions and major updates are the entry point to build breakage and supply-chain accidents. "First check whether existing ones suffice" and "no unsolicited major updates" work.
If your instruction file feels like it "isn't working"
When the AI still won't follow the rules even after you add a template, the cause is often placement, granularity, or priority. We explain the fixes by cause.
Read: Why AI Ignores Your .md Rules and How to Fix It* The prompts are in English; commands and paths inside the file templates are kept in English (they are environment-dependent). Last updated: 2026-05