keepcalculator

06 Numbers and Powers

Claude Code Reliability: Rules, Checks, and Plans

Card No. 06·30094 · Updated · Standard formula, shown below

Average pace 5.00 min/km
Average speed
12.00 km/h
Result
Finish time
50 min
You entered
Distance
10 km
You entered
You enter
Finish time, Distance
You get
Average pace, Average speed
Rounding
2 dp

Claude Code can be made significantly more reliable by giving it explicit project rules, automated checks, and a structured plan before it starts working. This article explains how to set up those guardrails, what each layer does, and why the combination prevents most common failures. You’ll learn the practical steps to configure rules, run checks, and plan tasks so Claude Code produces consistent, correct results.

Formula

The calculator above computes average pace and speed from a given finish time and distance. The formulas are:

  • Pace (min/km) = Finish time (minutes) ÷ Distance (km)
  • Speed (km/h) = Distance (km) ÷ (Finish time (minutes) ÷ 60)

Variables:

  • t = finish time in minutes (e.g., 50)
  • d = distance in kilometers (e.g., 10)

Pace is expressed as minutes per kilometer, and speed as kilometers per hour. If you prefer miles, convert distance to miles and pace becomes minutes per mile; speed in mph uses the same formula with distance in miles.

Worked Example

Using the default values (t = 50 minutes, d = 10 km):

  1. Pace = 50 ÷ 10 = 5.00 min/km
  2. Speed = 10 ÷ (50 ÷ 60) = 10 ÷ 0.8333 = 12.00 km/h

The calculator returns pace = 5.00 min/km and speed = 12.00 km/h. This matches the expected result for a 50-minute 10K run.

Why Reliability Matters in Claude Code

Claude Code is an AI coding assistant that can edit files, run commands, and execute multi-step tasks. Without guardrails, it may misinterpret instructions, skip steps, or make changes that break existing code. Reliability issues often stem from ambiguous prompts, lack of context, or no verification step. By providing project rules, automated checks, and a plan, you give Claude Code the structure it needs to work predictably.

For example, a developer might ask Claude Code to “refactor the login module.� Without rules, Claude might change function signatures, forget to update tests, or alter error handling. With a rule like “always run tests after changes� and a plan that lists specific files and expected outcomes, the result is far more likely to be correct.

Setting Up Project Rules

Project rules are instructions that Claude Code follows every time it works in your repository. They are typically stored in a file like CLAUDE.md or .claude/rules.md at the project root. These rules can include:

  • Coding style guidelines (e.g., “use 2-space indentation,â€� “prefer const over letâ€�)
  • Architecture constraints (e.g., “do not import from utils in componentsâ€�)
  • Testing requirements (e.g., “run `npm test` before finishingâ€�)
  • File organization rules (e.g., “keep all API calls in /servicesâ€�)
  • Security practices (e.g., “never log passwords or tokensâ€�)

To create rules, write them in plain language, one per line, and place the file in the project root. Claude Code reads this file automatically when it starts. You can also add global rules in your home directory (e.g., ~/.claude/CLAUDE.md) that apply to all projects. Keep rules specific and actionable; vague rules like “write good code� have little effect.

Adding Automated Checks

Automated checks are commands that verify the codebase before and after Claude Code makes changes. These can be linting, type checking, unit tests, or build scripts. By telling Claude Code to run these checks, you catch errors early. For example:

  • “Run `npm run lint` after any edit to JavaScript files.â€�
  • “Run `python -m pytest` before declaring the task complete.â€�
  • “Run `tsc –noEmit` to check TypeScript types.â€�

You can also integrate checks into the plan itself. For each step, specify the verification command and the expected result. If a check fails, Claude Code should fix the issue and re-run the check. This creates a feedback loop that improves reliability. Some teams use CI/CD pipelines to enforce checks, but having Claude Code run them locally during the session is more immediate.

Structuring a Clear Plan

A plan breaks a task into small, verifiable steps. When you give Claude Code a plan, you reduce ambiguity and make it easier to track progress. A good plan includes:

  1. Objective – what the final result should be.
  2. Steps – each with a specific action and expected outcome.
  3. Checks – commands to run after each step.
  4. Rollback – how to revert if something goes wrong.

For instance, a plan to add a new API endpoint might look like:

  • Create a new route file in /routes.
  • Implement GET and POST handlers.
  • Add input validation using the existing validator.
  • Write unit tests for both success and error cases.
  • Run `npm test` and fix any failures.

