Skip to main content
rule CX Codex

context-discipline — Claude Code rule: what it does, how to install

The context-discipline rule sets limits for file reads, tool calls, and test-driven edits. It helps keep Claude Code from reopening unchanged files or polishing code after tests pass.

MIT ★ 2,966 updated 2026-09-29

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/context-discipline.mdc
Open on GitHub

What context-discipline does

Claude Code reads a file and its tests before coding. It avoids rereading files unless they have changed. For simple or medium tasks, the rule calls for a complete implementation in one pass, one test run, and a stop when tests pass. It also caps attempts to fix the same failure at two.

Tool-call budgets are 20 for a quick fix, 30 for a bug fix, 50 for a feature, and 80 for a large feature. At 80% of the budget, wrap up the current task. Use plan mode for changes to more than 3 files, architecture decisions, or unclear requirements. The rule also asks Claude Code to compact context at task boundaries and keep fewer than 10 MCP servers and fewer than 80 tools enabled. The 80-call ceiling can constrain work on a large feature.

What it helps with

  • avoid rereading unchanged files
  • inspect tests before implementing code
  • stop editing once tests pass
  • set a tool-call budget for a task
  • plan changes across more than 3 files

Example prompts for the agent

  • Fix this bug after reading the affected files and tests; stop once the tests pass.
  • Change more than 3 files: plan the work first and track tool calls against the budget.
  • Ask a subagent to inspect the logs, then summarize its findings before making changes.

How to install context-discipline

Manually: put the files in place

.cursor/rules/context-discipline.mdc

Frontmatter: description, globs, alwaysApply

Step by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules

Questions about context-discipline

How do I install context-discipline in Claude Code?

Run /plugin marketplace add rohitg00/pro-workflow, then /plugin install pro-workflow@pro-workflow. Place the rule file at .claude/rules/context-discipline.md.

What does context-discipline do?

It sets a workflow for reading files and tests, editing code, and limiting tool calls. It also defines when to use plan mode and compact context.

When does context-discipline call for plan mode?

Use plan mode when a change touches more than 3 files, involves an architecture decision, or has unclear requirements.

Source text

context-discipline.mdc · MIT
---
description: Manage AI context window efficiently - read before write, no re-reads, tool-call budgets, one-pass discipline
alwaysApply: true
---

Read before write: always read a file before editing or writing it. Never modify a file you have not read in this session.

No re-reads: do not re-read a file already read in this session unless it was modified since the last read.

One-pass coding: for simple-to-medium tasks, write the complete solution in one pass. Run tests once. If tests pass, stop immediately. Do not refactor, improve, or polish passing code. Never iterate more than twice on the same failure.

Tool-call budgets: track tool calls per session. Quick fix: 20 calls. Bug fix: 30. Feature: 50. Large feature: 80. At 80% of budget, wrap up current task.

Use plan mode for changes touching more than 3 files, architecture decisions, or unclear requirements.

Compact context at task boundaries: after planning, after completing a feature, when switching domains.

Keep MCP servers under 10 enabled and total tools under 80.

Use subagents to isolate high-volume output (test runs, log analysis, documentation searches).

Summarize exploration findings before acting on them.

Read tests before coding: understand what the tests assert before writing implementation code.

© Rohit Ghumare · MIT · rohitg00/pro-workflow

Similar IDE rules

All IDE rules for Agent setup: memory, context, orchestration →

From the same set83

The whole set →

Project sponsors

Companies that keep this analytics open