ββββββββββββββ
ββββββββββββββββββββββ
ββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββ
ββββββββββββ ββββββββββββββ
ββββββββ ββββββββββ
ββββββββ ββββββ ββββββ ββββββββββ
ββββββββ ββββββββββββββββ ββββββββββ
ββββββββ ββββββββββββββββ ββββββββββ
ββββββββ ββββββββββββββββ ββββββββββ
ββββββββ ββββββββββββββββ ββββββββββ
ββββββββ ββββ ββββ ββββββββββ
ββββββββ ββββββββββ
ββββββββββββ ββββββββββββββ
ββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββ
ββββββββββββββββββββββ
ββββββββββββββ
The AI brain that builds while you sleep. By Itsjwill
./megamind.shAutonomous AI agents that loop until your project is complete.
"Fresh context every iteration. Memory persists. Quality guaranteed."
How It Works Β· Quick Start Β· The MEGAMIND Advantage Β· Commands
MEGAMIND runs AI coding agents in an autonomous loop. Give it user stories or a project plan, and it builds everything β piece by piece β until done.
You β Define what you want (prd.json or GSD plans)
β
MEGAMIND β Loops AI agents until complete
β
You β Wake up to working software
Each iteration:
- π§ Spawns a fresh AI agent (Claude Code or Amp)
- π Picks the next incomplete task
- β‘ Implements it with full focus
- β Runs quality checks
- πΎ Commits if passing
- π Updates progress & patterns
- π Loops until everything passes
As AI fills its context, quality degrades. You've seen this:
"Due to context limits, I'll be more concise..."
Translation: The AI is about to cut corners.
MEGAMIND prevents this. Each iteration starts with a fresh 200k context:
| Traditional AI | MEGAMIND |
|---|---|
| Context fills up | Fresh start each loop |
| Quality degrades | Peak quality always |
| Forgets earlier work | Memory via files |
| Does too much | ONE task per loop |
MEGAMIND remembers everything via files, not context:
| File | Purpose |
|---|---|
PATTERNS.md |
Codebase patterns & gotchas |
progress.txt |
What was built & learned |
prd.json |
Task completion status |
| Git history | Actual changes |
The AI reads these fresh each iteration. Full memory, zero bloat.
Each loop produces exactly one focused commit:
abc123f feat: US-001 - Add user login
def456g feat: US-002 - Add logout button
hij789k feat: US-003 - Add password reset
Benefits:
git bisectfinds exact breaking change- Each task independently revertable
- Clean history for future AI iterations
MEGAMIND learns as it works:
Iteration 1: Discovers codebase uses Zod
β Updates PATTERNS.md
Iteration 2: Uses Zod without trial/error
β Faster implementation
Iteration N: Knows all patterns
β Maximum efficiency
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π§ MEGAMIND LOOP β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β 1. READ BRAIN STATE β β
β β β’ PATTERNS.md (codebase knowledge) β β
β β β’ progress.txt (history) β β
β β β’ prd.json / PLAN.md (tasks) β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β 2. SPAWN FRESH AI AGENT β β
β β β’ Clean 200k context β β
β β β’ Full focus on ONE task β β
β β β’ No degradation β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β 3. IMPLEMENT β β
β β β’ Follow patterns from PATTERNS.md β β
β β β’ Implement the task/story β β
β β β’ Run quality checks β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β 4. COMMIT & UPDATE β β
β β β’ Commit if checks pass β β
β β β’ Update progress.txt β β
β β β’ Update PATTERNS.md (if learned) β β
β β β’ Mark task complete β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β 5. LOOP OR EXIT β β
β β β’ More tasks? β Loop to step 1 β β
β β β’ All done? β Exit with success β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Install one of these AI CLIs:
# Claude Code (Anthropic)
npm install -g @anthropic-ai/claude-code
# Or Amp
# Visit https://ampcode.comBest for: Feature work with clear requirements.
1. Create your stories:
mkdir -p .planning/mindCreate .planning/mind/prd.json:
{
"project": "MyApp",
"branchName": "feature/user-auth",
"userStories": [
{
"id": "US-001",
"title": "Add user registration",
"description": "As a new user, I want to register with email/password",
"acceptanceCriteria": [
"Registration form at /register",
"Email validation",
"Password min 8 chars",
"Redirect to /login on success"
],
"priority": 1,
"passes": false
},
{
"id": "US-002",
"title": "Add user login",
"description": "As a registered user, I want to log in",
"acceptanceCriteria": [
"Login form at /login",
"JWT token on success",
"Error on invalid credentials"
],
"priority": 2,
"passes": false
}
]
}2. Run MEGAMIND:
./megamind.sh3. Watch it build. Each story implemented one at a time.
Best for: Full project lifecycle, architecture-heavy work.
1. Initialize project:
claude '/gsd:new-project'Answer the questions. Creates PROJECT.md.
2. Create roadmap:
claude '/gsd:create-roadmap'Creates phases in ROADMAP.md.
3. Plan first phase:
claude '/gsd:plan-phase 1'Creates detailed PLAN.md with tasks.
4. Run MEGAMIND:
./megamind.sh5. Watch it execute. Each task committed individually.
./megamind.sh --mode=prd- Reads
.planning/mind/prd.json - Implements one user story per iteration
- Marks
passes: truewhen done - Exits when all stories pass
./megamind.sh --mode=plan- Reads
.planning/phases/*/PLAN.mdfiles - Executes tasks from each plan
- Creates
SUMMARY.mdper plan - Updates
STATE.mdandROADMAP.md - Full GSD deviation rules
./megamind.sh- If
prd.jsonexists with incomplete stories β PRD mode - Otherwise β Plan mode
./megamind.sh [iterations] [--mode=prd|plan|auto] [--help]| Option | Description |
|---|---|
iterations |
Max loops before stopping (default: 10) |
--mode=prd |
Force PRD mode |
--mode=plan |
Force Plan mode |
--mode=auto |
Auto-detect (default) |
--help |
Show help |
Examples:
./megamind.sh # 10 iterations, auto
./megamind.sh 50 # 50 iterations, auto
./megamind.sh --mode=prd # 10 iterations, PRD
./megamind.sh 100 --mode=plan # 100 iterations, Planyour-project/
βββ .planning/
β βββ PROJECT.md # Project vision
β βββ ROADMAP.md # Phase roadmap
β βββ STATE.md # Session state
β βββ ISSUES.md # Deferred issues
β βββ phases/ # GSD plans
β β βββ 01-foundation/
β β β βββ 01-01-PLAN.md
β β β βββ 01-01-SUMMARY.md
β β βββ ...
β βββ mind/ # π§ MEGAMIND files
β βββ prd.json # User stories
β βββ progress.txt # Execution log
β βββ PATTERNS.md # Learned patterns
β βββ archive/ # Previous runs
βββ megamind.sh # The brain
MEGAMIND learns as it builds. The PATTERNS.md file grows with each iteration.
Example PATTERNS.md:
# π§ MEGAMIND Brain Patterns
## Architecture
- API routes: `src/app/api/[route]/route.ts`
- Components: `src/components/[Name]/index.tsx`
- Database: `src/db/schema.ts` (Drizzle ORM)
## Conventions
- Use `jose` for JWT (not jsonwebtoken)
- Zod for validation with `.safeParse()`
- TailwindCSS only, no inline styles
- "use client" for interactive components
## Gotchas
- Always add new routes to middleware.ts
- Migrations need `IF NOT EXISTS`
- Form components need client directive
## Dependencies
- auth.ts depends on db/schema.ts
- Changing user schema requires migration
- API routes import from @/lib/*Every iteration reads this first. The AI gets smarter each loop.
MEGAMIND includes full GSD (Get Shit Done) support.
Use with Claude Code:
| Command | What It Does |
|---|---|
/gsd:new-project |
Initialize with questions |
/gsd:create-roadmap |
Create phase roadmap |
/gsd:plan-phase N |
Plan phase N |
/gsd:execute-plan |
Execute one plan |
/gsd:progress |
Check status |
/gsd:verify-work |
Manual testing |
/gsd:rollback |
Undo changes |
When executing plans, MEGAMIND follows these rules:
- Auto-fix bugs β Fix immediately, document
- Auto-add critical β Security/correctness gaps
- Auto-fix blockers β Unblock and continue
- Ask about architectural β STOP and ask human
- Log enhancements β Add to ISSUES.md
Every iteration must pass:
- Typecheck
- Lint
- Tests
- Focused changes only
- Individual file staging
If checks fail, no commit. Fix then retry.
# Define your features
cat > .planning/mind/prd.json << 'EOF'
{
"project": "SaaS MVP",
"branchName": "feature/mvp",
"userStories": [
{"id": "US-001", "title": "Landing page", "priority": 1, "passes": false},
{"id": "US-002", "title": "User signup", "priority": 2, "passes": false},
{"id": "US-003", "title": "Dashboard", "priority": 3, "passes": false},
{"id": "US-004", "title": "Stripe integration", "priority": 4, "passes": false}
]
}
EOF
# Let MEGAMIND build it
./megamind.sh 20
# Wake up to working MVP# Initialize GSD
claude '/gsd:new-project'
# "I want to modernize this Express app to Next.js"
claude '/gsd:create-roadmap'
# Creates phased migration plan
claude '/gsd:plan-phase 1'
# Plans first phase
./megamind.sh 50
# MEGAMIND migrates piece by piececat > .planning/mind/prd.json << 'EOF'
{
"project": "Bug Fixes",
"branchName": "fix/q1-bugs",
"userStories": [
{"id": "BUG-101", "title": "Fix login timeout", "priority": 1, "passes": false},
{"id": "BUG-102", "title": "Fix cart calculation", "priority": 2, "passes": false},
{"id": "BUG-103", "title": "Fix email templates", "priority": 3, "passes": false}
]
}
EOF
./megamind.sh
# Each bug fixed with its own commit# Install Claude Code
npm install -g @anthropic-ai/claude-code
# Or install Amp from https://ampcode.comCreate .planning/mind/prd.json with your user stories. See examples above.
Initialize with GSD:
claude '/gsd:new-project'Make sure .planning/mind/PATTERNS.md exists. MEGAMIND reads this first each iteration.
The loop exits when:
- All stories have
passes: true - All PLAN.md files have SUMMARY.md
- Max iterations reached
Check your status:
# PRD mode
cat .planning/mind/prd.json | jq '.userStories[] | {id, passes}'
# Plan mode
ls .planning/phases/*/*.mdMEGAMIND combines the best of:
- GSD (Get Shit Done) by TΓCHES β Project lifecycle management
- Ralph by Ryan Carson β Iterative agent loop
- Geoffrey Huntley's Ralph pattern β Original concept
MIT License. See LICENSE for details.
π§ MEGAMIND
The AI brain that builds while you sleep.
Fresh context. Persistent memory. Ship faster.
Star this repo if MEGAMIND helps you ship!