Skip to main content
prompt GP ChatGPT

read_discipline — Claude Code prompt: what it does, how to install

read_discipline is a prompt for Claude Code and ChatGPT that forces targeted shell file reads. It keeps context compact by replacing wide file reads with scoped rg and sed ranges.

MIT ★ 341 updated 2026-11-17

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/commands/read_discipline.md
Open on GitHub

What read_discipline does

The prompt instructs the agent to read source code, tests, schemas, and configurations through targeted terminal commands. It mandates searching with rg using surrounding context lines and opening narrow ranges around matches with sed, typically capped at around 80 lines.

Re-reading entire files to check already inspected lines is prohibited, as is speculative file opening for symbol references. Full-file reads remain allowed only for orientation documents such as README.md, CLAUDE.md, and AGENTS.md. Execution relies on having ripgrep and sed available in the environment.

What it helps with

  • reduce context token consumption during code inspection
  • search codebases with contextual rg output
  • open bounded line ranges using sed
  • prevent redundant full-file re-reads by agents

Example prompts for the agent

  • Investigate the auth module using read_discipline rules
  • Trace database config keys using scoped rg searches
  • Inspect failing tests without pulling entire files into context

How to install read_discipline

Manually: put the files in place

.claude/commands/read_discipline.md

Questions about read_discipline

How to install read_discipline in Claude Code?

Save the prompt text into .claude/commands/read_discipline.md inside your project root.

What does read_discipline do?

It enforces narrow file reads up to roughly 80 lines using sed and contextual searches via rg. This prevents context bloat from broad file inspection.

What is required to run read_discipline?

The agent environment requires command-line utilities rg (ripgrep) and sed installed in PATH.

Source text

read_discipline.md · MIT
<read_discipline>
You read files through shell commands. Read narrowly: wide blind reads waste
context and slow the run. Follow these rules whenever you search or inspect
source files, schemas, tests, configs, or diffs.

1. Search with context, not bare line numbers. Prefer
   `rg -n -B<n> -A<n> "<pattern>" <path>` so each match arrives with nearby
   lines in one call. Do not follow a successful `rg` with a wide file read just
   to see the match again.

2. Read targeted windows. When you need to open a file, anchor the window to the
   line `rg` reported: `sed -n '<N-20>,<N+40>p' <path>`. Do not open
   `sed -n '1,260p'` to inspect one symbol. Keep source-code reads to roughly
   80 lines or fewer unless you have a concrete reason to read more.

3. Do not re-read. Keep the line numbers and ranges you have already seen. If
   you need the same spot again, re-open only that narrow range. Do not re-pull
   the whole file to relocate something you already found.

4. Whole-file reads are expected for orientation docs: README.md, AGENTS.md,
   CLAUDE.md, and any configured knowledge-directory files your stage instructs you to
   read in full. Review-stage untracked files are also exempt when the review
   prompt requires reviewing them as fully added files. Rules 1-3 govern source,
   schema, config, test, and tracked-diff inspection.

5. Trace references with search, not speculative reads. To find usages of a
   symbol or config key, run another scoped `rg` across the relevant directory
   instead of opening candidate files broadly.
</read_discipline>

© rudderlabs · MIT · rudderlabs/devbox

Similar prompts

All prompts for Agent setup: memory, context, orchestration →

From the same set4

Project sponsors

Companies that keep this analytics open