Stack-neutral CLAUDE.md conventions for Claude Code covering how to read before editing, keep diffs scoped, debug from a reproduction, test and report verification.
.claude/rules/claude-coding-assistant.md. Downloaded files need to be placed in that repository path.--- paths: - "**/*" --- # Engineering Conventions Applies to: any repository where Claude Code reads this file as project instructions. Stack-specific rules belong in separate files. These conventions cover how to work. ## Understand before changing - Read the files you will change and at least one caller and one test of each. Don't edit code you haven't opened. - Find the project's commands for build, test, lint and type-check (`package.json` scripts, `Makefile`, `pyproject.toml`, CI workflow) and use those, not commands you guessed. - If the request is ambiguous in a way that changes the design (data shape, public API, behavior for users), ask one focused question. For minor choices, pick the option most consistent with existing code and state the assumption. ## Making changes - Keep the diff scoped to the request. Don't reformat, rename or refactor unrelated code. Mention any problem you noticed but didn't fix. - Follow the patterns already in the codebase (error handling, naming, file layout) even where you would choose differently. Propose a refactor separately. - Prefer clear code over clever code: descriptive names, early returns, small functions with one job. Split a function when it does two separable things, not to reach a line count. - Handle failures at the boundary where you can act on them. Don't catch errors only to log and rethrow, and never swallow them silently. - Write comments for intent, constraints and non-obvious decisions (the "why"). Don't comment what the code already says. - Don't add a dependency, change a public API or edit generated files without saying so explicitly in your summary, and ask first when the change is hard to reverse. - Never put secrets, tokens or personal data in code, logs, tests or fixtures. ## Debugging 1. Reproduce the problem first: a failing test, a command, or the exact steps and the observed output. 2. State the expected behavior and the actual behavior. 3. List the plausible causes and check the cheapest one first, using logs, a debugger or a minimal reproduction instead of guessing. 4. Fix the root cause, not the symptom. If you can only mitigate, say so. 5. Add a regression test that fails without the fix and passes with it. 6. In the summary, explain the root cause in one or two sentences. ## Tests - When behavior changes, add or update tests in the same change. Test observable behavior and edge cases (empty input, boundary values, error paths), not private implementation details. - Don't delete, skip or weaken a failing test to make the suite pass unless the user agrees the test is wrong. ## Reporting back - Summarize what changed and why, which files were touched, and the exact commands you ran with their results. - Be explicit about what you did not verify (for example "UI not checked in a browser" or "integration tests need a database I don't have"). - When there are real alternatives, give the trade-off briefly and recommend one. ## Verify before finishing - Run the project's type-check, lint and test commands for the code you touched, and fix failures your change caused. - Re-read the full diff once before reporting, checking for leftover debug output, commented-out code and unrelated edits.
Cursor rules for strict TypeScript: compiler checks beyond strict, interfaces vs type aliases, real type guards, discriminated unions, utility types and branded IDs.
CLAUDE.md rules for React 19 with TypeScript covering typed components, derived state, compiler-aware memoization, useId-based accessibility and review checks.
CLAUDE.md rules for the Next.js 16 App Router with async params, streaming via Suspense, secured Server Actions, metadata conventions and explicit caching choices.
Claude
general
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
Content reviewed .
A team adds general working conventions to Claude Code as a project rule so every session follows the same read-change-verify-report loop, independent of language.
Bug: `formatPrice(0)` returns an empty string instead of "$0.00" in src/utils/format.ts. Fix it.
Illustrative; not a recorded model run. Claude opens format.ts, its callers and tests; finds the test command in package.json; writes a failing test for 0; identifies the root cause (a falsy check like `if (!amount) return ''`); changes it to an explicit null/undefined check; runs the test, type-check and lint commands and reports their output; states the root cause in one or two sentences; mentions without changing it any unrelated issue it noticed; leaves other code untouched.
Claude Code loads persistent project instructions from CLAUDE.md files and from Markdown rules in .claude/rules/. Rules can be scoped to file paths with a paths frontmatter field, and CLAUDE.md can import other files with @path syntax. The rules in this directory are written as plain instruction prompts: in Claude Code, save them as CLAUDE.md or .claude/rules/ content; in Claude.ai or the Claude API, use the same text as project instructions or a system prompt instead.
.claude/rules/claude-coding-assistant.mdStarting point, not a tested configuration for your repository. Loaded when Claude Code works with files matching paths. Review the instructions, adapt the file paths and run your project's existing checks.
--- paths: - "**/*" --- # Engineering Conventions Applies to: any repository where Claude Code reads this file as project instructions. Stack-specific rules belong in separate files. These conventions cover how to work. ## Understand before changing - Read the files you will change and at least one caller and one test of each. Don't edit code you haven't opened. - Find the project's commands for build, test, lint and type-check (`package.json` scripts, `Makefile`, `pyproject.toml`, CI workflow) and use those, not commands you guessed. - If the request is ambiguous in a way that changes the design (data shape, public API, behavior for users), ask one focused question. For minor choices, pick the option most consistent with existing code and state the assumption. ## Making changes - Keep the diff scoped to the request. Don't reformat, rename or refactor unrelated code. Mention any problem you noticed but didn't fix. - Follow the patterns already in the codebase (error handling, naming, file layout) even where you would choose differently. Propose a refactor separately. - Prefer clear code over clever code: descriptive names, early returns, small functions with one job. Split a function when it does two separable things, not to reach a line count. - Handle failures at the boundary where you can act on them. Don't catch errors only to log and rethrow, and never swallow them silently. - Write comments for intent, constraints and non-obvious decisions (the "why"). Don't comment what the code already says. - Don't add a dependency, change a public API or edit generated files without saying so explicitly in your summary, and ask first when the change is hard to reverse. - Never put secrets, tokens or personal data in code, logs, tests or fixtures. ## Debugging 1. Reproduce the problem first: a failing test, a command, or the exact steps and the observed output. 2. State the expected behavior and the actual behavior. 3. List the plausible causes and check the cheapest one first, using logs, a debugger or a minimal reproduction instead of guessing. 4. Fix the root cause, not the symptom. If you can only mitigate, say so. 5. Add a regression test that fails without the fix and passes with it. 6. In the summary, explain the root cause in one or two sentences. ## Tests - When behavior changes, add or update tests in the same change. Test observable behavior and edge cases (empty input, boundary values, error paths), not private implementation details. - Don't delete, skip or weaken a failing test to make the suite pass unless the user agrees the test is wrong. ## Reporting back - Summarize what changed and why, which files were touched, and the exact commands you ran with their results. - Be explicit about what you did not verify (for example "UI not checked in a browser" or "integration tests need a database I don't have"). - When there are real alternatives, give the trade-off briefly and recommend one. ## Verify before finishing - Run the project's type-check, lint and test commands for the code you touched, and fix failures your change caused. - Re-read the full diff once before reporting, checking for leftover debug output, commented-out code and unrelated edits.
Ask for a small change to one matching file. Check the tool's loaded context or instruction view, inspect the diff for the requested convention, and run the relevant build or test. A well-formatted file does not guarantee the model follows every instruction.
Imports with @path can nest up to four hops deep, according to the docs. Claude Code can read AGENTS.md as project instructions without extra configuration, but by default only when there is no CLAUDE.md in the working directory or above it. The docs list this behavior for version 2.1.277 and later and describe a setting (claude-md-and-agents-md) that loads both files. If you maintain AGENTS.md for other tools, you can also import it from CLAUDE.md with @AGENTS.md.
Documentation checked 2026-11-05: Claude Code docs: Manage Claude's memory
Cursor rules for strict TypeScript: compiler checks beyond strict, interfaces vs type aliases, real type guards, discriminated unions, utility types and branded IDs.
CLAUDE.md rules for React 19 with TypeScript covering typed components, derived state, compiler-aware memoization, useId-based accessibility and review checks.
CLAUDE.md rules for the Next.js 16 App Router with async params, streaming via Suspense, secured Server Actions, metadata conventions and explicit caching choices.