<?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: daylay92</title>
    <description>The latest articles on DEV Community by daylay92 (@daylay92).</description>
    <link>https://dev.to/daylay92</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%2F439884%2F48b49664-f5f8-4e07-8987-37f89043a29f.jpeg</url>
      <title>DEV Community: daylay92</title>
      <link>https://dev.to/daylay92</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/daylay92"/>
    <language>en</language>
    <item>
      <title>Context Engineering: Designing AI Systems That Actually Understand Your Codebase</title>
      <dc:creator>daylay92</dc:creator>
      <pubDate>Sun, 01 Feb 2026 14:19:14 +0000</pubDate>
      <link>https://dev.to/daylay92/context-engineering-designing-ai-systems-that-actually-understand-your-codebase-28bf</link>
      <guid>https://dev.to/daylay92/context-engineering-designing-ai-systems-that-actually-understand-your-codebase-28bf</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fon4khns9lj721kjj3qmf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fon4khns9lj721kjj3qmf.png" alt="Context Loading Flow" width="800" height="615"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A practical guide to designing AI-ready codebases that actually understand your project.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The Frustration That Started It All
&lt;/h2&gt;

&lt;p&gt;"Create a lease activation endpoint."&lt;/p&gt;

&lt;p&gt;I typed this instruction to Claude for the 47th time. I know it was the 47th because I'd started keeping a tally in frustration.&lt;/p&gt;

&lt;p&gt;Each time, I'd watch it generate code that &lt;em&gt;looked&lt;/em&gt; right but missed critical details:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Forgot about our 8-state lease lifecycle&lt;/li&gt;
&lt;li&gt;Skipped tenant isolation (hello, security vulnerability)&lt;/li&gt;
&lt;li&gt;Missed the side effects (update unit status, generate invoice, log activity)&lt;/li&gt;
&lt;li&gt;Used patterns inconsistent with the rest of the codebase&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So I'd correct it. Explain the state machine. Remind it about &lt;code&gt;organization_id&lt;/code&gt;. Paste in example code from other files. Twenty minutes later, we'd have working code.&lt;/p&gt;

&lt;p&gt;The next day? Same conversation. Same corrections. Same twenty minutes burned.&lt;/p&gt;

&lt;p&gt;I estimated I was losing 6-8 hours per week just re-explaining context. That's a full workday, every week, saying the same things to an AI that couldn't remember yesterday.&lt;/p&gt;

&lt;p&gt;Something had to change.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Failed Experiments
&lt;/h2&gt;

&lt;p&gt;Before I found what worked, I tried several approaches that didn't:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Attempt #1: The mega-prompt.&lt;/strong&gt; I wrote a 3,000-word system prompt covering everything. Result? Claude got confused, cherry-picked random details, and the token cost was brutal. The AI couldn't distinguish what mattered for the current task.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Attempt #2: Code comments everywhere.&lt;/strong&gt; I added extensive JSDoc comments and inline documentation. But Claude still couldn't see the big picture—it would read one file and miss how it connected to everything else.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Attempt #3: A single massive README.&lt;/strong&gt; 50 pages of documentation in one file. Claude would quote irrelevant sections while missing the specific thing I needed. It's like giving someone an encyclopedia when they asked for directions.&lt;/p&gt;

&lt;p&gt;The breakthrough came when I stopped thinking about documentation for &lt;em&gt;humans&lt;/em&gt; and started thinking about documentation for &lt;em&gt;AI consumption&lt;/em&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Aha Moment
&lt;/h2&gt;

&lt;p&gt;Week six of the project. I was explaining the lease state machine for the dozenth time when I noticed something: I always explained it the same way. Same states, same transitions, same edge cases.&lt;/p&gt;

&lt;p&gt;What if I just... wrote it down once? In a format optimized for Claude to parse quickly?&lt;/p&gt;

&lt;p&gt;I created a simple markdown file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;## State Transitions&lt;/span&gt;
DRAFT → PENDING_APPROVAL, CANCELLED
PENDING_APPROVAL → APPROVED, DRAFT (rejected)
APPROVED → ACTIVE, CANCELLED
ACTIVE → EXPIRED, TERMINATED, RENEWED
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next time I needed lease work, I told Claude: "Read this file first, then implement the activation endpoint."&lt;/p&gt;

&lt;p&gt;It worked. First try. No corrections.&lt;/p&gt;

&lt;p&gt;That file became the seed of a system that would eventually grow to 90+ files—and save me an estimated 300+ hours over the next three months.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is Context Engineering?
&lt;/h2&gt;

&lt;p&gt;Context Engineering is the practice of designing documentation systems that give AI assistants deep, persistent understanding of your codebase.&lt;/p&gt;

&lt;p&gt;Think of it like this: instead of training a new developer from scratch every morning, you hand them a comprehensive onboarding guide that contains everything they need to be productive immediately.&lt;/p&gt;

&lt;p&gt;The key insight is that &lt;strong&gt;AI assistants don't need less documentation—they need &lt;em&gt;structured&lt;/em&gt; documentation&lt;/strong&gt; designed for quick comprehension and targeted loading.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Three Principles
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Layered Depth&lt;/strong&gt;: Not everything needs full context. Simple tasks need simple context; complex tasks need comprehensive context.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Targeted Loading&lt;/strong&gt;: Load only what's relevant to the current task. Token budgets are real constraints.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Single Source of Truth&lt;/strong&gt;: Define patterns once, reference everywhere. No more "which version is correct?"&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  The Three-Tier Architecture
&lt;/h2&gt;

