claude-best-practices
Skill0 starsChanged 34 days agoMITView on GitHub
Work efficiently in Claude Code so usage limits last: short focused sessions, small context, lean always-on context, cheap tool use and clean hand-offs. Use at the start of every session, when a session has run for hours or the context is large, when the user mentions /usage, limits, cost or slowness, before starting a big multi-part build, and when switching to a new task.
In this repository68 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- accessibilitySkill
- api-designSkill
- api-versioningSkill
- authSkill
- background-jobsSkill
- cachingSkill
- capacity-planningSkill
- changelogSkill
- chaos-engineeringSkill
- ci-cdSkill
- circuit-breakerSkill
- code-commentsSkill
- code-hygieneSkill
- code-reviewSkill
- code-structureSkill
- commit-styleSkill
- concurrency-and-lockingSkill
- database-transactionsSkill
- data-consistencySkill
- debug-infra-startupSkill
- debug-sessionSkill
- demo-video-creatorSkill
- demo-video-script-creatorSkill
- dependency-injectionSkill
- dependency-updateSkill
- disk-cleanupSkill
- distributed-tracingSkill
- dockerSkill
- env-configSkill
- env-setupSkill
- error-handlingSkill
- event-driven-architectureSkill
- feature-flagsSkill
- file-storageSkill
- graceful-shutdownSkill
- idempotencySkill
- input-validationSkill
- jars-engineering-blogsmithSkill
- jars-workshop-builderSkill
- licensingSkill
- loggingSkill
- memory-and-allocationsSkill
- migrate-dbSkill
- monitoringSkill
- multi-tenancySkill
- notificationsSkill
- openapiSkill
- paginationSkill
- perf-profileSkill
- pr-descriptionSkill
- query-optimizationSkill
- rate-limitingSkill
- refactorSkill
- releaseSkill
- runbook-writerSkill
- searchSkill
- secrets-auditSkill
- simplifySkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
17 rules. About 0 are common, 9 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 30
Correctness first: Never skip a test, a check or a warning to save tokens.
- Distinctive: line 34
Say it once: When a session should end, be cleared or be compacted, tell the user in one line with the reason.
- Very specific: line 41
One task per session: Start a new session (or /clear) when the task changes.
- Very specific: line 43
Compact before it is big: Run /compact with a focus when the context passes about half of the window, for example /compact keep the plan, …
- Distinctive: line 45
Do not wait for automatic compaction at the very end.
- Very specific: line 48
Keep always-on context lean: Run /context to see what is loaded on every request.
- Very specific: line 49
Keep CLAUDE.md files short (rules, not essays), disable MCP servers you are not using in /mcp, and uninstall plugins and skills you never …
- Very specific: line 51
Check
/usageonce a day: If one pattern dominates, fix that habit first. - Distinctive: line 57
Read only what the task needs: the repo's AGENTS.md or CLAUDE.md, then the files the task touches.
- Very specific: line 59
If the request bundles several unrelated jobs, say so and suggest doing them in separate sessions, or finish one, write a hand-off, and let …
- Distinctive: line 64
Search first, then read: use grep or glob to find the place, then read that range with an offset and limit, not the whole file.
- Distinctive: line 66
Never re-read a file you just wrote or edited.
- Very specific: line 67
Do not paste large outputs into the conversation.
- Distinctive: line 78
Run long commands (test suites, builds, servers) in the background and wait for the notification.
- Distinctive: line 80
Verify once, at the right level: run the relevant tests after a change, the full suite before a commit.
- Distinctive: line 82
Keep replies short: what changed, what was verified, what is next.
- Very specific: line 97
Write it to a file in the repo (for example docs/handoff.md, or the scratchpad) so the next session can read it in one call:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Claude best practices
Same work, a fraction of the usage.
Usage limits are spent per request, and every request sends the whole conversation so far plus everything that is always loaded. So the cost of a session grows with how long it has run and how much context it carries, not only with how hard the task is. A one-line question asked at 200k tokens of context costs far more than the same question in a fresh session.
/usage shows what drives your usage. The three patterns it most often reports:
What /usage says | What it means | The fix |
| most usage came from sessions active for 8+ hours | one long session doing many unrelated tasks | one task per session; /clear between tasks |
| most usage was at more than 150k context | every request resends a huge history | /compact mid-task, hand off and start fresh |
| a share went to always-on context over 40k tokens | CLAUDE.md, MCP tools, skills and memory ride on every request | trim them; turn off what you do not use |
Ground rules
- Correctness first. Never skip a test, a check or a warning to save tokens. Saving comes from not repeating work, not from doing less of it.
- The user's and the repository's rules win. This skill changes how work is paced and carried, never what is required.
- Say it once. When a session should end, be cleared or be compacted, tell the user in one line with the reason. Do not nag.
For the user: five habits
- One task per session. Start a new session (or
/clear) when the task changes. A finished feature, a new repo, "now let's do X": all are new sessions. - Compact before it is big. Run
/compactwith a focus when the context passes about half of the window, for example/compact keep the plan, the open decisions and file paths. Do not wait for automatic compaction at the very end. - Hand off instead of dragging on. For multi-day work, ask for a hand-off note (below),
save it in the repo,
/clear, and start the next session from the note. - Keep always-on context lean. Run
/contextto see what is loaded on every request. KeepCLAUDE.mdfiles short (rules, not essays), disable MCP servers you are not using in/mcp, and uninstall plugins and skills you never call. - Check
/usageonce a day. If one pattern dominates, fix that habit first.
For the agent: how to work
Start of a session
- Read only what the task needs: the repo's
AGENTS.mdorCLAUDE.md, then the files the task touches. Do not tour the codebase "for context". - If the request bundles several unrelated jobs, say so and suggest doing them in separate
sessions, or finish one, write a hand-off, and let the user
/clearbefore the next.
Reading and searching
- Search first, then read: use grep or glob to find the place, then read that range with an offset and limit, not the whole file.
- Never re-read a file you just wrote or edited. The tools tell you when they fail.
- Do not paste large outputs into the conversation. Filter command output (
tail,grep,--quiet,-q) to the lines that answer the question. - For a broad search across many files where only the answer matters, a subagent keeps the main context small. It still uses tokens, so do not spawn one for a lookup that a single grep answers.
Doing the work
- Batch independent tool calls in one turn. Write related files in one turn.
- Plan big builds before writing code: list the pieces, agree on them in one exchange, then build without back-and-forth.
- Run long commands (test suites, builds, servers) in the background and wait for the notification. Never poll with sleep loops.
- Verify once, at the right level: run the relevant tests after a change, the full suite before a commit. Do not re-run a suite that just passed when nothing changed.
- Keep replies short: what changed, what was verified, what is next. No narration of every step, no repeating the plan back.
When the session gets long
Watch for these signs, and when one appears, tell the user once:
- the task the user asked for is done and a new, unrelated one starts
- the conversation has been compacted before, or holds many large outputs
- you are re-deriving facts that were settled earlier
Then offer a hand-off.
The hand-off note
Write it to a file in the repo (for example docs/handoff.md, or the scratchpad) so the next
session can read it in one call:
# Hand-off: <task>, <date>
## Goal
One or two sentences.
## Done
- What is finished, with commit hashes.
## Next
1. The next concrete step.
## Decisions
- Choices already made, and why, so they are not reopened.
## Facts
- Paths, commands, ports, versions and gotchas the next session needs.Then tell the user: "Saved a hand-off to <path>. Run /clear and start the next session with:
read <path> and continue."
Checklist
- One task in this session; unrelated work goes to a new one.
- Context compacted with a focus before it got huge.
- Files searched before read, read in ranges, never re-read after editing.
- Independent tool calls batched; long commands in the background.
- Tests run once at the right level; no repeated passing runs.
- Replies short; no step-by-step narration.
- Hand-off written before a long session ends.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

