AI Development

ARCHITECTURE.md and CLAUDE.md: Why Spec-Driven AI Coding Ships Faster

Day 6 of a 30-day AI coding experiment revealed something counterintuitive: the developers shipping fastest with AI tools were spending more time writing specs and less time writing code. Not because they were slow coders, but because a well-written spec turns AI coding into a nearly mechanical process. The code writes itself when the architecture doc is good enough. This guide explores how ARCHITECTURE.md and CLAUDE.md files have become the most valuable artifacts in AI-assisted development, and why the old practice of spec-driven development is making a comeback in a form nobody expected.

1. The Vibe Coding Problem

"Vibe coding" entered the developer vocabulary in 2025. The idea was simple: describe what you want in natural language, let the AI write the code, accept the result if it looks right. For prototypes and throwaway scripts, it works surprisingly well. For anything that needs to survive a week in production, it falls apart.

The failure mode is predictable. Without architectural context, AI generates code that satisfies the immediate request but ignores the surrounding system. It creates a new database connection instead of using the connection pool. It adds a REST endpoint when your API is GraphQL. It uses a different state management pattern than the one your team adopted three months ago.

These are not AI failures. They are context failures. The AI does exactly what you ask because it does not know what you should have asked. The difference between a junior developer and a senior one is mostly context, and that same context gap is what makes vibe coding unreliable.

The fix is not better prompting. Prompts are ephemeral, specific to one task, and do not accumulate knowledge. The fix is documentation that persists across sessions, that captures architectural decisions, that teaches the AI your codebase the way you would teach a new team member. That documentation takes the form of ARCHITECTURE.md and CLAUDE.md files.

2. Why Specs Are Making a Comeback

Software development has oscillated between heavy-spec and no-spec approaches for decades. Waterfall required exhaustive specs before any code was written. Agile pushed back, favoring working software over comprehensive documentation. Many teams ended up with minimal specs and relied on institutional knowledge instead.

AI coding has shifted the economics. Writing specs used to feel wasteful because a human still had to translate the spec into code, and the translation process was the bottleneck. Now, with AI handling the translation, the spec is the bottleneck. The better your spec, the faster and more accurate the code generation.

This is genuinely new. For the first time, investing an extra hour in documentation can save multiple hours of coding, debugging, and refactoring. The return on spec quality is direct and measurable. Teams running 30-day AI coding experiments consistently report that their best days, measured by features shipped, were the days they spent the most time planning and the least time prompting.

The spec-driven approach also solves the consistency problem across multiple AI sessions. Without a persistent spec, every new conversation starts from zero. With ARCHITECTURE.md and CLAUDE.md, every session inherits the full context of your project decisions.

3. Writing an Effective ARCHITECTURE.md

ARCHITECTURE.md is a living document at your project root that describes the system structure, key decisions, and the reasoning behind them. It is not API documentation or a README. It answers the question: "If a new developer joined today, what would they need to understand before writing their first line of code?"

Sections that consistently prove valuable:

  • System overview - A two-paragraph summary of what the system does, who uses it, and the core data flow. Keep it high-level enough that someone outside your team could understand it.
  • Component map - List each major component, what it does, and how it connects to others. Include the directory structure so the AI can navigate the codebase.
  • Key decisions and constraints - Why you chose Postgres over MongoDB. Why the API is REST instead of GraphQL. Why you use server-side rendering for some pages and client-side for others. The "why" matters more than the "what".
  • Patterns to follow - Error handling conventions, logging format, testing approach, state management. These are the patterns the AI should replicate when generating new code.
  • Patterns to avoid - Equally important. If you migrated away from Redux, say so. If you are deprecating a specific API pattern, document it. This prevents the AI from introducing code you will have to remove later.

The document should be 500 to 2000 words. Longer than that and it becomes noise. Shorter than that and it misses critical context. Update it whenever you make a significant architectural decision. The investment pays for itself within the first AI session that reads it.

4. CLAUDE.md: Teaching the AI Your Codebase

CLAUDE.md is a Claude Code-specific file that provides instructions and context for every interaction. While ARCHITECTURE.md describes the system, CLAUDE.md describes how to work with it. Think of ARCHITECTURE.md as the map and CLAUDE.md as the field guide.

