확인할 수 있는 Claude 코드에 대한 CLAUDE.md 규칙

작성자

카테고리:

← 피드로
DEV Community · Adela · 2026-08-20 개발(SW)

BetterToken.ai profile image Adela

CLAUDE.md Rules for Claude Code That You Can Check

A long list of preferences does not make Claude Code predictable. A useful project rule says what the agent may do, what it must avoid, and which command or diff proves the result. If the workflow uses an API, open the current BetterToken Claude Code guide, configure your own API key, and run a short check: Dashboard should show the expected model, status, and token usage. Keep the key in the environment, not in CLAUDE.md.

Start with a small contract

# Project rules

## Goal
- Keep changes limited to the requested feature.

## Before editing
- Read package.json and the files named in the task.
- Do not read or print .env files.

## Checks
- Run `npm test` after code changes.
- Run `npm run lint` when TypeScript files change.
- Report each command, its exit code, and every changed file path.

## Scope and conflicts
- Rules in `packages/payments/CLAUDE.md` apply only under `packages/payments/`.
- Inside that directory, the local rule wins when it directly conflicts with this root file.
- Root security and secret-handling rules always apply.

## Forbidden
- Do not run deploy, publish, or destructive Git commands.

Enter fullscreen mode Exit fullscreen mode

Each line has an observable result. “Write quality code” does not; “run npm test and report its exit code” does.

Separate goals, boundaries, checks, and style

Use a goal for the requested outcome, a boundary for files or commands that are off limits, a check for a reproducible command, and a style rule only when it affects review. If a command is not present in package.json, do not invent it. Move long explanations and exception lists to documentation with a link from CLAUDE.md.

Keep secrets out

CLAUDE.md is part of the repository and is read with the project. Never put API keys, CI tokens, real personal data, or copied API responses in it. State the boundary instead:

- Never open, print, or commit `.env`, `*.pem`, or `secrets/`.
- Use `API_KEY=your_api_key_here` in examples.

Enter fullscreen mode Exit fullscreen mode

Pass a real key through an environment or secret store when a test needs one. Do not paste it into a prompt or handoff.

Resolve scope and conflicts

The current Claude Code memory documentation defines how instructions at different scopes are discovered. In this article’s sample, “local package rules may override ordinary root rules, but not root security rules” is a project-authored contract, not a universal built-in Claude Code exception. When files disagree, inspect the instructions visible to the target file and remove the duplicate.

Test one rule on a reversible task

Test one rule with a reversible task:

  1. Ask Claude Code to rename one local variable in a test file.
  2. Run git diff --check and inspect git diff --stat.
  3. Execute the test command from CLAUDE.md.
  4. Reject the result if another file changed or the command was not run. This isolates the rule from a large project plan.

Sources

Originally published on the BetterToken blog.

BetterToken provides pay-as-you-go access to AI model APIs through
OpenAI-compatible and Anthropic-compatible endpoints — useful if you are wiring
Claude Code, Codex, or your own tooling to a custom base URL.
See the docs to get started.

원문에서 계속 ↗