You can provide this plan in your initial prompt or ask Claude Code to generate one before starting. When the plan is explicit, Claude Code is less likely to skip steps or go off track.

Common Mistakes and Misconceptions

One common mistake is assuming Claude Code will infer rules from your codebase. It won’t—you must state them. Another is writing rules that are too long or contradictory; Claude Code may ignore or misinterpret them. Keep rules concise and consistent.

A frequent misconception is that automated checks guarantee correctness. They only verify what you test for. If you don’t have tests for edge cases, Claude Code won’t catch them. Also, checks can be slow; running a full test suite after every small edit may be impractical. Instead, run targeted checks for the files you changed, and run the full suite at the end.

Another issue is that Claude Code might modify files outside the scope of the plan. To prevent this, specify which files and directories are in scope, and instruct it to ask before touching anything else. You can also use git to review changes before committing.

Comparing with Other Approaches

Some developers rely on manual code review instead of automated checks. While review is valuable, it happens after the fact and depends on human attention. Automated checks catch issues immediately and are consistent. Others use pair programming with Claude Code without rules, which can work for simple tasks but fails on complex ones. The combination of rules, checks, and a plan is more robust than any single approach.

Another comparison is between using Claude Code’s built-in features (like --review flag) versus external tools. Built-in review can spot some issues, but it doesn’t replace project-specific rules. External linters and test runners are more reliable for enforcing code standards. The best practice is to use both: Claude Code’s review plus your existing toolchain.

Costs and Practical Considerations

Using Claude Code with extensive rules and checks may increase token usage because Claude reads the rules file and runs more commands. However, the cost is usually offset by fewer errors and less rework. There is also a learning curve to write effective rules. Start with a few critical rules and expand based on what issues you encounter.

Performance can be affected if you run heavy checks after every edit. To balance, you can configure Claude Code to run checks only at the end of a task, or use a fast linter during the session and a full test suite at the end. Also, consider using a pre-commit hook to enforce checks before code is committed, providing a safety net.

Safety and Best Practices

Always review the changes Claude Code makes before committing. Use version control (like git) and create a branch for each task. If something goes wrong, you can revert. Avoid giving Claude Code access to production credentials or sensitive data; use environment variables or a secrets manager. Also, be cautious with commands that delete files or modify the database—add explicit rules to require confirmation.

For security-sensitive tasks, never rely solely on Claude Code’s judgment. Run security linters and manual review. If you’re working on a public repository, ensure your rules don’t contain secrets. And remember that Claude Code is a tool, not a replacement for human oversight.

Frequently Asked Questions

Does Claude Code automatically read CLAUDE.md?

Yes, Claude Code looks for a CLAUDE.md file in the project root and reads it at the start of a session. You can also place a CLAUDE.md in your home directory for global rules. The file is plain text and can include any instructions you want Claude to follow.

Can I use multiple rule files?

Yes, you can have a main CLAUDE.md and additional files in a .claude/ directory, such as rules-js.md or security.md. Claude Code will read all of them, but keep them organized to avoid conflicting instructions.

What if Claude Code ignores my rules?

If rules are ignored, check that they are clear and not contradictory. Sometimes Claude Code may misinterpret a rule if it’s ambiguous. Rephrase the rule to be more specific. Also, ensure the rules file is in the correct location and is being loaded—you can ask Claude Code to confirm it read the file.

How do I make Claude Code run checks automatically?

You can include commands in your rules, like “After editing any file, run `npm run lint`.� Or you can specify checks in your plan for each step. Claude Code will execute those commands as part of the task. You can also use a pre-commit hook to enforce checks before code is committed.

Is it better to give a detailed plan or let Claude Code figure it out?

For complex tasks, a detailed plan is better because it reduces ambiguity and prevents missed steps. For simple tasks, a brief description may suffice. If you’re unsure, ask Claude Code to propose a plan first, then review and approve it before it starts.

Can I use Claude Code for code review only?

Yes, you can ask Claude Code to review your code without making changes. Provide the files or diff, and specify what to look for (e.g., bugs, style, security). This is a lighter use case and doesn’t require as many rules, but you can still apply project-specific guidelines.

Related

Formula used
in t | Finish time | min | 50 | 0
in d | Distance | km | 10 | 0 | 100000
out pace | Average pace | min/km | t / d | 2
out speed | Average speed | km/h | d / (t / 60) | 2

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →