Entry file exists
Anthropic: CLAUDE.md is auto-loaded by Claude Code as the entry point. OpenAI: 88 AGENTS.md files, one per subsystem, each as a local entry point.
Entry file describes the project
AI-Friendly Standard: CLAUDE.md answers three questions — what is this, what can I do, what to read first. First paragraph must state what the project does.
Conditional loading guidance
Session Checklist ('if X → read Y') is the single most effective AI-friendly pattern. ETH Zurich found that generic repo overviews hurt performance — targeted loading helps.
Large directories have index
Directories with >10 content files need INDEX for AI navigation. Without it, AI defaults to 'read everything' which fills context with irrelevant content.
All references resolve
Real-world audit found broken references across multiple production projects. Broken links waste AI tokens on dead-end file reads. Codified Context: stale references are a primary failure mode.
Predictable file naming
Standard filenames (CLAUDE.md, AGENTS.md, README.md) are recognized by AI tools. Non-standard names require explicit documentation to be discovered.
Emphasis keyword usage
Across 265 versions: IMPORTANT 12→4, MUST 7→1, NEVER 4→1, VERY IMPORTANT 2→0 (eliminated). Keyword-imperative instructions dropped from 34% to 5% of the system prompt.
Keyword density
Anthropic density: 7.5 rules/1K words (v1.0.0) → 1.4 (v2.1.81). IFScale: at 500 instructions, best model (Gemini 2.5 Pro) scores 68.9%, Claude Sonnet 42.9%. Every instruction weakens every other instruction.
Rule specificity
Anthropic converged on: 'Don't [anti-pattern]. Instead [correct]. Because [reason].' — the golden formula after 265 versions. Agent READMEs study: concrete instructions (F1=0.94) understood 2x better than abstract ones (F1=0.42).
Action-oriented organization
Section titles evolved: Phase 1 'Tone and style' (identity) → Phase 2 'Professional objectivity' (attitude) → Phase 3 'Executing actions with care' (action). All identity sections were deleted.
No identity language
'Following conventions' — an entire 12-line section telling the model to mimic code style — was deleted in v2.0.0. The model already does this without being told. Identity descriptions are dead weight.
Entry file length
Anthropic main agent: 15K-22K token baseline. Codified Context: 660-line constitution (n=1 reference point). IFScale: compliance degrades beyond ~150 instructions. No single 'right' length — measure and compare.
Build/test commands documented
GitHub analysis of 2500+ repos: 'Build and test commands' is one of the 6 core areas of effective AGENTS.md. AI cannot run what it cannot find.
CI exists
Harness Engineering: 'Put rules in CI mechanical checks, not just documentation.' CI is the enforcement mechanism.
Tests exist and are non-empty
Real-world audit found a project with 'uv run pytest' in CI but 0 test files. CI always 'passed' because there was nothing to fail. Empty-shell CI creates false confidence.
Linter configured
Harness Engineering: 'Configure code format enforcement in CI.' Linters catch style issues mechanically so AI doesn't need to guess conventions.
Document freshness
Codified Context: stale content is the #1 failure mode — 'not missing rules, but rules that were once correct and no longer are.' Harness Engineering: 'CI Job checks document freshness relative to code.'
Handoff information exists
Anthropic: 'Structured progress files that let a new agent quickly understand the state of work.' Without handoff, every new session starts from zero.
Changelog has why
'Updated INDEX.jsonl' tells a future session nothing. 'Fixed broken file path — entry referenced old directory structure' tells it what happened and whether it's relevant.
Plans in repo
Harness Engineering: 'Plans in Jira, Confluence, Slack — for Agent, these don't exist.' Plans must be in the repo as first-class artifacts.
CLAUDE.local.md not tracked
Claude Code behavior: CLAUDE.local.md is for per-user private preferences. If tracked in git, all team members share private overrides. CC's /init explicitly recommends adding it to .gitignore.
Env files gitignored
Claude Code behavior: Glob tool defaults to CLAUDE_CODE_GLOB_NO_IGNORE=true, meaning .env files are visible to AI even if gitignored at grep level. Corpus analysis: 57 of 4533 repos have .env committed to git.
Actions SHA pinned
Corpus analysis: 58% of repos use floating tags for GitHub Actions. A compromised tag can steal CI secrets when AI pushes code. SHA pinning makes actions immutable.
Secret scanning configured
Corpus analysis: 98% of repos have no gitleaks config or pre-commit secret scanning. AI agents don't self-check for accidentally written secrets.
Security policy exists
Corpus analysis: 92% of repos have no SECURITY.md. Without it, AI has no reference for security-sensitive decisions and users have no vulnerability reporting channel.
Workflow permissions minimized
Workflow-level contents:write grants write access to every job. AI-triggered workflows should use job-level permissions with minimal scope.
No hardcoded secrets
Hardcoded API keys, tokens, and private keys in source code are the most common credential leak vector. AI agents may copy-paste patterns with embedded secrets.
No personal paths in source
Personal filesystem paths (/home/dev/, /home/xxx/) in source files reveal developer identity. Claude Code behavior: Glob tool defaults to ignoring .gitignore, making these paths visible to AI. AI copy-paste patterns spread leaked paths to new files.
No pull_request_target trigger
Workflows using pull_request_target run with write access and secrets from the base branch. AI agents push code and create PRs frequently, increasing exposure to this attack vector. A malicious PR can execute arbitrary code with elevated permissions.
Entry file size within limit
Claude Code behavior: MAX_MEMORY_CHARACTER_COUNT = 40000. CC's built-in /doctor command warns when any single memory file exceeds 40,000 characters. Large files dilute instruction priority.
Include directives resolve
Claude Code behavior: @include paths that don't exist are silently ignored — no error, no warning. The user thinks the content is loaded but it isn't. CC supports @path, @./relative, @~/home syntax.
No oversized source files
Claude Code behavior: FileReadTool hard limit is 256 KB (MAX_FILE_SIZE). Files exceeding this cause a hard error — CC cannot read them at all. Common culprits: generated files, minified JS, large SQL schemas.
Pre-commit hooks are fast
Claude Code behavior: CC is instructed to NEVER skip hooks (--no-verify). If a pre-commit hook is slow (>10s) or flaky, CC's commit workflow stalls visibly. CC will retry indefinitely on hook failure.
Local fast test command documented
AI agents need a single, fast, documented command to run before pushing. Without it, agents either skip local verification or invoke the full slow CI suite. Observed pattern: gstack documents 'bun test' at top of CLAUDE.md; all 4 audited repos were missing this and had to add it manually in a single session.
npm test script exists (JS/Node projects)
For Node.js projects, the absence of 'scripts.test' in package.json means there is no canonical test entry point. AI agents attempting 'npm test' get 'missing script: test'. Observed: agent-lint shipped without this for its entire history; fixed when explicitly audited.
Contradictory rules
When the same rule exists at two levels with different wording, AI averages the signals instead of choosing one, producing unpredictable behavior.
Dead-weight rules
Deletion test: 'Follow coding conventions' deleted because model already does this. Four conditions must hold: model can't self-derive, prevents real failure, has decision boundary, doesn't create worse edge cases.
Vague rules without decision boundary
'Follow security best practices' was deleted — no decision boundary. Agent READMEs: abstract instructions (F1=0.42) understood at half the rate of concrete ones (F1=0.94).
Repeated instructions
Claude Code /insights: 'PRIORITIZE instructions that appear MULTIPLE TIMES in user data. If user told Claude the same thing in 2+ sessions, that's a PRIME candidate for CLAUDE.md.'
Ignored rules
A rule that exists in CLAUDE.md but is repeatedly violated in sessions may be too abstract, poorly worded, or conflicting with another rule. Signal for rewriting, not deleting.
Friction hotspots
Claude Code /insights friction_analysis: categorized friction by type (misunderstood_request, wrong_approach, buggy_code, excessive_changes). File/directory level aggregation reveals structural issues.
Missing rule suggestions
Claude Code /insights claude_md_additions: 'A specific line or block to add to CLAUDE.md based on workflow patterns.' Derived from user corrections and repeated instructions.
Hook event names valid
Corpus analysis: 35+ unique invalid event names across ~50 repos. Common: preCommit (git hook name, not Claude hook), sessionStart (wrong casing), postEditHook (invented). Invalid hooks silently never fire — users believe they have protection but don't.
PreToolUse hooks have matcher
Corpus analysis: 248/273 (91%) PreToolUse hooks lack tool_name filtering (no matcher field). Every Read, Glob, Grep call triggers the hook — massive performance tax on routine operations.
No dangerous auto-approve
Corpus analysis: 85 repos auto-approve bare Bash (any command), 7 repos approve * (everything), 50 repos auto-approve financial MCP tools, 13 repos use mcp__* wildcard. Bare Bash auto-approve is equivalent to giving the agent root shell access.
Stop hook has circuit breaker
Corpus analysis: only 5/92 Stop hooks have loop protection. Stop hook exit non-zero → Claude continues → triggers Stop again → infinite loop. Circuit breaker pattern: guard variable (STOP_HOOK_ACTIVE) checked at script entry.
Env deny coverage complete
Corpus analysis: 88 repos deny Read(./.env), but only 78 cover .env.* variants (.env.local, .env.production). Partial deny creates false sense of security — the most sensitive env file variants remain readable.
Hook scripts network access
Corpus analysis: 5 repos have hooks that POST tool call input/output to external servers via curl/wget/fetch. This is a data exfiltration vector — tool calls may contain source code, credentials, or user data.
Gate workflows are blocking (not warn-only)
Observed in production CI audits: gate workflows configured in warn-only mode exit 0 regardless of test or lint outcome, blocking zero regressions. A gate workflow that always exits 0 provides no enforcement — it only creates false confidence. Gate workflows must have a failure path that exits non-zero.
No personal email in git history
Observed incident: 5 commits with a personal Gmail address in a public repo's git history. Git history is permanent and publicly visible — author email in commits is a PII leak even if the current source code is clean. Pre-commit author identity hooks prevent new leaks but don't retroactively clean history.
Rule file frontmatter uses globs
Corpus analysis: 26.8% of .claude/rules/*.md files use paths: frontmatter instead of globs:. Claude Code's documented field is globs: — paths: may silently not apply the rule to intended files.
No unfilled template placeholders
Corpus analysis: 13% of CLAUDE.md files (419/3225) contain unreplaced template placeholders such as [your project name], <framework>, or TODO: markers. These waste context tokens and may confuse the agent about the project's actual identity.
Total injected content within budget
Corpus analysis: total injected content (CLAUDE.md + AGENTS.md + rules/*.md) median is 116 non-empty lines, outliers reach 1000+. IFScale research shows instruction compliance degrades beyond ~150 instructions. The right metric is total injected content across all files, not just entry file length.
Release workflow validates version consistency
Production multi-repo release audits show that workflows validating the git release tag against package manifests (pyproject.toml, package.json) catch version drift before publish. Workflows that only check tag regex (vX.Y.Z) silently ship mismatched packages. Triple-check: extract tag, compare against source manifest, fail with ::error:: on mismatch.
Test cost tiers defined (pytest markers)
Production Python repository audits show that defining at least 3 pytest marker tiers (such as unit, smoke, and slow/network/live) lets AI agents run sub-5-second unit suites locally. Without cost tiers, every test invocation hits slow network or external APIs — causing agents to stall or skip verification. PR CI runs fast unit tests while nightly CI runs live integration markers.
feat/fix commits paired with test commits (test-required gate)
Production CI audits show commit-type gating (requiring test coverage when feat/ or fix/ commits land in a PR) prevents untested features from merging silently. File-change heuristics have high false positives; commit-subject or test-diff gating with an explicit opt-out checkbox is precise and reproducible via .github/workflows/test-required.yml.
Hook errors use structured format (what/rule/fix)
Production git and Claude Code hook audits show that emitting structured error output (what failed, which rule triggered, and the exact fix command) lets coding agents self-correct immediately. Unstructured one-line hook failures force agents to guess or read hook source code, multiplying retry loops.
HANDOFF.md contains verify conditions (not just status)
Production multi-session audits show that handoff notes containing explicit runnable verification evidence (passing test counts, command outputs, concrete completion criteria) let the next agent session resume without re-auditing the entire repo. Plain status text ('in progress', 'looks good') cannot be verified and triggers redundant full scans.