<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: lucky</title>
    <description>The latest articles on DEV Community by lucky (@solooperator).</description>
    <link>https://dev.to/solooperator</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3973240%2F476ec1ac-aa6f-4bf4-92b1-1697b47a4e3c.png</url>
      <title>DEV Community: lucky</title>
      <link>https://dev.to/solooperator</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/solooperator"/>
    <language>en</language>
    <item>
      <title>How to structure CLAUDE.md for long-running projects</title>
      <dc:creator>lucky</dc:creator>
      <pubDate>Mon, 08 Jun 2026 17:21:33 +0000</pubDate>
      <link>https://dev.to/solooperator/how-to-structure-claudemd-for-long-running-projects-2jli</link>
      <guid>https://dev.to/solooperator/how-to-structure-claudemd-for-long-running-projects-2jli</guid>
      <description>&lt;p&gt;Most CLAUDE.md files fail because they don't actually constrain Claude's behavior. They become too brittle and go stale the moment the project pivots. Don't treat CLAUDE.md as a brain dump. Treat it as an operating contract.&lt;/p&gt;

&lt;p&gt;Here's a four-section structure that can hold up over months.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why most CLAUDE.md files fail
&lt;/h2&gt;

&lt;p&gt;The short version reads like this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Project: a Next.js app for managing inventory. Use TypeScript. Prefer Tailwind. Don't use class components.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's a starter, not an operating contract. Claude has no idea what success looks like in this project, what decisions have already been made, what to avoid suggesting. The first session is fine, but come session five, when Claude suggests refactoring the routing layer because "that's the modern Next.js pattern," there's nothing in the file telling it not to.&lt;/p&gt;

&lt;p&gt;The too-brittle version is another problem:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The &lt;code&gt;users&lt;/code&gt; table joins to &lt;code&gt;profiles&lt;/code&gt; via &lt;code&gt;user_id&lt;/code&gt;. Always cast UUIDs to strings before sending to the frontend. The Stripe webhook handler in &lt;code&gt;/api/webhooks/stripe.ts&lt;/code&gt; requires the raw body. Don't modify &lt;code&gt;/lib/auth/middleware.ts&lt;/code&gt;. The &lt;code&gt;pages/dashboard/[id]/edit.tsx&lt;/code&gt; file has a known race condition with...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is everything bolted into one file. The moment any of those facts changes (a schema migration, a webhook refactor, a new auth pattern), the file is wrong. &lt;/p&gt;

&lt;p&gt;The fix is to think of CLAUDE.md as a contract, not a wiki. Contracts have sections, and each section answers a different question. &lt;/p&gt;

&lt;h2&gt;
  
  
  The four sections every CLAUDE.md needs
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Section 1: Standing operating instructions
&lt;/h3&gt;

&lt;p&gt;This is what you always want Claude to do, regardless of task. It's the part that should rarely change.&lt;/p&gt;

&lt;p&gt;What goes here:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Behavior patterns. "Stop flailing. If three approaches haven't worked, stop and ask what's wrong with the original ask."&lt;/p&gt;

&lt;p&gt;Reuse expectations. "Search the codebase for prior art before writing a new abstraction."&lt;/p&gt;

&lt;p&gt;Working-code protection. "Don't override working code without an explicit ask. 'I'd write it differently' is not the bar."&lt;/p&gt;

&lt;p&gt;Communication preference. "When there are multiple valid approaches, name them and let me choose. Don't silent-pick."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This section is the closest thing to a personality for Claude in your project. Once it's good, you'll port the same rules to every project you start. That's the goal: this section is mostly project-agnostic, so the writing effort compounds.&lt;/p&gt;

&lt;h3&gt;
  
  
  Section 2: Project context
&lt;/h3&gt;

&lt;p&gt;This is what this project actually is. Why it exists. What success looks like.&lt;/p&gt;

&lt;p&gt;What goes here:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;One-line project description.&lt;/p&gt;

&lt;p&gt;The stack. Language, framework, database, deployment target.&lt;/p&gt;

&lt;p&gt;Where the project is in its lifecycle (pre-launch, live, mature).&lt;/p&gt;

&lt;p&gt;The locked decisions. Architectural choices that have been made and should not be re-evaluated. ("We use Postgres, not MongoDB. Decided in October. Don't re-suggest.").&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The Locked Decisions subsection is the highest-leverage piece in this section. Most session drift happens because Claude suggests a different approach to something that was already decided. Documenting the decision once with the why helps to kill that drift in subsequent sessions.&lt;/p&gt;

&lt;p&gt;Write the section so that someone reading it cold could understand what the project is in 60 seconds. If they couldn't, the section is too vague.&lt;/p&gt;

&lt;h3&gt;
  
  
  Section 3: Conventions and constraints
&lt;/h3&gt;

&lt;p&gt;This is the negative space. What NOT to do. What patterns to avoid. What's already been tried and rejected.&lt;/p&gt;

&lt;p&gt;What goes here:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Don't lists. "Don't generate test files unless asked. Don't run destructive commands (drop, delete, force push) without explicit ask."&lt;/p&gt;

&lt;p&gt;Anti-patterns specific to your stack. "Don't suggest server components for interactive UI; this project has chosen client components for the dashboard."&lt;/p&gt;

