Notebook
Note
Download Markdown

Sample CLAUDE.Md File

9 min read

Global Instructions

I am not a developer. I build projects by describing what I want in plain language. Treat me as a smart, capable person who does not know programming terminology or conventions. These rules apply to every project.

For full personal context, business details, team info, and preferences, read ~/Claude-Memory/CLAUDE.md and the sub-files it points to.

Security (Critical)

API Keys and Secrets

Package Installation — How to Report Findings

A hook intercepts every npm install, npm i, pnpm add, pnpm install, pnpm i, yarn add, pip install, and pip3 install command and runs a Socket.dev security check before anything installs. When the hook blocks an install and returns findings, report them in this format:

Package: [name] What it does: [one sentence] Weekly downloads / last updated: [from Socket.dev or web] Socket.dev findings: [exact output from the hook, in plain English] Verdict: SAFE / CAUTION / DO NOT INSTALL / UNVERIFIED Reasoning: [plain English, no jargon]

Then stop and wait for me to type “yes, install it” or “go ahead.” Do not retry the install for any other reason.

If Socket.dev was unreachable and returned no data, your verdict must be UNVERIFIED — search the web for “[package name] security vulnerability” and “[package name] supply chain attack,” include what you find, and still wait for my approval.

Automatic DO NOT INSTALL Triggers

If any of these are present, verdict must be DO NOT INSTALL and you must tell me why before asking anything:

Transitive Dependencies

If installing Package A also pulls in B and C automatically, check all of them. If you can’t feasibly check them all, list every package that will be installed and tell me before proceeding.

Scripts and Network Requests

Safety and Confirmation

Code Quality

Project Organisation

Three roots: ~/Code, ~/AI-Work, ~/CoWork

My work splits across three folders that share one relative path, so swapping the root gets you the matching half — no lookup needed. ~/Code/Project A/ pairs with ~/AI-Work/Project A/.

Read access to ~/AI-Work and ~/CoWork is granted once in ~/.claude/settings.json, so no folder needs adding to any project.

Never put client data or any non-code files in ~/Code. A folder there can be committed and pushed by accident; ~/CoWork cannot. Never git init anything inside ~/CoWork.

Dependencies and Packages

Error Handling

Backup and Recovery

Memory

At the end of each session, write a 5–8 bullet summary of what was completed and what’s still pending to context-log.md in the project root. Create the file if it doesn’t exist.

One event, one home

Writing the same event into four files gives you four accounts that drift apart as the code moves on. Each kind of record has exactly one home:

What you’re recordingWhere it goes
What this session didcontext-log.md
How the system works nowTECHNICAL_DOCUMENTATION.md — state, never history
A deploy and its post-mortemdeploy-log.md
A standing rule, or a trap that would cost another incidentCLAUDE.md

A file that accumulates dated ## headings is in the wrong shape. A manual whose sections are dates is a changelog wearing a manual’s name — ask it “how does login work?” and you get every historical account to reconcile instead of one answer.

Keep this file small

CLAUDE.md is prepended to every session, so anything appended here is paid for on every future run, forever. Ceiling ~25 KB, target under 200 lines — past that, adherence drops as well as budget. Only two things earn a place: a rule that changes what a future session may do, or a trap that would otherwise cost another incident. Corrections replace the wrong text rather than sitting beside it; git holds the history. Run wc -c CLAUDE.md before you commit.

Two mechanisms genuinely defer cost, and @import is not one of them — imports load at launch, so they organise without saving anything. Skills load only when invoked, and .claude/rules/*.md with paths: frontmatter load only when a matching file is read.

⚠️ Never move a safety rule into a path-scoped rule file to shrink this one. Path-scoped rules are not re-injected after /compact, while a project-root CLAUDE.md is. A long autonomous run compacts repeatedly, so a permission boundary or deploy guardrail moved there would silently stop applying part-way through — a control that reads as enforcement and executes nothing. Fine for file-type conventions, never for rules.

Never load a log file at session start

Two hooks assist, and neither blocks — both only print. session-snapshot.sh (SessionStart) prints about 1.4 KB of computed state: branch, uncommitted count, recent commits, recent session titles sorted by date, and any open ## Needs Human items. It never opens a log file. session-log-check.sh (Stop) measures what the session actually appended and reports one of: nothing written, more than 4 KB written, or the live log past 150 KB so rotation is due.

No context log is auto-loaded. Open one yourself when you need prior-session history — and never read it whole. A 250 KB log costs roughly 62,000 tokens to read, half a context window, to find one paragraph. Instead:

  1. grep -n '^## ' context-log*.md — the index. Every entry is a dated heading. The * is load-bearing in any project that has rotated: without it you silently stop at the current period and still get results.
  2. Read only that line range, or grep -n -i '<term>' context-log*.md to search by topic and read around the hits.

Sort that index by date, not by position — sessions append to both the top and the bottom of these files, so head or tail alone can miss the newest entry.

Rotation. When context-log.md passes ~150 KB, or at a quarter boundary, move the oldest complete period into context-log-<YYYY>-Q<n>.md beside it at the project root — flat, never a subdirectory, because entries contain relative links that a depth change would break. Archives are frozen; append only to context-log.md. Two things to check before your first rotation, both of which fail silently, are in the memory note.

Skills

Agent Team Policy

Propose an agent team when: the task has 3+ clearly independent workstreams, parallel research benefits from multiple perspectives, or changes cross layers (frontend + backend + tests).

Do NOT spawn a team for: tasks under ~30 min of single-agent work, same-file edits, or sequential tasks with hard dependencies.