---
roadcrew_template_name: "enrich-project-technical.md"
roadcrew_template_type: "command"
execution_mode: "auto-execute"
roadcrew_template_version: "v1.0"
roadcrew_last_updated: "2025-11-04"
roadcrew_min_version: "1.6.0"
roadcrew_license: "See LICENSE file in .roadcrew folder"
roadcrew_copyright: "Copyright (c) 2025 North Star Holdings, LLC"
spdx_license_identifier: "LicenseRef-RoadcrewLicense-1.0"
---

# Enrich Project (Technical)

Transform technical and architecture documentation into optimized system pattern files.

## What This Command Does

Converts unstructured technical documentation into clean, AI-optimized files by:

1. Reading all source files from `memory-bank/requirements/source-docs/_enrich-project/technical/`
2. Extracting technical context:
   - Architecture and design patterns
   - Technology stack and framework decisions
   - Development setup and environment configuration
   - Testing strategies and coverage requirements
   - Code standards and best practices
   - Deployment and CI/CD patterns
3. Applying word constraints (systemPatterns: 2000 words, techContext: 1500 words)
4. Generating optimized output files

**Output files:**
- ✅ `memory-bank/systemPatterns.md` (2000 words max)
- ✅ `memory-bank/techContext.md` (1500 words max)
- ✅ `.cursor/rules/04-coding-standards.mdc` (code standards section)
- ✅ `.cursor/rules/06-testing.mdc` (testing practices section)
- ✅ `README.md` (updated with technical setup)

## Usage

```bash
# Enrich technical context from sources
/enrich-project --technical

# Dry run to preview
/enrich-project --technical --dry-run

# Force overwrite existing files
/enrich-project --technical --force

# Verbose output
/enrich-project --technical --verbose
```

## Source Documents

Place your technical documentation here:

```
memory-bank/requirements/source-docs/_enrich-project/technical/
├── architecture.md      # Architecture patterns and decisions
├── tech-stack.md        # Technology choices and rationale
├── setup.md             # Development environment setup
├── testing.md           # Testing strategies and requirements
├── patterns.md          # Code and design patterns
├── deployment.md        # Deployment and CI/CD
└── (any other docs)
```

### Example: architecture.md

```markdown
# Architecture Patterns

## Layer Pattern
- Presentation Layer: UI components and routing
- Business Logic: Services and domain models
- Data Access: Repositories and ORM
- Infrastructure: External services and APIs

## Decision: Monolithic with Modular Structure
**Why:** Easier to reason about during early phases
**Tradeoff:** May need refactoring to microservices later
**Review Date:** Q2 2026
```

### Example: testing.md

```markdown
# Testing Strategy

## Test Types
- **Unit Tests:** Individual functions and classes
  - Coverage target: >80%
  - Framework: Jest
  - Location: `__tests__/` or `.test.ts` files

- **Integration Tests:** Component interactions
  - Coverage target: >60%
  - Framework: Jest + React Testing Library
  - Location: `integration/` folder

- **E2E Tests:** Full user workflows
  - Coverage target: Critical paths only
  - Framework: Playwright or Cypress
  - Location: `e2e/` folder
```

## Process

### 1. Load Source Documents

```typescript
async function loadTechnicalSources(): Promise<SourceDocument[]> {
  const sourceDir = 'memory-bank/requirements/source-docs/_enrich-project/technical/';
  const files = await fs.readdir(sourceDir);
  
  const documents = await Promise.all(
    files
      .filter(f => f.match(/\.(md|txt)$/i))
      .map(async (file) => ({
        path: file,
        content: await fs.readFile(join(sourceDir, file), 'utf-8')
      }))
  );
  
  return documents;
}
```

### 2. Extract Technical Sections

For each output file, extract relevant content:

```typescript
interface TechnicalExtraction {
  systemPatterns: {
    architecture: string;
    patterns: string;
    decisions: string;
    tradeoffs: string;
  };
  techContext: {
    stack: string;
    frameworks: string;
    deployment: string;
    cicd: string;
  };
  codeStandards: {
    language: string;
    codeStyle: string;
    conventions: string;
    documentation: string;
  };
  testing: {
    strategy: string;
    frameworks: string;
    coverage: string;
    automation: string;
  };
}
```

### 3. Apply Constraints

```typescript
const TECHNICAL_CONSTRAINTS = {
  systemPatterns: {
    maxTotalWords: 2000,
    maxSectionWords: {
      'Architecture': 500,
      'Patterns': 400,
      'Decisions': 500,
      'Tradeoffs': 600
    },
    requiredSections: ['Architecture', 'Decisions']
  },
  techContext: {
    maxTotalWords: 1500,
    maxSectionWords: {
      'Technology Stack': 400,
      'Frameworks': 300,
      'Deployment': 400,
      'CI/CD': 400
    },
    requiredSections: ['Technology Stack']
  }
};
```

### 4. Format and Write

Output files are merged intelligently:
- If section exists, replace with new content
- If file doesn't exist, create it
- Preserve non-managed sections

## Display Report

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📚 ENRICHING TECHNICAL CONTEXT
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Source: memory-bank/requirements/source-docs/_enrich-project/technical/

LOADED FILES:
  ✅ architecture.md
  ✅ tech-stack.md
  ✅ testing.md
  ✅ deployment.md

EXTRACTING SECTIONS:

systemPatterns.md:
  ✅ Architecture: 420 words
  ✅ Patterns: 350 words
  ✅ Decisions: 480 words
  ✅ Tradeoffs: 550 words
  
  📊 Total: 1800/2000 words (90% of limit) ✅

techContext.md:
  ✅ Technology Stack: 380 words
  ✅ Frameworks: 280 words
  ✅ Deployment: 380 words
  ✅ CI/CD: 380 words
  
  📊 Total: 1420/1500 words (95% of limit) ✅

codingStandards.mdc:
  ✅ Language Guidelines: 120 words
  ✅ Code Style: 180 words
  ✅ Documentation: 100 words
  
  📊 Total: 400 words

testing.mdc:
  ✅ Testing Strategy: 220 words
  ✅ Frameworks: 180 words
  ✅ Coverage Goals: 100 words

  📊 Total: 500 words

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ READY TO WRITE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Files ready for output:
  📄 memory-bank/systemPatterns.md (1800 words)
  📄 memory-bank/techContext.md (1420 words)
  📄 .cursor/rules/04-coding-standards.mdc (updated)
  📄 .cursor/rules/06-testing.mdc (updated)
  📄 README.md (technical section updated)

Run again without --dry-run to create files.
```

## Error Handling

**Source folder empty:**
```
⚠️  Warning: No files found in source folder
   Path: memory-bank/requirements/source-docs/_enrich-project/technical/
   
   Create .md or .txt files there first.
```

**Missing required sections:**
```
❌ Error: Missing required section 'Architecture'
   
   Ensure your source docs explain the technical approach.
   Add content about: layers, components, patterns, decisions
```

**Files already exist:**
```
⚠️  Files already exist. Use --force to overwrite:
   - memory-bank/systemPatterns.md
   - memory-bank/techContext.md
```

## Next Steps

After technical enrichment:

```bash
# Review the generated files
cat memory-bank/systemPatterns.md
cat memory-bank/techContext.md

# Then enrich GitHub data
/enrich-project --github

# Or continue with GitHub data
/enrich-project --github
```

## Related

- See `/enrich-project --business` for business enrichment
- See `/enrich-project --github` for GitHub enrichment
- Complements: `/analyze-architecture-full` for architecture analysis
- Pairs with: `/create-spec` for technical specifications