&lt;p&gt;Things that might look wrong but are intentional. "The auth middleware doesn't return early on missing session; that's deliberate, see the comment in the file."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The reason to separate this from Section 1 is that constraints change. The standing operating instructions are mostly evergreen; the constraints accumulate as the project matures and as the team learns what patterns don't work for them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This section is also where you document the tool noise. The things that prompt every session and waste time.&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The dev server throws hydration warnings on hot reload; ignore unless persistent." Documenting these once prevents the same explanation in every session.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Section 4: Lessons
&lt;/h3&gt;

&lt;p&gt;This is the section most people skip. &lt;em&gt;It's the most important one.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;What goes here is a running log of what Claude has learned over time. Each entry is short:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;LESSON: When blocked on one approach, immediately consider the full toolkit instead of suggesting workarounds.&lt;/p&gt;

&lt;p&gt;THE MISTAKE: Hit a network restriction in bash, kept suggesting Python alternatives (same restriction), offered manual download workarounds repeatedly. Only used the browser tool after the user challenged.&lt;/p&gt;

&lt;p&gt;THE FIX: When blocked, research own capabilities first. File downloads → browser tool is the direct solution. Don't suggest manual workarounds when there are tools to automate it.&lt;/p&gt;

&lt;p&gt;APPLIED TO: SEC filing downloads, any file-from-URL task.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This format does three things. It names the failure mode so it's recognizable. It documents the fix concretely. And it tags the scope, so it's clear when the lesson applies.&lt;/p&gt;

&lt;p&gt;The key discipline is to append, not overwrite. When understanding evolves, add an inline correction with a date:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CORRECTION (2026-05-21): The "fully automated, zero manual steps" claim doesn't hold in the scheduled-task sandbox. The host isn't on the allowlist. The pipeline is blocked until either the host is allowlisted or the task runs with a browser connected.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two months later, when the situation evolves again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RESOLVED for LOCAL runs (2026-06-05): The host is reachable when the script runs as a normal local process. The block was only the scheduled-task sandbox. Script now has an --auto mode for local execution.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two dated corrections on top of the original lesson, showing how understanding evolved. Don't overwrite the original lesson. Don't try to fit the resolution into the LESSON text. The chain is the value.&lt;/p&gt;

&lt;p&gt;This section is the institutional memory of your Claude work. Without it, every new session starts cold. With it, the first thing Claude reads after the structural sections is "what have we learned that I should know."&lt;/p&gt;

&lt;h2&gt;
  
  
  What changes between project types
&lt;/h2&gt;

&lt;p&gt;The four-section structure is universal. What goes in each section varies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code-heavy projects&lt;/strong&gt; lean Section 3 hard. Lots of constraints, anti-patterns, framework-specific gotchas. Lessons section captures debugging discoveries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Writing-heavy projects&lt;/strong&gt; (research vaults, knowledge bases) lean Section 1 toward editorial discipline. Read-before-write, append-only, framing locks, source hierarchy. Section 3 covers things like "no first-person language outside meta/" or "use canonical entity names, not handles."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pipeline projects&lt;/strong&gt; (data scrapers, automated workflows) lean Section 4 hard. The lessons section is where the dated-correction format earns its keep. Verification protocols and tool fallback ladders also live in adjacent files referenced from CLAUDE.md.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solo vs collaborative&lt;/strong&gt;: solo projects can use first-person voice in the contract; collaborative projects need to write in voice-agnostic instructions ("the team uses X" not "I use X").&lt;/p&gt;

&lt;p&gt;The structure stays the same. The fill changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Maintenance
&lt;/h2&gt;

&lt;p&gt;The rule: this file doesn't change without a reason.&lt;/p&gt;

&lt;p&gt;Good reasons to edit CLAUDE.md:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A locked decision was made. Add it to Section 2.&lt;/li&gt;
&lt;li&gt;A new pattern emerged that's worth treating as a standing rule. Add to Section 1.&lt;/li&gt;
&lt;li&gt;A constraint got hit. Add to Section 3.&lt;/li&gt;
&lt;li&gt;A lesson was learned. Append to Section 4.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Bad reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"This sentence could be worded better." (Probably true. Not a good reason to touch the file mid-project.)&lt;/li&gt;
&lt;li&gt;"I want to reorganize the sections." (You don't. Read the existing structure, work within it.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When the file gets long enough to feel unwieldy, that's a signal to extract the heaviest sections into separate files and reference them via &lt;code&gt;@import&lt;/code&gt;. The full kit's structure (&lt;code&gt;.claude/rules/&lt;/code&gt; for behavioral rules, &lt;code&gt;.claude/reference/&lt;/code&gt; for project-specific data) is designed for exactly this evolution.&lt;/p&gt;

&lt;h2&gt;
  
  
  The starter is free
&lt;/h2&gt;

&lt;p&gt;There's a starter CLAUDE.md you can download free. It has this four-section structure pre-built, with placeholders ready to fill in for your project. Drop it in your project root, work through it for 15 minutes, and you'll have an operating contract that's already better than 90% of the CLAUDE.md files in the wild.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://solooperator.dev" rel="noopener noreferrer"&gt;solooperator.dev&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The hardened mode-specific versions (code mode with the modular &lt;code&gt;.claude/rules/&lt;/code&gt; structure, content mode with editorial discipline) are in the full Solo Operator Kit.&lt;/p&gt;

&lt;p&gt;Two modes, one kit, $99. Pipeline mode coming in v2 at no additional cost to v1 buyers. Same link.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>claude</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