&lt;p&gt;After weeks of iteration (and plenty of wrong turns), I settled on a three-tier system:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;         ┌─────────────────────────────┐
         │      Quick Reference        │  ~100 lines
         │   (Fields, Enums, APIs)     │  Load for simple tasks
         └──────────────┬──────────────┘
                        │
         ┌──────────────▼──────────────┐
         │      Domain Context         │  ~400 lines
         │  (State Machines, Rules)    │  Load for complex features
         └──────────────┬──────────────┘
                        │
         ┌──────────────▼──────────────┐
         │     Pattern Guides          │  ~300 lines
         │  (How to implement)         │  Load for new code
         └─────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkbd19z6h89qnejm576qo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkbd19z6h89qnejm576qo.png" alt="Three-Tier Architecture" width="800" height="615"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Tier 1: Quick Reference Files (~100 lines)
&lt;/h3&gt;

&lt;p&gt;These are optimized for fast lookups. Entity fields, enums, API signatures, basic relationships. When I just need to know "what are the lease statuses?" I load the quickref—nothing more.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gh"&gt;# Leasing Quick Reference&lt;/span&gt;

&lt;span class="gu"&gt;## Entity: Lease&lt;/span&gt;

| Field | Type | Required | Notes |
|-------|------|----------|-------|
| id | UUID | auto | PK |
| lease_number | string(50) | auto | Format: LS-{YYYY}-{SEQ} |
| status | enum | yes | LeaseStatus |
| start_date | date | yes | |
| end_date | date | yes | Must be &amp;gt; start_date |
| rent_amount | decimal(12,2) | yes | |
| security_deposit | decimal(12,2) | yes | Default: 0 |

&lt;span class="gu"&gt;## Enums&lt;/span&gt;

enum LeaseStatus {
  DRAFT, PENDING_APPROVAL, APPROVED, ACTIVE,
  EXPIRED, TERMINATED, RENEWED, CANCELLED
}

&lt;span class="gu"&gt;## State Transitions (Summary)&lt;/span&gt;

DRAFT → PENDING_APPROVAL, CANCELLED
PENDING_APPROVAL → APPROVED, DRAFT
APPROVED → ACTIVE, CANCELLED
ACTIVE → EXPIRED, TERMINATED, RENEWED

&lt;span class="gu"&gt;## API Endpoints&lt;/span&gt;

| Method | Path | Description |
|--------|------|-------------|
| POST | /leases/:id/activate | Activate lease |
| POST | /leases/:id/terminate | Terminate lease |
| POST | /leases/:id/renew | Renew lease |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;~95 lines. Everything Claude needs for simple CRUD work. Nothing it doesn't.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tier 2: Domain Context Files (~400 lines)
&lt;/h3&gt;

&lt;p&gt;These contain the full business logic. State machine diagrams, transition rules, workflow implementations, validation logic. When I'm implementing a complex feature, I load the domain file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gh"&gt;# Leasing Domain - Full Context&lt;/span&gt;

&lt;span class="gu"&gt;## State Machine&lt;/span&gt;

&lt;span class="gu"&gt;### State Diagram&lt;/span&gt;&lt;span class="sb"&gt;

                    ┌──────────────┐
                    │    DRAFT     │
                    └──────┬───────┘
                           │ submit()
                           ▼
            ┌──────────────────────────────┐
            │      PENDING_APPROVAL        │
            └──────┬────────────┬──────────┘
                   │            │
          approve()│            │reject()
                   ▼            ▼
            ┌──────────┐  ┌──────────┐
            │ APPROVED │  │  DRAFT   │
            └────┬─────┘  └──────────┘
                 │ activate()
                 ▼
            ┌──────────┐
            │  ACTIVE  │
            └────┬─────┘
    ┌────────────┼────────────┐
    ▼            ▼            ▼
&lt;/span&gt;┌────────┐ ┌──────────┐ ┌─────────┐
│EXPIRED │ │TERMINATED│ │ RENEWED │
└────────┘ └──────────┘ └─────────┘

&lt;span class="gu"&gt;## Lease Activation Workflow&lt;/span&gt;