Effective CLAUDE.md files typically include:

  • Build and test commands - How to build the project, run tests, start the development server. The AI should never have to guess these.
  • Code style requirements - Formatting preferences, naming conventions, import ordering. Specifics that your linter might not catch.
  • Workflow rules - "Never push directly to main." "Always run tests before committing." "Use conventional commit messages." These become guardrails the AI follows automatically.
  • Common pitfalls - Things that break in non-obvious ways. "The auth middleware must be applied before the rate limiter." "Environment variables are loaded from .env.local in development, not .env."
  • Testing requirements - What to test, what not to test, preferred test patterns, and any test infrastructure specifics.

You can also have a global CLAUDE.md in your home directory that applies to all projects. This is useful for personal preferences that span codebases, like preferred tools, communication style, and standard debugging approaches.

The combination of ARCHITECTURE.md and CLAUDE.md means the AI starts every session with deep context about both the system and how to work with it. The first time you see it correctly apply your architecture patterns without being told, you understand why this time investment matters.

5. The Planning-Heavy Workflow in Practice

The concrete workflow that emerges from spec-driven AI coding looks different from both traditional development and vibe coding. Here is how it plays out for a typical feature:

Step 1: Write the feature spec (30-45 minutes). Before touching any code or opening any AI tool, write a plain-text spec. Describe the feature, the user interaction, the data model changes, the API endpoints, the edge cases, and the testing approach. Be specific. "The user can filter by date range" is not a spec. "The user selects a start date and end date using date pickers. The API accepts ISO 8601 timestamps. If no end date is provided, default to now. Results are paginated with a limit of 50" is a spec.

Step 2: Have the AI review your spec (10 minutes). Before implementation, ask the AI to review the spec for gaps. It will often catch missing error handling, unclear edge cases, and inconsistencies with existing architecture. This is cheaper to fix in a spec than in code.

Step 3: Implement with the spec as context (30-60 minutes). Paste the spec into the conversation or reference it from a file. The AI now has enough context to generate code that matches your architecture, handles edge cases, and follows your conventions. Most of your time in this step is reviewing and testing, not directing.

Step 4: Update the architecture docs (10 minutes). If the feature changed any architectural patterns or introduced new components, update ARCHITECTURE.md. This keeps future sessions accurate.

Total time: 80 to 125 minutes for a feature that would take a full day without AI and half a day with unguided vibe coding (plus another half day fixing the issues vibe coding introduced).

6. Time Spent: Spec-Driven vs. Prompt-and-Pray

Developers in 30-day AI coding experiments have tracked their time across different approaches. The numbers are consistent enough to be instructive:

PhaseVibe CodingSpec-Driven
Planning and specs5 minutes40 minutes
Initial coding20 minutes30 minutes
Debugging and fixing90 minutes15 minutes
Rework and refactoring60 minutes10 minutes
Doc updates0 minutes10 minutes
Total~175 minutes~105 minutes

The pattern is clear: vibe coding front-loads speed and back-loads pain. Spec-driven development front-loads thought and back-loads speed. The total time difference is significant, but the quality difference is even larger. Spec-driven code matches existing architecture, handles edge cases, and rarely needs rework.

Tools across the AI development ecosystem are converging on this insight. Claude Code uses CLAUDE.md. Cursor uses .cursorrules. Copilot uses .github/copilot-instructions.md. Desktop automation tools like Fazm, an AI computer agent for macOS that is voice-first, open source, and uses accessibility APIs, similarly benefit from clear instructions and structured workflows rather than ad-hoc commands.

7. Starting Your Spec-Driven Practice Today

You do not need to overhaul your workflow overnight. Start with these concrete steps:

  • Create CLAUDE.md this week. Spend 30 minutes writing the basics: build commands, code style, common pitfalls. You will see immediate improvement in AI output quality.
  • Write ARCHITECTURE.md for your main project. Start with the system overview, component map, and key decisions. It does not need to be comprehensive on day one. Grow it over time.
  • Spec your next feature before coding it. Write a plain-text spec with enough detail that someone unfamiliar with your codebase could understand what needs to be built. Then use that spec as context for AI coding.
  • Track your time for two weeks. Compare tasks where you wrote specs first versus tasks where you went straight to prompting. The data will convince you more than any article.
  • Share your docs with your team. ARCHITECTURE.md and CLAUDE.md are valuable for human team members too. They codify knowledge that otherwise lives only in people's heads.

The counterintuitive truth of AI-assisted development is that the most valuable skill is not prompting. It is thinking clearly enough to write a good spec. The AI handles the translation from spec to code. Your job is to make sure the spec is worth translating.

From Specs to Shipped Software

Fazm is an open source AI computer agent for macOS that turns voice commands into desktop actions using accessibility APIs. Automate the workflows around your code.

Try Fazm Free