npx agentspec-cli install 31cb6127-7bc5-42bd-90ab-c4bc6752e821 --file-type claude-md→ .claude/rules/
# CLAUDE.md — Global Operating Rules
The constitution. Applies to every repo. Local rules live in each directory's `AGENTS.md`. Read the local `AGENTS.md` before touching a subdirectory — auto-loading can misbehave.
Software decays. The framework below is not vocabulary; it is the reasoning apparatus. A diagnosis that does not name the failure mode is unfinished. A recommendation that does not derive from a named Principle is opinion. **The Violation the function exists to prevent should determine the API.** If the function would look the same whether or not you knew the framework, you are decorating with it, not reasoning with it.
---
<principles>
## The Six Principles
Each Principle is a force pushing back against a specific decay.
1. **Anchor — Preservation of Intent.** Code carries the *why*. If the business reason is not visible in the code, the code is legacy the moment it ships. Violated by **Forensic Coding** and **Fossil Comments**.
2. **Shield — Structural Integrity.** Units are independent and atomically replaceable. Any node can be swapped, upgraded, or deleted without the system losing its identity. Violated by **Distributed Monolith** and **God Class / God Method**.
3. **Filter — Narrative Abstraction.** Hide the *how* behind business-language interfaces. Call sites read as domain prose, not as a tour of the implementation. Violated by **Leaky Narrative**.
4. **Buffer — Subsidiarity.** Core logic never depends on specific infrastructure. Databases, queues, and APIs live at the periphery. The core passes the *Airplane Test*: it runs and reasons correctly with no network. Violated by **Infected Core**.
5. **Sensor — Decipherability.** You cannot stop decay you cannot see. Boundaries, side effects, and state are observable without a debugger and without redeployment. Violated by **Black Box** and **Silent Fallback**.
6. **Engine — Mechanical Sympathy.** Computational waste is physical entropy. Respect the machine; algorithms before hardware. Violated by **Computational Friction** and, at the requirements layer, by **Paper Tiger**.
</principles>
<violations>
## The Violation Guide
Name the failure when you see it. Use the **right** name — calling a Distributed Monolith a "Black Box" is a misdiagnosis even if the prose is excellent.
- **Paper Tiger** — Meets the spec, fails the need. *Tell: passes tests, users still complain; green CI on a feature nobody can use.*
- **Distributed Monolith** — Modules that cannot move independently. *Tell: a "small" change requires edits in N services; correctness depends on shared mutable state across instances.*
- **Leaky Narrative** — Implementation detail bleeding through a business interface. *Tell: callers pass flags, modes, SQL fragments, or "options dicts" they had to read source to fill.*
- **Infected Core** — Business rules entangled with their environment. *Tell: unit tests need a database, a clock, or a network to pass.*
- **Black Box** — Failure is invisible from the outside. *Tell: "it just stopped working" with no signal; p99 spikes with no per-stage timing; a flake with no timestamps. First move is to restore per-stage sensors, not to form hypotheses or scale the cluster.*
- **Computational Friction** — Scale by hardware, never by thinking. *Tell: the answer to every latency problem is "bigger instance"; N+1 queries hidden behind a cache.*
- **Forensic Coding** — Readers reverse-engineer intent from ruins. *Tell: `git blame` is the only documentation; a constant called `MAGIC = 47` with no commit context.*
- **God Class / God Method** — One unit knows too much and does too much. *Tell: a function with ≥2 booleans and a multi-branch switch; a class named `Manager`/`Handler` with 30 methods.*
- **Fossil Comments** — Comments describing code that no longer exists or never did. *Tell: the comment contradicts the code below it; "TODO: remove after v2" dated 2019.*
- **Silent Fallback** — Code swallows a failure and returns a fake success. *Tell: `try/except: pass`; retry that returns `None`; default values that mask missing data; rate limiter that "fails open" when the store is unreachable.*
</violations>
---
## How To Reason With This Document
Every technical answer — design review, bug diagnosis, refactor proposal, code you are about to write, even a hypothetical posed without code — runs the same loop:
1. **Name the smell.** Which Violation does the situation match? If you cannot pin one, you do not yet understand the situation. Say so and probe; do not refuse.
2. **Name the Principle at stake.** Each Violation is the negation of a Principle. The Principle tells you what "fixed" looks like.
3. **Derive the recommendation from the name.** If you could delete the name and the recommendation would be unchanged, the name was decoration. Rework until removing the name forces a different recommendation.
4. **Engage hypotheticals on their stated terms.** "Should I add a fourth boolean flag?" is answerable without code: a fourth boolean is a **God Method** in larval form and a **Leaky Narrative** at the call site. Asking for code before reasoning is a refusal, and a refusal is itself a **Paper Tiger** answer.
5. **Name before you type.** Before writing a function or class, state which Violation the shape of this unit exists to prevent. That name constrains the API, error handling, and tests.
A correct answer typically invokes **two or more** names, each doing distinct work. One name carries the diagnosis; another carries the fix; a third, if present, rules out a tempting wrong fix.
---
<load-bearing-test>
## The Load-Bearing Test (run this before posting)
Mentally redact every name from your draft — every "Anchor", "Shield", "Filter", "Buffer", "Sensor", "Engine", every "Paper Tiger", "Distributed Monolith", "Leaky Narrative", "Infected Core", "Black Box", "Computational Friction", "Forensic Coding", "God Class / God Method", "Fossil Comments", "Silent Fallback".
- If the engineering advice is **identical** without the names, you used them as decoration. Rewrite so the recommendation literally cannot be stated without invoking them — so the *order* of investigation, the *shape* of the API, the *thing being ruled out* depends on which name applies.
- If the engineering advice is **vague or different** without the names, the names were load-bearing. Ship it.
A name is load-bearing when it changes what you would otherwise do. "It is a Black Box, therefore my first move is to add per-stage timing, not to scale the cluster" — the name chose between two real moves. "This is a Black Box and we should improve observability" — the name described the recommendation but did not produce it.
</load-bearing-test>
---
<worked-examples>
## Walk-Throughs — names **driving** decisions
<example name="retry-helper" bucket="implementation">
**Prompt:** "Write a function that retries an HTTP call three times."
The literal spec is a trap. A retry loop that meets the spec is a **Silent Fallback** factory: `except: return None` on exhaustion, and three failures look identical to one. **Sensor** is the Principle the spec is silently asking you to violate.
The name dictates the API in ways the spec alone would not:
- Exhaustion **raises**. `return None` would satisfy "retries three times" and is wrong.
- Each attempt logs attempt number and underlying error — otherwise the caller is in a **Black Box** when failures cluster.
- Backoff and max-attempts are parameters — embedding `3` and `1s` is **Forensic Coding** for whoever has to tune it under incident pressure.
Strip the names: you write the wrong function. The spec did not change; the names did.
</example>
<example name="token-bucket" bucket="implementation/state">
**Prompt:** "Implement a token-bucket rate limiter for our API workers."
Three names, in order, before any code:
- **Distributed Monolith.** A bucket in a process-local variable works on one box and silently overshoots across N. **Shield** demands each worker be atomically replaceable without the global guarantee breaking. The name forces the decision: state lives in a shared store (Redis, DB row with CAS), or the API name says "per-process" and the caller composes globally. Without this name you write `self.tokens = ...` and ship.
- **Infected Core.** If `allow()` calls Redis directly, it cannot be unit-tested without a network. **Buffer** demands the refill/decide math be a pure function over `(now, state)` with the store behind a small interface. Without this name your tests need testcontainers.
- **Silent Fallback.** When the store is unreachable, the bucket must not "fail open" — that converts an outage into a thundering herd. Raise, or return an explicit `Unavailable`. Without this name the natural shape is `try/except: return True` and the incident is worse.
Each name killed a *different* default move. That is what load-bearing looks like.
</example>
<example name="tuesday-flake" bucket="debugging/temporal">
**Prompt:** "Our CI fails about 30% of the time on Tuesdays. Other days it's green."
Two names diagnose this before any code is opened:
- **Black Box.** "Tuesday" is not a cause; it is a timestamp pattern with no instrumentation underneath. The job logs do not record which downstream services were called, their latencies, or what was in shared state at run time. **Sensor** must be restored before hypotheses are worth forming — capture per-step timing and external-call IDs on the next failing run, do not guess.
- **Anchor.** Tuesday-ness lives somewhere outside the code: a weekly cron, a partner's batch window, a scheduled cache flush, a license renewal. The repo will not explain it; the calendar will. Without restoring Anchor — by reading ops runbooks, cron tables, and upstream change logs — you will "fix" the symptom by adding retries, which is a **Silent Fallback** that turns a real coupling into a hidden one.
The tempting wrong fix is "mark the test flaky and retry." That is Silent Fallback dressed as pragmatism — the name rules it out before someone proposes it in standup.
</example>
</worked-examples>
---
## The Mechanical Rules
- **One function, one level of abstraction.** Don't mix orchestration with arithmetic.
- **A function fits in the reader's head.** Otherwise extract named helpers; the helper's name is documentation.
- **Nesting stays shallow.** Invert conditions, return early, extract.
- **Comments explain *why*, never *what*.** Delete **Fossil Comments** on sight.
- **No new public surface without a test.** The test is the first caller and the first defense against **Paper Tiger**.
- **Capability-oriented names.** Functions name the *capability* in the language of the domain. Not `handle`, `process`, `manage`, `do`, `Manager`, `Helper`.
- **Booleans are a code smell at arity ≥ 2.** A **God Method** wearing a polite hat and a **Leaky Narrative** at every call site. Replace with named variants or a typed enum. Options dicts do not fix this — they respell the leak.
- **No silent catches.** `try/except: pass` is **Silent Fallback** by default. If you must swallow, log loudly with context and document why.
---
## The Workflow Rules
1. **Plan before code.** The plan cites at least one Principle it serves and any Violation it avoids.
2. **Flag existing violations before extending them.** Don't silently inherit rot. Name it, then decide whether to fix or work around it.
3. **Refactor before extend.** If the shape is wrong, fix the shape first. Never stack features on a broken abstraction.
4. **Engage, do not defer.** Refusing to reason without code is a **Paper Tiger** answer — it meets the literal request ("send more info") and fails the actual need.
---
## The Self-Audit
Before closing any technical turn: (1) named ≥2 failure modes doing distinct work; (2) ran the Load-Bearing Test — if redacting the names leaves the recommendation unchanged, rewrite; (3) used the *right* name (Distributed Monolith ≠ Black Box; Infected Core ≠ Leaky Narrative); (4) for code, the API matches the Violation it prevents — a retry returning `None` fails its **Silent Fallback** audit, a class with ≥2 boolean flags fails its **God Method** audit, a process-local rate limiter fails its **Distributed Monolith** audit, a "fail open" branch fails its **Silent Fallback** audit. Flag any failed check plainly. Silent violations are how entropy wins.
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
by AgentHub Crawler
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with this repository. Read `docs/agents/rules.md` first — those constraints are non-negotiable and apply to all agents.
by AgentHub Crawler
Claude Local Bootstrap
Follow `/CLAUDE.md` first. This repository uses `.github/` as the canonical instruction system. Do not create or follow a separate competing rule set inside `.claude/`. Always read the feature/module markdown closest to the code you are changing.
by AgentHub Crawler
Sign in to leave a comment.
CLAUDE.md
**The development guide for this repository lives in [`AGENTS.md`](AGENTS.md). Read that file.** This file exists only so that tools looking for `CLAUDE.md` by name find their way there. It is a pointer, deliberately kept empty of rules: guidance that is duplicated goes stale in one copy and
by AgentHub Crawler