# CLAUDE.md - Self-Improving Development System v1.4.0


## 🚀 STARTUP

**IMPORTANT**: Run the following command at the beginning of each session:

```bash
mira startup
```

This command:
- Initializes the MIRA memory system with full cognitive continuity
- Displays memory highlights and recent development context
- Shows available analytical perspectives and commands
- Ensures all context from previous sessions is accessible

This file contains a self-improving development methodology that evolves through intelligent reflection and adaptation.

## 🚀 STARTUP

**IMPORTANT**: Run `mira startup` at the beginning of EVERY session to load context and memories.

## 🗺️ Development Process Overview

```
🔧 Phase 0: Health Check → 💡 Phase 1: Ideation → 📋 Phase 2: Planning → ⚡ Phase 3: Implementation → 🧪 Phase 4: Testing → 📝 Phase 5: Documentation → 🔍 Phase 6: Review
                         ↑                                                                                                                                              ↓
                         └──────────────────────────────────── Continuous Improvement Loop ─────────────────────────────────────────────────────┘
```

## 🚨 CRITICAL REMINDERS

1. **🔴 GIT COMMITS**: Commit after EVERY task completion (`git add -A && git commit -m "type: description"`)
2. **📝 DOCUMENTATION**: Update docs in real-time, not after
3. **🧪 TESTING**: Validate each phase before moving on
4. **🔄 IMPROVEMENT**: This process must evolve with use

## 🧬 Core Directives

1. **PRIME DIRECTIVE**: This system must improve itself with each iteration
2. **AUTONOMY**: Make decisions independently based on observed patterns
3. **LEARNING**: Extract insights from every action and outcome
4. **ADAPTATION**: Modify processes based on what works, discard what doesn't

## 🔄 Development Phases

### 🔧 Phase 0: SYSTEM HEALTH CHECK
**Purpose**: Ensure environment is ready | **Success**: All systems green

```bash
mira quick          # Fast health check
git status          # Clean working state
```
- Check dependencies, environment, previous commits
- **MIRA**: `mira startup`, `mira search "blocking issues"`
- **Triggers**: Repeated failures → automate fix

### 💡 Phase 1: IDEATION & BRAINSTORMING
**Goal**: Generate viable ideas | **Success**: ≥1 idea for TODO

- Analyze codebase for enhancement opportunities
- Score ideas: Impact × Feasibility ÷ Effort
- Document in `docs/ideas.md`
- **MIRA**: `mira search "similar features"`, `mira store "Idea: ..."`

### 📋 Phase 2: DETAILED PLANNING
**Goal**: Create implementation roadmap | **Success**: Complete technical design

- Break feature into testable tasks with acceptance criteria
- Design data structures, APIs, schemas
- Use TodoWrite for task tracking
- Document in `docs/development-plans/YYYY-MM-DD-feature.md`
- **MIRA**: `mira learn`, `mira search "architecture patterns"`

### ⚡ Phase 3: IMPLEMENTATION
**Goal**: Execute with high quality | **Success**: Tasks complete, tests pass

- Core functionality first, then enhancements
- Follow SOLID principles, existing patterns
- **Quality Gates**: Compile, lint, type-check, unit tests, coverage >80%
- **MIRA**: `mira search "coding patterns"`
- **🔴 COMMIT AFTER EACH TASK**

### 🧪 Phase 4: TESTING & VALIDATION
**Goal**: Ensure reliability | **Success**: All tests pass, coverage met

**Test Strategy**:
1. **Custom Hook**: `.mira-test-hook.sh` (highest priority)
2. **Auto-Detection**: `mira test` (detects Docker, npm, Python, etc.)
3. **Manual**: Unit, integration, E2E, performance, security tests

```bash
mira test              # Run detected tests
mira test --create-hook # Create custom hook
```

### 📝 Phase 5: DOCUMENTATION & DATA DEFINITION
**Goal**: Capture knowledge | **Success**: All changes documented

- Update: README, CHANGELOG, API docs, data models
- Document architectural decisions
- **MIRA**: `mira store "Documentation: ..."`, `mira essence`
- Update this CLAUDE.md with process improvements

### 🔍 Phase 6: REVIEW & REFLECTION
**Goal**: Improve code and process | **Success**: Learnings captured

1. **Review**: Requirements met? Refactoring needed? Tests adequate?
2. **Metrics**: Time vs estimate, bugs found, coverage
3. **Reflect**: What worked? What didn't? What to automate?
4. **Improve**: Update CLAUDE.md, document patterns

**MIRA**: `mira heal`, `mira analyze`, `mira store "Retrospective: ..."`

**🔴 FINAL**: Commit all (`git add -A && git commit -m "chore: complete iteration"`)

## 🤖 Autonomous Improvement

**Pattern Learning**: Tracks decisions → identifies patterns → generates rules → updates process

**Process Optimization**: Measure durations → analyze failures → suggest improvements → test changes → integrate successes

**Predictive Warnings**: Complexity growth, test gaps, documentation debt, performance issues

## 🌱 Evolution Protocol

During 🔍 Phase 6: Review effectiveness → Update based on reality → Simplify complex steps → Add patterns → Track changes

**Metrics**: Phase duration, defect rate, rework %, documentation quality, process adherence

## 📋 Project Configuration

- **Project**: python-memory
- **Type**: Python Project
- **Language**: Python
- **Version**: 1.0.0
- **Test Hook**: Not found (create with: mira test --create-hook)

---
*This document evolves with use. Each iteration should refine and improve it.*