async activate(tenant, leaseId) {
  return this.dataSource.transaction(async (manager) =&amp;gt; {
    // 1. Fetch with tenant isolation (CRITICAL)
    const lease = await manager.findOne(Lease, {
      where: {
        id: leaseId,
        organization_id: tenant.organizationId  // Never skip this
      },
      relations: ['unit', 'tenant'],
    });&lt;span class="sb"&gt;

    // 2. Validate state transition
    if (lease.status !== LeaseStatus.APPROVED) {
      throw new BusinessRuleException('INVALID_STATUS',
        `Cannot activate lease in ${lease.status} status`);
    }

    // 3. Check for overlapping leases on same unit
    const overlapping = await this.checkOverlappingLeases(
      lease.unit_id, lease.start_date, lease.end_date, lease.id
    );
    if (overlapping) {
      throw new BusinessRuleException('LEASE_OVERLAP',
        'Unit has overlapping lease');
    }

    // 4. Update lease
    lease.status = LeaseStatus.ACTIVE;
    lease.activated_at = new Date();
    await manager.save(lease);

    // 5. Update unit status (side effect)
    await manager.update(Unit, lease.unit_id, {
      status: UnitStatus.OCCUPIED,
      current_lease_id: lease.id,
      current_tenant_id: lease.tenant_id,
    });

    // 6. Generate first invoice (side effect)
    await this.invoiceService.generateForLease(lease, manager);

    // 7. Log activity (side effect)
    await this.activityService.log({
      entity_type: 'lease',
      entity_id: lease.id,
      action: 'ACTIVATED',
      actor_id: tenant.userId,
    }, manager);

    // 8. Queue notification (side effect)
    await this.notificationService.queue({
      type: NotificationType.LEASE_ACTIVATED,
      recipient_id: lease.tenant_id,
    });

    return lease;
&lt;/span&gt;  });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now Claude understands not just &lt;em&gt;what&lt;/em&gt; to build, but &lt;em&gt;how&lt;/em&gt; it should work—including all five side effects that my early attempts kept missing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tier 3: Pattern Guides (~300 lines)
&lt;/h3&gt;

&lt;p&gt;These are implementation how-tos. API structure, database patterns, testing approaches. Framework-specific enough to be useful, but focused on our conventions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gh"&gt;# API Patterns&lt;/span&gt;

&lt;span class="gu"&gt;## Controller Structure&lt;/span&gt;

@Controller('resources')
export class ResourceController {
  @Get()
  @Permissions('resource:view')
  async findAll(
    @Tenant() tenant: TenantContext,  // Always inject tenant
    @Query() query: QueryDto,
  ): Promise&lt;span class="nt"&gt;&amp;lt;Paginated&lt;/span&gt;&lt;span class="err"&gt;&amp;lt;&lt;/span&gt;&lt;span class="na"&gt;ResourceDto&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;&amp;gt; {
    return this.service.findAll(tenant, query);
  }

  @Post(':id/activate')
  @Permissions('resource:activate')
  @HttpCode(HttpStatus.OK)  // Not 201 for state changes
  async activate(
    @Tenant() tenant: TenantContext,
    @Param('id', ParseUUIDPipe) id: string,
  ): Promise&lt;span class="nt"&gt;&amp;lt;ResourceDto&amp;gt;&lt;/span&gt; {
    return this.service.activate(tenant, id);
  }
}

&lt;span class="gu"&gt;## Error Handling&lt;/span&gt;

// Framework exceptions for HTTP errors
throw new NotFoundException('Lease not found');
throw new ForbiddenException('Insufficient permissions');

// Custom exception for business rules
throw new BusinessRuleException('LEASE_OVERLAP',
  'Unit already has active lease');

// Always include error code for client handling
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Frontend Projects: The UI Layer
&lt;/h3&gt;

&lt;p&gt;If your project has significant frontend work, the three-tier system benefits from UI-specific additions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;         ┌─────────────────────────────┐
         │    UI Quick Reference       │  ~100 lines
         │  (Which pattern to use?)    │  Decision tree for forms, pages
         └──────────────┬──────────────┘
                        │
         ┌──────────────▼──────────────┐
         │    Focused UI Patterns      │  ~150 lines each
         │  (Forms, Modals, Tables)    │  One file per UI pattern
         └──────────────┬──────────────┘
                        │
         ┌──────────────▼──────────────┐
         │    Component Methodology    │  ~400 lines
         │  (Where components live)    │  Package structure, composition rules
         └─────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I added these files to handle frontend complexity:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docs/patterns/ui/
├── FORM_PATTERNS.md      # Modal vs page vs wizard decision tree
├── DETAIL_PAGES.md       # Full detail vs focused detail templates
├── EMPTY_STATES.md       # Empty state patterns and copy
├── SKELETON_LOADERS.md   # Loading state patterns
└── MODALS_TOASTS.md      # Confirmation dialogs, notifications

docs/quickref/UI_PATTERNS.qr.md   # Quick decision tree
docs/patterns/COMPONENT_METHODOLOGY.md  # Where to put components
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The key insight: &lt;strong&gt;UI decisions are recursive&lt;/strong&gt;. Before building a page, you need to decide which pattern. Before building a form, you need to decide modal vs page vs wizard. Having these decisions documented prevents inconsistent UX across features.&lt;/p&gt;

&lt;p&gt;My CLAUDE.md now includes a critical rule:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;### Component-First Development (CRITICAL)&lt;/span&gt;

&lt;span class="gs"&gt;**BEFORE building ANY UI feature, you MUST:**&lt;/span&gt;
&lt;span class="p"&gt;
1.&lt;/span&gt; Load &lt;span class="sb"&gt;`docs/patterns/COMPONENT_METHODOLOGY.md`&lt;/span&gt;
&lt;span class="p"&gt;2.&lt;/span&gt; Decompose the design into component hierarchy
&lt;span class="p"&gt;3.&lt;/span&gt; Check &lt;span class="sb"&gt;`packages/ui`&lt;/span&gt; for existing components
&lt;span class="p"&gt;4.&lt;/span&gt; Build missing components in shared package FIRST
&lt;span class="p"&gt;5.&lt;/span&gt; THEN compose the page in the app

&lt;span class="gs"&gt;**Import rule:**&lt;/span&gt;
// ✅ ALWAYS import from package
import { Button, Card } from '@myproject/ui';

// ❌ NEVER create duplicates in apps/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This single rule eliminated the "duplicate component" problem where Claude would create a new Button in every feature folder.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Pre-Implementation Phase
&lt;/h2&gt;

&lt;p&gt;One pattern that emerged later—and should have been there from the start—is a formal clarification phase before writing code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The problem&lt;/strong&gt;: Claude would jump into implementation with reasonable-sounding assumptions that didn't match my actual requirements. I'd end up with working code that solved the wrong problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fix&lt;/strong&gt;: A structured question phase in CLAUDE.md:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;### Pre-Implementation Clarification Phase&lt;/span&gt;

&lt;span class="gs"&gt;**For non-trivial tasks**&lt;/span&gt;: After loading context but BEFORE writing code,
ask clarifying questions.

&lt;span class="gs"&gt;**Skip for trivial tasks**&lt;/span&gt;: Typo fixes, single-line changes, simple renames.

&lt;span class="gu"&gt;#### Question Categories&lt;/span&gt;

| Category | Questions to Consider |
|----------|----------------------|
| &lt;span class="gs"&gt;**User Value &amp;amp; UX**&lt;/span&gt; | Does this solve a real user problem? Is the UX optimal? Could it be simpler? |
| &lt;span class="gs"&gt;**Edge Cases &amp;amp; Errors**&lt;/span&gt; | What happens at boundaries? Empty states? Max limits? Rollback needed? |
| &lt;span class="gs"&gt;**Conflicts &amp;amp; Coherence**&lt;/span&gt; | Does this contradict existing behavior? Fits existing patterns? |
| &lt;span class="gs"&gt;**Security &amp;amp; Performance**&lt;/span&gt; | Auth concerns? Data access controls? N+1 queries? Will this scale? |

&lt;span class="gu"&gt;#### Before Proceeding, Ensure:&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; All ambiguities resolved
&lt;span class="p"&gt;-&lt;/span&gt; Edge cases identified and handling agreed
&lt;span class="p"&gt;-&lt;/span&gt; No contradictions with existing system
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This added maybe 2-3 minutes to each feature but saved 20+ minutes of rework. Claude now asks "Should the delete button require confirmation?" &lt;em&gt;before&lt;/em&gt; implementing, rather than after I notice it's missing.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Master Reference File
&lt;/h2&gt;

&lt;p&gt;At the root sits &lt;code&gt;CLAUDE.md&lt;/code&gt;—the file that's always loaded. This is your AI's "home base" containing:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Project Identity&lt;/strong&gt;: What we're building, who it's for&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tech Stack&lt;/strong&gt;: Technologies and versions (Claude needs to know if we're using NestJS vs Express)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Critical Conventions&lt;/strong&gt;: Naming patterns, file structure, import order&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Context Loading Guide&lt;/strong&gt;: Which files to load for which tasks&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Quality Requirements&lt;/strong&gt;: What "done" looks like&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Anti-patterns&lt;/strong&gt;: What NOT to do (this section alone prevented dozens of bugs)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The crucial section is the &lt;strong&gt;Context Selection Matrix&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;## Context Loading Guide&lt;/span&gt;

| Task Type | Load These Files |
|-----------|------------------|
| Quick lookup | docs/quickref/{DOMAIN}.qr.md |
| Simple CRUD | quickref + docs/patterns/API.md |
| Complex feature | docs/domains/{DOMAIN}.md + patterns/API.md |
| State machine | docs/domains/{DOMAIN}.md (required!) |
| Writing tests | docs/patterns/TESTING.md + quickref |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This tells Claude exactly what to read before starting any task. No guessing, no missing context, no wasted tokens loading irrelevant files.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Mistakes That Taught Me
&lt;/h2&gt;

&lt;p&gt;Building this system wasn't smooth. Here are three mistakes that cost me time:&lt;/p&gt;

&lt;h3&gt;
  
  
  Mistake #1: Putting Everything in Tier 2
&lt;/h3&gt;

&lt;p&gt;Early on, I made all my context files comprehensive 400-line domain documents. Every simple CRUD task loaded full state machines and workflow code.&lt;/p&gt;

&lt;p&gt;The problem? Token waste and context confusion. Claude would reference complex workflow logic when I just wanted a simple GET endpoint.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fix&lt;/strong&gt;: Create the quickref tier. Simple questions get simple context. Complex questions get comprehensive context. Match the depth to the task.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mistake #2: Duplicating Information Across Tiers
&lt;/h3&gt;

&lt;p&gt;My first quickref files duplicated content from domain files. When I updated the state machine, I'd forget to update the quickref summary. Claude would get conflicting information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fix&lt;/strong&gt;: Quickrefs now &lt;em&gt;summarize&lt;/em&gt; and &lt;em&gt;reference&lt;/em&gt;. At the top of every quickref: &lt;code&gt;&amp;gt; **Full details**: docs/domains/LEASING.md&lt;/code&gt;. The quickref has enough for simple tasks; complex work loads the source of truth.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mistake #3: Not Documenting Anti-Patterns
&lt;/h3&gt;

&lt;p&gt;I kept seeing the same mistakes: &lt;code&gt;any&lt;/code&gt; types, missing tenant filters, console.logs left in code. I'd correct them, but they'd reappear.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fix&lt;/strong&gt;: An explicit "DO NOT" section in CLAUDE.md:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;## Anti-Patterns (DO NOT)&lt;/span&gt;

// ❌ Don't use &lt;span class="sb"&gt;`any`&lt;/span&gt;
const data: any = response;

// ❌ Don't skip tenant filtering
return this.repo.find();  // Security bug!

// ❌ Don't hardcode IDs
const adminId = '550e8400-e29b-41d4-a716-446655440000';

// ❌ Don't use console.log in production code
console.log('debug:', data);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Negative examples are as valuable as positive ones. Maybe more.&lt;/p&gt;




&lt;h2&gt;
  
  
  Token Budget Management
&lt;/h2&gt;

&lt;p&gt;Here's something I learned the hard way: context isn't free. Every token of context is a token that can't be used for reasoning or code generation.&lt;/p&gt;

&lt;p&gt;I hit this wall when Claude started truncating responses mid-function. Too much context, not enough room for output.&lt;/p&gt;

&lt;p&gt;Now I think about context loading like database queries—load only what you need:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Context Load&lt;/th&gt;
&lt;th&gt;~Tokens&lt;/th&gt;
&lt;th&gt;Use Case&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;CLAUDE.md only&lt;/td&gt;
&lt;td&gt;3,500&lt;/td&gt;
&lt;td&gt;General questions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;+ 1 quickref&lt;/td&gt;
&lt;td&gt;5,000&lt;/td&gt;
&lt;td&gt;Simple CRUD&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;+ 1 domain&lt;/td&gt;
&lt;td&gt;8,500&lt;/td&gt;
&lt;td&gt;Complex feature&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;+ 1 domain + 1 pattern&lt;/td&gt;
&lt;td&gt;11,000&lt;/td&gt;
&lt;td&gt;Complex new feature&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;+ 2 domains (cross-cutting)&lt;/td&gt;
&lt;td&gt;13,500&lt;/td&gt;
&lt;td&gt;Multi-domain work&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;My rule&lt;/strong&gt;: Stay under 15,000 tokens to leave headroom for code generation.&lt;/p&gt;

&lt;p&gt;This is why the three-tier system matters. I don't load full domain files for simple questions—I load the quickref. The full context exists when I need it, but I'm not paying the token cost when I don't.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fikbp2fgonnflcgorc0y7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fikbp2fgonnflcgorc0y7.png" alt="Before and After Comparison" width="800" height="540"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Architecture Decision Records: The "Why" Documentation
&lt;/h2&gt;

&lt;p&gt;One pattern that paid off unexpectedly: Architecture Decision Records (ADRs). These document &lt;em&gt;why&lt;/em&gt; we made specific choices.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gh"&gt;# ADR-003: Multi-tenancy Approach&lt;/span&gt;

&lt;span class="gu"&gt;## Context&lt;/span&gt;
We need to isolate data between organizations...

Options considered:
&lt;span class="p"&gt;1.&lt;/span&gt; Database per tenant
&lt;span class="p"&gt;2.&lt;/span&gt; Schema per tenant
&lt;span class="p"&gt;3.&lt;/span&gt; Shared schema with organization_id

&lt;span class="gu"&gt;## Decision&lt;/span&gt;
We chose &lt;span class="gs"&gt;**shared schema with organization_id**&lt;/span&gt;.

&lt;span class="gu"&gt;## Rationale&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; Simpler infrastructure (one database)
&lt;span class="p"&gt;-&lt;/span&gt; Easier migrations (one schema)
&lt;span class="p"&gt;-&lt;/span&gt; Works at our scale (hundreds of orgs, not thousands)
&lt;span class="p"&gt;-&lt;/span&gt; Team has experience with this pattern

&lt;span class="gu"&gt;## Consequences&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; Every query MUST include organization_id filter
&lt;span class="p"&gt;-&lt;/span&gt; Risk of cross-tenant data leaks if filter forgotten
&lt;span class="p"&gt;-&lt;/span&gt; Added TenantContext to enforce this at framework level
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without this ADR, Claude would suggest "why not use separate databases?" every few weeks. Now I point to the decision and its rationale. The AI understands the tradeoffs and doesn't re-litigate settled architecture.&lt;/p&gt;

&lt;p&gt;I have ADRs for: monorepo structure, ORM choice, authentication strategy, state machine implementation, and file storage approach. Six documents that prevent dozens of circular conversations.&lt;/p&gt;




&lt;h2&gt;
  
  
  Before and After: The Real Difference
&lt;/h2&gt;

&lt;p&gt;Let me show you what changed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Before Context Engineering
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Me&lt;/strong&gt;: Create a lease activation endpoint&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Claude&lt;/strong&gt;: I'll create a POST /leases/:id/activate endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;:id/activate&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;activate&lt;/span&gt;&lt;span class="p"&gt;(@&lt;/span&gt;&lt;span class="nd"&gt;Param&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;lease&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;leaseRepo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findOne&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;lease&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ACTIVE&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;leaseRepo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;lease&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What's wrong&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No tenant isolation (security vulnerability)&lt;/li&gt;
&lt;li&gt;No state validation (can "activate" a cancelled lease?)&lt;/li&gt;
&lt;li&gt;No transaction (partial updates if something fails)&lt;/li&gt;
&lt;li&gt;No side effects (unit status, invoice, activity log)&lt;/li&gt;
&lt;li&gt;No error handling&lt;/li&gt;
&lt;li&gt;Wrong patterns (doesn't match our controller structure)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Time to fix&lt;/strong&gt;: 20+ minutes of back-and-forth&lt;/p&gt;

&lt;h3&gt;
  
  
  After Context Engineering
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Me&lt;/strong&gt;: Create a lease activation endpoint&lt;br&gt;
       &lt;a class="mentioned-user" href="https://dev.to/docs"&gt;@docs&lt;/a&gt;/domains/LEASING.md &lt;a class="mentioned-user" href="https://dev.to/docs"&gt;@docs&lt;/a&gt;/patterns/API.md&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Claude&lt;/strong&gt;: Looking at the leasing domain, activation requires:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Current status must be APPROVED (from state machine)&lt;/li&gt;
&lt;li&gt;Must check for overlapping leases&lt;/li&gt;
&lt;li&gt;Transaction wrapping lease + unit updates&lt;/li&gt;
&lt;li&gt;Side effects: unit status, invoice generation, activity log, notification&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here's the implementation following your API patterns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Controller&lt;/span&gt;
&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;:id/activate&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Permissions&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lease:activate&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;HttpCode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;HttpStatus&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;OK&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;activate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Tenant&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="nx"&gt;tenant&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;TenantContext&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Param&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ParseUUIDPipe&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;LeaseResponseDto&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;leaseService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;activate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tenant&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Service&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;activate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tenant&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;TenantContext&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;leaseId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Lease&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;dataSource&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;transaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;manager&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;lease&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;manager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findOne&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Lease&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;where&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;leaseId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;organization_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;tenant&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;organizationId&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="na"&gt;relations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;unit&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;tenant&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;lease&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;NotFoundException&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Lease not found&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;lease&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nx"&gt;LeaseStatus&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;APPROVED&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;BusinessRuleException&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;INVALID_STATUS&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;`Cannot activate lease in &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;lease&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; status`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Check overlapping leases&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;overlapping&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;checkOverlappingLeases&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="nx"&gt;lease&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;unit_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nx"&gt;lease&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;start_date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nx"&gt;lease&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;end_date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nx"&gt;lease&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nx"&gt;manager&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;overlapping&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;BusinessRuleException&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;LEASE_OVERLAP&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Unit has overlapping lease&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Update lease&lt;/span&gt;
    &lt;span class="nx"&gt;lease&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;LeaseStatus&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ACTIVE&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;lease&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;activated_at&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;manager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;lease&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Update unit (side effect)&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;manager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Unit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;lease&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;unit_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;UnitStatus&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;OCCUPIED&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;current_lease_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;lease&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;current_tenant_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;lease&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tenant_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="c1"&gt;// Generate invoice (side effect)&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;invoiceService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generateForLease&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;lease&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;manager&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Log activity (side effect)&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;activityService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;organization_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;tenant&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;organizationId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;entity_type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lease&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;entity_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;lease&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ACTIVATED&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;actor_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;tenant&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;manager&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Queue notification (side effect)&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;notificationService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;queue&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;NotificationType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;LEASE_ACTIVATED&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;recipient_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;lease&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tenant_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;lease&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Time to working code&lt;/strong&gt;: First try. Maybe minor tweaks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;That's the difference.&lt;/strong&gt; Not "slightly better"—categorically different. The AI understood the requirements, the patterns, the side effects, and the error handling. All from two file references.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faghcn88f593s9uo1ztvx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faghcn88f593s9uo1ztvx.png" alt="Token Budget" width="800" height="708"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Customizing for Your Project: A Walkthrough
&lt;/h2&gt;

&lt;p&gt;The template is generic. Here's how to make it yours, using a SaaS billing system as an example.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Define Your Domains
&lt;/h3&gt;

&lt;p&gt;List your major feature areas:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Users &amp;amp; Authentication&lt;/li&gt;
&lt;li&gt;Organizations &amp;amp; Teams&lt;/li&gt;
&lt;li&gt;Subscriptions&lt;/li&gt;
&lt;li&gt;Invoices&lt;/li&gt;
&lt;li&gt;Payments&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 2: Create a Quick Reference
&lt;/h3&gt;

&lt;p&gt;Copy &lt;code&gt;docs/quickref/_TEMPLATE.qr.md&lt;/code&gt; to &lt;code&gt;docs/quickref/SUBSCRIPTIONS.qr.md&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gh"&gt;# Subscriptions Quick Reference&lt;/span&gt;
&lt;span class="gt"&gt;
&amp;gt; **Full details**: docs/domains/SUBSCRIPTIONS.md&lt;/span&gt;

&lt;span class="gu"&gt;## Entity: Subscription&lt;/span&gt;

| Field | Type | Required | Notes |
|-------|------|----------|-------|
| id | UUID | auto | PK |
| organization_id | UUID | yes | Tenant isolation |
| plan_id | UUID | yes | FK → plans |
| status | enum | yes | SubscriptionStatus |
| current_period_start | timestamp | yes | |
| current_period_end | timestamp | yes | |
| cancel_at_period_end | boolean | yes | Default: false |

&lt;span class="gu"&gt;## Enums&lt;/span&gt;

enum SubscriptionStatus {
  TRIALING = 'TRIALING',
  ACTIVE = 'ACTIVE',
  PAST_DUE = 'PAST_DUE',
  CANCELED = 'CANCELED',
  UNPAID = 'UNPAID'
}

&lt;span class="gu"&gt;## State Transitions&lt;/span&gt;

TRIALING → ACTIVE, CANCELED
ACTIVE → PAST_DUE, CANCELED
PAST_DUE → ACTIVE, UNPAID, CANCELED
UNPAID → ACTIVE, CANCELED
CANCELED → (terminal)

&lt;span class="gu"&gt;## API Endpoints&lt;/span&gt;

| Method | Path | Description |
|--------|------|-------------|
| POST | /subscriptions | Create subscription |
| POST | /subscriptions/:id/cancel | Cancel subscription |
| POST | /subscriptions/:id/reactivate | Reactivate canceled |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;~80 lines. Enough for Claude to handle basic subscription work.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Add to Context Matrix
&lt;/h3&gt;

&lt;p&gt;Update &lt;code&gt;CLAUDE.md&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;## Domain Quick Reference&lt;/span&gt;

| Domain | Quick Ref | Full Context |
|--------|-----------|--------------|
| Auth | quickref/AUTH.qr.md | domains/AUTH.md |
| Subscriptions | quickref/SUBSCRIPTIONS.qr.md | domains/SUBSCRIPTIONS.md |
| Invoices | quickref/INVOICES.qr.md | domains/INVOICES.md |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now Claude knows where to find subscription context.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Build Domain File When Needed
&lt;/h3&gt;

&lt;p&gt;You don't need full domain files immediately. Create them when you hit complex logic:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Implementing the renewal workflow? Time for &lt;code&gt;domains/SUBSCRIPTIONS.md&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Just doing CRUD? Quickref is enough&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Build what you need, when you need it.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Task Breakdown System
&lt;/h2&gt;

&lt;p&gt;As the project grew, I needed more than context files—I needed to track &lt;em&gt;what&lt;/em&gt; to build and in &lt;em&gt;what order&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The task system has three components:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Master Index (&lt;code&gt;docs/tasks/TASK_INDEX.md&lt;/code&gt;)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gh"&gt;# Task Index&lt;/span&gt;

&lt;span class="gs"&gt;**Total**&lt;/span&gt;: 127 tasks | &lt;span class="gs"&gt;**Complete**&lt;/span&gt;: 0 | &lt;span class="gs"&gt;**In Progress**&lt;/span&gt;: 0

&lt;span class="gu"&gt;## Features&lt;/span&gt;

| # | Feature | Tasks | Complete | Status |
|---|---------|-------|----------|--------|
| 0 | Foundation | 18 | 0 | 🔴 Not Started |
| 1 | Portfolio | 18 | 0 | 🔴 Not Started |
| 2 | Properties | 15 | 0 | 🔴 Not Started |
| 3 | Units | 13 | 0 | 🔴 Not Started |
...

&lt;span class="gu"&gt;## Recommended Order&lt;/span&gt;
&lt;span class="p"&gt;0.&lt;/span&gt;x Foundation → 2.x Properties → 3.x Units → 5.x Tenants → 4.x Leases
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Feature Task Files (&lt;code&gt;docs/tasks/01-portfolio/tasks.md&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;Each feature gets a task file with atomic, testable tasks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gh"&gt;# Portfolio Tasks&lt;/span&gt;

&lt;span class="gs"&gt;**Context**&lt;/span&gt;: Load &lt;span class="sb"&gt;`docs/quickref/PORTFOLIO.qr.md`&lt;/span&gt;

&lt;span class="gu"&gt;## Tasks&lt;/span&gt;

&lt;span class="gu"&gt;### 1.1 Create Portfolio Entity&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; [ ] Define entity with fields from quickref
&lt;span class="p"&gt;-&lt;/span&gt; [ ] Add TypeORM decorators
&lt;span class="p"&gt;-&lt;/span&gt; [ ] Create migration
&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="gs"&gt;**Tests**&lt;/span&gt;: Entity creates, validates required fields
&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="gs"&gt;**Blocks**&lt;/span&gt;: 1.2, 1.3

&lt;span class="gu"&gt;### 1.2 Portfolio CRUD Endpoints&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; [ ] GET /portfolios (list with pagination)
&lt;span class="p"&gt;-&lt;/span&gt; [ ] GET /portfolios/:id (single with relations)
&lt;span class="p"&gt;-&lt;/span&gt; [ ] POST /portfolios (create)
&lt;span class="p"&gt;-&lt;/span&gt; [ ] PATCH /portfolios/:id (update)
&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="gs"&gt;**Tests**&lt;/span&gt;: Each endpoint, validation errors, tenant isolation
&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="gs"&gt;**Blocked by**&lt;/span&gt;: 1.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Context Routing (&lt;code&gt;docs/tasks/context-slices/README.md&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;Maps task types to required context files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;## Context Slices&lt;/span&gt;

| Task Pattern | Load These Files |
|--------------|------------------|
| &lt;span class="sb"&gt;`*.1`&lt;/span&gt; Entity tasks | DATABASE.md + quickref |
| &lt;span class="sb"&gt;`*.2`&lt;/span&gt; CRUD tasks | API.md + quickref |
| &lt;span class="sb"&gt;`*.3`&lt;/span&gt; State machine tasks | Full domain file |
| &lt;span class="sb"&gt;`*.4`&lt;/span&gt; UI tasks | COMPONENT_METHODOLOGY.md + domain |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This system lets me (or Claude) pick up any task and know exactly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What to build&lt;/li&gt;
&lt;li&gt;What context to load&lt;/li&gt;
&lt;li&gt;What it depends on&lt;/li&gt;
&lt;li&gt;How to verify it works&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;I've packaged this system into a template repository you can fork and customize.&lt;/p&gt;

&lt;h3&gt;
  
  
  Quick Setup
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Fork the template&lt;/strong&gt;: github.com/daylay92/context-engineering-template&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Customize CLAUDE.md&lt;/strong&gt; with your project identity and tech stack&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Create quickref files&lt;/strong&gt; for your main domains (start with 2-3)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add domain files&lt;/strong&gt; as complexity demands them&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Set up task tracking&lt;/strong&gt; when you're ready to build&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  What's Included
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;context-engineering-template/
├── CLAUDE.md                 # Customize this first
├── .cursorrules              # Cursor IDE variant
├── docs/
│   ├── PROGRESS.md           # Project status
│   ├── CONTEXT_INDEX.md      # Navigation guide
│   ├── quickref/
│   │   ├── _TEMPLATE.qr.md   # Copy for each domain
│   │   └── EXAMPLE.qr.md     # Annotated example
│   ├── domains/
│   │   ├── _TEMPLATE.md      # Copy when needed
│   │   └── EXAMPLE.md        # Full example with state machine
│   ├── patterns/
│   │   ├── API.md            # REST patterns
│   │   ├── DATABASE.md       # Database patterns
│   │   └── TESTING.md        # Testing patterns
│   ├── decisions/
│   │   └── _TEMPLATE.md      # ADR template
│   └── tasks/
│       ├── TASK_INDEX.md     # Master tracker
│       ├── README.md         # How to use tasks
│       ├── context-slices/   # Task → context mapping
│       └── 00-example/       # Example feature tasks
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmwyr9op169iy8jqzau35.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmwyr9op169iy8jqzau35.png" alt="File Structure" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All templates include annotations explaining each section. Delete them once you understand the system.&lt;/p&gt;




&lt;h2&gt;
  
  
  The ROI
&lt;/h2&gt;

&lt;p&gt;Let me be concrete about what this cost and what it returned.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Investment&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Initial system design: ~8 hours&lt;/li&gt;
&lt;li&gt;Writing 90+ files: ~50 hours over 3 months&lt;/li&gt;
&lt;li&gt;Ongoing maintenance: ~2 hours/month&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Return&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Time saved per session: 15-25 minutes&lt;/li&gt;
&lt;li&gt;Sessions per week: 15-20&lt;/li&gt;
&lt;li&gt;Weekly savings: 4-8 hours&lt;/li&gt;
&lt;li&gt;Three-month savings: 50-100+ hours&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;But the bigger win isn't time—it's quality.&lt;/strong&gt; The code Claude generates now fits naturally into the codebase. Fewer bugs. Less refactoring. More consistency. The patterns I defined in documentation become the patterns in the code.&lt;/p&gt;




&lt;h2&gt;
  
  
  Quality Verification
&lt;/h2&gt;

&lt;p&gt;One thing I underestimated: Claude doesn't naturally verify its work. It generates code and moves on. I added an explicit quality checklist to CLAUDE.md:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;## Quality Checklist (MANDATORY)&lt;/span&gt;

&lt;span class="gs"&gt;**Before marking ANY task complete:**&lt;/span&gt;

☐ Type check     → pnpm typecheck        → ZERO errors
☐ Lint           → pnpm lint             → ZERO errors
☐ Format         → pnpm format           → Applied
☐ Tests pass     → pnpm test             → ALL green
☐ Tests written  → New code has tests    → See coverage rules
☐ Build works    → pnpm build            → Succeeds
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;More importantly, I require Claude to &lt;em&gt;output&lt;/em&gt; the results:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;### Report Format&lt;/span&gt;
After completing work, output:

&lt;span class="gu"&gt;## Quality Checklist&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; [x] Type check passed
&lt;span class="p"&gt;-&lt;/span&gt; [x] Lint passed (0 errors)
&lt;span class="p"&gt;-&lt;/span&gt; [x] Formatted
&lt;span class="p"&gt;-&lt;/span&gt; [x] Tests passed (12 passed, 0 failed)
&lt;span class="p"&gt;-&lt;/span&gt; [x] New tests: lease.service.spec.ts (8 tests)
&lt;span class="p"&gt;-&lt;/span&gt; [x] Build succeeded
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This seemingly small addition had outsized impact. Claude now runs the checks &lt;em&gt;because it knows it needs to report them&lt;/em&gt;. The verification step went from "often skipped" to "always done."&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Context Engineering isn't about writing more documentation—it's about writing &lt;em&gt;smarter&lt;/em&gt; documentation. Documentation designed for AI consumption, structured for quick loading, and organized for targeted retrieval.&lt;/p&gt;

&lt;p&gt;The 90+ markdown files I created represent about a week of focused work, spread over three months of iteration. They've saved me hundreds of hours of repetitive explanation and correction.&lt;/p&gt;

&lt;p&gt;But more importantly, they changed the nature of my work with AI. Instead of fighting against amnesia every session, I have a collaborator that understands my project deeply—every time, from the first message.&lt;/p&gt;

&lt;p&gt;If you're using AI coding assistants more than a few times per week, this investment pays for itself fast. The question isn't whether to build a context system, but how soon you'll start.&lt;/p&gt;

&lt;p&gt;Fork the template. Customize it for your project. And stop repeating yourself.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Template Repository&lt;/strong&gt;: &lt;a href="https://github.com/daylay92/context-engineering-template" rel="noopener noreferrer"&gt;github.com/daylay92/context-engineering-template&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Have questions or built something with this?&lt;/strong&gt; I'd love to hear about it. Open an issue on the template repo or reach out on &lt;a href="https://twitter.com/daylaynos" rel="noopener noreferrer"&gt;Twitter/X&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This article was written while building &lt;a href="https://qacehomes.com" rel="noopener noreferrer"&gt;Qace Homes PMS&lt;/a&gt;, a property management system. The context engineering system described here evolved from real frustration into a real solution—90+ files that fundamentally changed how I work with AI.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Tags&lt;/strong&gt;: #ai #claude #cursor #copilot #productivity #developer-tools #programming #context-engineering&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
