{"id":8330,"date":"2026-09-21T00:36:07","date_gmt":"2026-09-21T00:36:07","guid":{"rendered":"https:\/\/robertjwallace.com\/?p=8330"},"modified":"2026-09-21T00:36:08","modified_gmt":"2026-09-21T00:36:08","slug":"using-claude-code-efficiently","status":"publish","type":"post","link":"https:\/\/robertjwallace.com\/es\/using-claude-code-efficiently\/","title":{"rendered":"Using Claude Code efficiently"},"content":{"rendered":"<p class=\"wp-block-paragraph\">I am working on a flight simulator game and claude code has been great.  But I just exceeded my usage limits.  Now I know I was not being very smart in how I use claude code.   Basically it was one long conversation spanning days.  So having a recursive set of mind, I asked AI what I should do.  <\/p>\n\n\n\n<!--more-->\n\n\n\n<p class=\"wp-block-paragraph\">For fun, I installed another agent, openclaude and linked it to a free LLM from openrouter.  I then  asked claude:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-style-default is-layout-flow wp-block-quote-is-layout-flow\"><\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">I want a prompt that instructs llama to inspect a claude code project and write a claude.md file so that claude is more efficient and doesn&#8217;t use up usage<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Here is what claude gave me:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Here&#8217;s a prompt built around the &#8220;keep it short, only include what Claude can&#8217;t infer&#8221; principle \u2014 that&#8217;s what actually saves tokens\/usage, since Claude reads CLAUDE.md in full every session.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>You are analyzing a software repository to write its CLAUDE.md file \u2014 the persistent context file that Claude Code reads in full at the start of every session in this project. Your goal is to make future Claude Code sessions faster and cheaper by front-loading only the things Claude cannot reliably infer by reading the code itself, so it stops re-discovering the same facts and burning usage on exploration.\n\nSTEP 1 \u2014 INSPECT THE REPOSITORY\nBefore writing anything, gather:\n- Root-level structure and purpose of top-level directories\n- Language(s), framework(s), and exact versions (from package.json \/ pyproject.toml \/ go.mod \/ Cargo.toml \/ etc.) \u2014 not \"Next.js\" but \"Next.js 15.1\"\n- Build, dev, test, lint, and typecheck commands \u2014 read package.json scripts \/ Makefile \/ justfile, don't guess\n- How to run a single test (not just the whole suite)\n- Existing CONTRIBUTING.md, README.md, .editorconfig, linter\/formatter configs \u2014 extract rules from them\n- Any non-standard architectural decisions, monorepo\/workspace layout, or unusual folder conventions\n- Environment variables or local setup steps required to actually run the project\n- Git conventions already in evidence (branch naming, commit message style, PR template)\n- Anything that would surprise a competent engineer familiar with this stack \u2014 gotchas, footguns, \"don't touch this file\" type constraints\n- Existing CLAUDE.md, AGENTS.md, or .cursorrules if present \u2014 treat as a starting draft, not gospel; verify claims against the actual code\n\nSTEP 2 \u2014 APPLY THIS FILTER TO EVERYTHING YOU FOUND\nFor every candidate line, ask: \"Would removing this cause Claude to make a mistake or waste a tool call re-deriving it?\" If no, cut it.\n\nInclude:\n- Commands Claude can't guess (custom scripts, non-default test runners, monorepo-specific invocations)\n- Code style\/conventions that deviate from the language\/framework defaults\n- Testing instructions and how to run a single test\n- Repo etiquette: branch naming, commit format, PR rules\n- Architecture decisions and *why* (not just what) where it's non-obvious\n- Environment quirks and setup gotchas\n- Known traps: things that look fine but break something (e.g. \"don't edit generated\/*.ts, it's overwritten by codegen\")\n\nExclude:\n- Anything Claude can determine by reading the code in under one tool call\n- Standard language\/framework conventions Claude already knows\n- File-by-file descriptions of the codebase\n- Detailed API documentation (link to it instead)\n- Information likely to go stale fast (current sprint status, temporary TODOs)\n- Generic advice like \"write clean code\" or \"add tests\"\n\nSTEP 3 \u2014 WRITE THE FILE\nProduce a CLAUDE.md, in markdown, using only sections that have real content for this repo (skip empty ones):\n\n# Project Overview\n1-2 sentences: what this is, in plain terms.\n\n# Tech Stack\nExact versions where they matter for behavior.\n\n# Commands\nDev, build, test (full suite AND single test), lint, typecheck \u2014 verified against actual config files, not assumed.\n\n# Architecture\nOnly non-obvious structure or decisions, with brief \"why\" where it isn't self-evident from the code.\n\n# Conventions\nOnly rules that differ from stack defaults.\n\n# Repo Etiquette\nBranch\/commit\/PR conventions if they exist.\n\n# Gotchas\nAnything that would trip up an agent working blind.\n\nConstraints on the output:\n- Target under ~150-200 lines total. If your draft is longer, cut before adding.\n- Every claim must be something you actually verified against the repo (a config file, a script, the README) \u2014 do not invent commands or versions. If something is ambiguous or you couldn't verify it, state that explicitly in an \"## Unverified \u2014 needs human review\" section at the end rather than guessing.\n- Do not include secrets, API keys, or credentials even if you find them in the repo \u2014 flag their presence and location instead.\n- Write it as terse, declarative instructions \u2014 not prose explaining what a CLAUDE.md is.\n\nOutput the final CLAUDE.md content only, followed by a short separate list of anything you flagged as unverified.<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A few notes on why it&#8217;s shaped this way:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>The token-savings lever is brevity, not thoroughness<\/strong> \u2014 Claude Code loads CLAUDE.md in full every session, so a bloated file burns usage on every turn rather than saving it once.<\/li>\n\n\n\n<li>The &#8220;would removing this cause a mistake&#8221; filter is the actual mechanism that keeps Llama from padding the file with restated code.<\/li>\n\n\n\n<li>The unverified-claims guardrail matters because a wrong command in CLAUDE.md (e.g. a stale test runner) actively wastes more usage than having no file at all, since Claude will trust it and fail.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">So when I start claude-code in the directory does it know to read claude.md<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Yes \u2014 Claude Code automatically reads <code>CLAUDE.md<\/code> from the project root at the start of every session, no flag or command needed. It also checks:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>~\/.claude\/CLAUDE.md<\/code> \u2014 user-level, applies across all your projects<\/li>\n\n\n\n<li><code>.\/CLAUDE.md<\/code> \u2014 project root, this is the main one, gets checked into git<\/li>\n\n\n\n<li><code>CLAUDE.local.md<\/code> in the root \u2014 for personal overrides you don&#8217;t want in version control (add it to <code>.gitignore<\/code>)<\/li>\n\n\n\n<li>Subdirectory <code>CLAUDE.md<\/code> files \u2014 loaded lazily as Claude works in that part of the repo<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">If there&#8217;s a conflict, project-level settings override user-level ones. You can also run <code>claude doctor<\/code> after starting a session to confirm it picked the file up, or just ask Claude something like &#8220;what does the project&#8217;s CLAUDE.md say&#8221; as a sanity check.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So, lets say I want to add new 3d models for buildings in one of the missions. Claude code reads the claude.md file and then takes my prompt and does it. When done and I am satisfied. I should \/clear before moving on to the next feature or enhancement, correct<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Yes, that&#8217;s exactly right. Once you&#8217;re satisfied with the 3D models feature and it&#8217;s committed (or at least stable), run <code>\/clear<\/code> before starting the next enhancement.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Why it matters:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>\/clear<\/code> wipes the conversation history but keeps your project and <code>CLAUDE.md<\/code> intact \u2014 you&#8217;re not losing setup, just the back-and-forth from the finished task<\/li>\n\n\n\n<li>Without it, the context window keeps accumulating: old exploration, dead-end attempts, irrelevant file reads from the previous feature \u2014 all of which Claude has to &#8220;carry&#8221; into the next task, costing tokens and sometimes causing it to get confused or apply stale assumptions<\/li>\n\n\n\n<li>One session = one focused task is the general rule of thumb<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">A couple of related things worth knowing:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If you&#8217;re mid-task and just feel context getting cluttered (not switching tasks, just bloated), <code>\/compact<\/code> summarizes and compresses instead of wiping \u2014 useful when you&#8217;re not done yet but the window&#8217;s getting full<\/li>\n\n\n\n<li><code>\/context<\/code> shows you what&#8217;s actually eating your context window if you want to see before deciding<\/li>\n\n\n\n<li>If something from the finished task should persist (a new convention, a gotcha you hit), write it into <code>CLAUDE.md<\/code> <em>before<\/em> you <code>\/clear<\/code> \u2014 otherwise that knowledge is gone with the cleared history<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Can I ask claude code to update the claude.md file before \/clear<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Yes \u2014 that&#8217;s actually a good habit to build into your workflow. You can literally just tell it, e.g.:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">&#8220;Before we wrap up, update CLAUDE.md with anything from this session that would be useful for future work \u2014 new conventions, gotchas, or commands we used.&#8221;<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">A few practical notes:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Claude Code will read the current <code>CLAUDE.md<\/code>, and edit it in place \u2014 same as any file edit, so review the diff before it&#8217;s finalized like you would any other change.<\/li>\n\n\n\n<li>Be specific if you want to <em>avoid<\/em> certain things being added \u2014 e.g. it might want to log &#8220;added 5 new building models for Mission 3,&#8221; which is session-specific noise, not durable project context. You want things like &#8220;3D models go in <code>\/assets\/models\/buildings\/<\/code>, use the X naming convention&#8221; \u2014 not a changelog entry. Steering it toward &#8220;durable, reusable facts&#8221; vs. &#8220;what happened this session&#8221; keeps the file from bloating over time.<\/li>\n\n\n\n<li>Some people ask Claude Code to only <em>propose<\/em> additions rather than write directly, so you can accept\/reject each line \u2014 worth doing if you&#8217;re being disciplined about keeping the file under ~150-200 lines.<\/li>\n\n\n\n<li>You can also just say &#8220;did anything come up in this session that should go in CLAUDE.md?&#8221; and let it self-assess before you decide whether to commit it.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Then <code>\/clear<\/code> right after, once the update&#8217;s committed to your liking.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Resumen<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Here&#8217;s the loop for each enhancement or feature you tackle:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Start the session<\/strong> \u2014 <code>claude<\/code> in your project directory (it auto-loads <code>CLAUDE.md<\/code>)<\/li>\n\n\n\n<li><strong>Prompt the enhancement<\/strong> \u2014 describe what you want (e.g. &#8220;add 3D models for buildings in Mission 3&#8221;)<\/li>\n\n\n\n<li><strong>Review and iterate<\/strong> \u2014 check the changes, give follow-up corrections as needed, all within the same session so Claude keeps relevant context<\/li>\n\n\n\n<li><strong>Test\/verify it works<\/strong> \u2014 run the project, confirm it&#8217;s actually correct, not just &#8220;looks done&#8221;<\/li>\n\n\n\n<li><strong>Ask Claude to update <code>CLAUDE.md<\/code><\/strong> \u2014 only if something durable came out of the session (a new convention, a gotcha, a naming pattern) \u2014 not a changelog of what you just did<\/li>\n\n\n\n<li><strong>Review that CLAUDE.md diff<\/strong> \u2014 keep it lean, cut anything that isn&#8217;t a reusable rule<\/li>\n\n\n\n<li><strong>Commit your work<\/strong> (models, code, updated <code>CLAUDE.md<\/code>) via git, if you haven&#8217;t already<\/li>\n\n\n\n<li><strong><code>\/clear<\/code><\/strong> \u2014 wipe the conversation before moving to the next unrelated enhancement<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Optional checkpoints along the way:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>\/compact<\/code><\/strong> instead of <code>\/clear<\/code> if you&#8217;re not done with the <em>current<\/em> task but context is getting full<\/li>\n\n\n\n<li><strong><code>\/context<\/code><\/strong> if you want to see what&#8217;s eating your context window<\/li>\n\n\n\n<li><strong>Plan mode (Shift+Tab)<\/strong> before big or ambiguous changes, so Claude researches\/proposes a plan before touching files<\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>I am working on a flight simulator game and claude code has been great. But I just exceeded my usage limits. Now I know I was not being very smart in how I use claude code. Basically it was one long conversation spanning days. So having a recursive set of mind, I asked AI what &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/robertjwallace.com\/es\/using-claude-code-efficiently\/\" class=\"more-link\">Continuar leyendo<span class=\"screen-reader-text\"> &#8220;Using Claude Code efficiently&#8221;<\/span><\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_eb_attr":"","footnotes":""},"categories":[171,143],"tags":[],"class_list":["post-8330","post","type-post","status-publish","format-standard","hentry","category-ai","category-computer-stuff"],"featured_image_src":null,"featured_image_src_square":null,"author_info":{"display_name":"Bob","author_link":"https:\/\/robertjwallace.com\/es\/author\/admin\/"},"_links":{"self":[{"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/posts\/8330","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/comments?post=8330"}],"version-history":[{"count":1,"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/posts\/8330\/revisions"}],"predecessor-version":[{"id":8331,"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/posts\/8330\/revisions\/8331"}],"wp:attachment":[{"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/media?parent=8330"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/categories?post=8330"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/tags?post=8330"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}