Crew Init - Project Analysis & Team Setup
Full project initialization that transforms any codebase into a CodeCrew workspace with indexed code, profiled architecture, and a configured agent team.
When to Activate
- User runs
/crew init
- User runs
/crew with init argument
- First time using CodeCrew in a project
Initialization Pipeline
Phase 1: Project Discovery
Scan the project to understand what we're working with:
1.1 Detect project type and languages:
Use Glob to check for:
- package.json, tsconfig.json → Node.js / TypeScript
- requirements.txt, pyproject.toml, setup.py → Python
- go.mod → Go
- Cargo.toml → Rust
- pom.xml, build.gradle → Java / Kotlin
- Gemfile → Ruby
- composer.json → PHP
- Makefile, CMakeLists.txt → C/C++
- pubspec.yaml → Dart/Flutter
- *.sln, *.csproj → .NET/C#
1.2 Detect frameworks:
Read package.json (or equivalent) for:
- react, next, vue, angular, svelte → Frontend framework
- express, fastify, koa, django, flask, gin, actix → Backend framework
- playwright, jest, pytest, mocha → Testing framework
- eslint, prettier, black, gofmt → Linting/formatting
- docker, kubernetes → Container/orchestration
1.3 Map project structure:
Use Glob for directory layout:
- src/, lib/, app/ → Source code
- test/, tests/, __tests__, spec/ → Tests
- docs/, doc/ → Documentation
- .github/, .gitlab-ci.yml → CI/CD
- Dockerfile, docker-compose.yml → Docker
- scripts/, bin/ → Build/deploy scripts
1.4 Read existing context:
- Read CLAUDE.md if it exists (project-specific instructions)
- Read README.md for project description
- Check git log for recent activity areas (if git repo)
Phase 2: Build Codebase Index
Invoke the codebase-index skill in full-build mode:
- Discover all source files (excluding node_modules, dist, build, etc.)
- For each file: read, hash, extract metadata (exports, imports, functions, classes, line count)
- Build call graph from import/export relationships
- Write
.claude/crew-index.json (Layer 1 - compact)
- Write
.claude/crew-symbols.json (Layer 2 - symbols)
This enables the Index-First Protocol for all future agent interactions.
Phase 3: Generate Project Profile
Write .claude/crew-profile.md with:
# Crew Profile: {project-name}
## Overview
- **Type**: {web-app | api | cli | library | scraper | mobile | etc.}
- **Languages**: {detected languages}
- **Frameworks**: {detected frameworks}
- **Size**: {total files} files, {total lines} lines
## Architecture
- **Entry Point**: {main file}
- **Pipeline/Flow**: {data flow description}
- **Patterns**: {MVC, pipeline, event-driven, microservice, etc.}
## Key Directories
- **Source**: {src paths}
- **Tests**: {test paths}
- **Config**: {config files}
- **Docs**: {doc paths}
## Tech Stack
- **Runtime**: {node, python, go, etc.}
- **Package Manager**: {npm, pip, cargo, etc.}
- **Testing**: {jest, pytest, etc.}
- **Linting**: {eslint, prettier, etc.}
- **CI/CD**: {github actions, gitlab ci, etc.}
- **Deployment**: {docker, k8s, vercel, etc.}
## Index Status
- **Files Indexed**: {count}
- **Symbols Mapped**: {count}
- **Last Indexed**: {timestamp}
- **Index Files**: .claude/crew-index.json, .claude/crew-symbols.json
Phase 4: Configure Agent Team
Based on detected stack, determine which agents are active and what skills they need.
Write .claude/crew-team.json:
{
"project": "project-name",
"configured": "2026-04-04T12:00:00Z",
"agents": {
"ceo": {
"model": "opus",
"active": true,
"role": "Task triage, decomposition, delegation, architecture decisions"
},
"vp-engineering": {
"model": "sonnet",
"active": true,
"role": "Tech decisions, architecture review, complex planning"
},
"vp-quality": {
"model": "sonnet",
"active": true,
"role": "Quality gates, test strategy, review coordination"
},
"senior-dev": {
"model": "sonnet",
"active": true,
"role": "Complex implementation, multi-file changes"
},
"junior-dev": {
"model": "haiku",
"active": true,
"role": "Simple fixes, formatting, small changes"
},
"code-reviewer": {
"model": "sonnet",
"active": true,
"role": "Code review, quality assessment"
},
"debugger": {
"model": "sonnet",
"active": true,
"role": "Bug investigation, root cause analysis"
},
"security-analyst": {
"model": "sonnet",
"active": false,
"activateWhen": "security-related tasks or pre-deploy review"
},
"devops-engineer": {
"model": "haiku",
"active": false,
"activateWhen": "Docker/CI/CD/deployment tasks detected"
},
"doc-writer": {
"model": "haiku",
"active": true,
"role": "Documentation, comments, READMEs"
},
"test-engineer": {
"model": "sonnet",
"active": false,
"activateWhen": "test directory detected or testing tasks"
}
},
"activationRules": {
"hasDocker": ["devops-engineer"],
"hasTests": ["test-engineer"],
"hasSecurity": ["security-analyst"],
"always": ["ceo", "vp-engineering", "senior-dev", "junior-dev", "code-reviewer", "debugger", "doc-writer"]
}
}
Activate conditional agents based on detected stack:
- Found
Dockerfile or docker-compose.yml → activate devops-engineer
- Found
test/ or testing framework → activate test-engineer
- Found
.env or security configs → activate security-analyst
Phase 5: Suggest Custom Agents
Based on Phase 1 detection results (languages, frameworks, tools), suggest project-specific custom agents that extend the built-in team. The number of suggestions is dynamic — more frameworks/tools detected = more suggestions.
Step 0: Detect Project Domain
Analyze available project signals to classify the project domain:
- Project directory name — check for keywords (e.g., "trading", "shop", "health", "game")
- README.md — read first 50 lines for project description keywords
- package.json / pyproject.toml — check
description and keywords fields
- Directory names — scan for domain-specific folders (e.g.,
strategies/, orders/, cart/, patients/)
- Import patterns — check for domain-specific libraries (e.g.,
ccxt, alpaca-trade-api, stripe, hl7)
Classify into ONE primary domain:
| Domain |
Detection Signals |
trading/finance |
"trading", "bot", "strategy", "backtest", "portfolio", "hedge", "quant", ccxt, alpaca, binance, ta-lib, quantlib |
e-commerce |
"shop", "store", "cart", "checkout", "product", stripe, shopify, woocommerce, snipcart |
healthcare |
"patient", "health", "medical", "clinical", "ehr", hl7, fhir, dicom |
education |
"course", "student", "learning", "lms", "quiz", "classroom" |
gaming |
"game", "player", "score", "level", "sprite", phaser, unity, godot, pixi.js |
ai-ml |
"model", "training", "inference", "prediction", tensorflow, pytorch, scikit-learn, transformers, langchain |
iot |
"sensor", "device", "mqtt", "firmware", "embedded", mqtt.js, johnny-five, raspberry |
media |
"stream", "video", "audio", "media", "content", ffmpeg, hls, webrtc |
saas |
"tenant", "subscription", "billing", "dashboard", "admin", "onboarding", "workspace" |
devtools |
"cli", "plugin", "extension", "lint", "compiler", "bundler", "sdk" |
data-pipeline |
"pipeline", "etl", "ingest", "warehouse", "transform", airflow, prefect, dagster, dbt |
social |
"chat", "message", "feed", "notification", "real-time", "presence", socket.io, pusher |
general |
No strong domain signals detected |
If domain is general, skip domain-specific suggestions. Otherwise, include domain-specific agents in Step 1 below.
Step 1: Match Detected Stack + Domain to Suggested Agents
Check Phase 1 results and Step 0 domain against these mappings. Only include agents whose detection conditions match:
JavaScript/TypeScript:
- react-specialist (sonnet) → if React or Next.js detected
"Expert in React component architecture, hooks, state management, and performance optimization"
- nextjs-specialist (sonnet) → if Next.js detected
"Expert in Next.js App Router, server components, API routes, and SSR/SSG strategies"
- vue-specialist (sonnet) → if Vue detected
"Expert in Vue 3 composition API, Pinia state management, and component patterns"
- angular-specialist (sonnet) → if Angular detected
"Expert in Angular modules, services, dependency injection, and RxJS patterns"
- node-api-specialist (sonnet) → if Express/Fastify/Koa detected
"Expert in Node.js API design, middleware patterns, route handling, and request validation"
- styling-specialist (haiku) → if Tailwind/styled-components/CSS modules detected
"Expert in styling architecture, responsive design, and CSS optimization"
Python:
- django-specialist (sonnet) → if Django detected
"Expert in Django models, views, serializers, middleware, and ORM optimization"
- flask-specialist (sonnet) → if Flask detected
"Expert in Flask blueprints, extensions, request handling, and API design"
- fastapi-specialist (sonnet) → if FastAPI detected
"Expert in FastAPI endpoints, Pydantic models, dependency injection, and async patterns"
- data-engineer (sonnet) → if pandas/numpy/scipy detected
"Expert in data pipelines, DataFrame operations, data cleaning, and transformation"
- ml-engineer (sonnet) → if tensorflow/pytorch/sklearn detected
"Expert in ML model architecture, training pipelines, and inference optimization"
Go:
- go-api-specialist (sonnet) → if Gin/Echo/Fiber detected
"Expert in Go HTTP handlers, middleware, routing, and concurrent request processing"
Rust:
- rust-systems (sonnet) → if Actix/Tokio detected
"Expert in Rust async patterns, ownership semantics, and systems-level optimization"
Database (any language):
- database-specialist (sonnet) → if Prisma/Sequelize/SQLAlchemy/TypeORM/Drizzle detected
"Expert in database schema design, query optimization, migrations, and ORM patterns"
Mobile:
- mobile-specialist (sonnet) → if React Native/Flutter detected
"Expert in mobile UI patterns, navigation, platform-specific APIs, and performance"
Monorepo:
- monorepo-specialist (haiku) → if Turborepo/Nx/Lerna detected
"Expert in monorepo architecture, workspace dependencies, and shared package management"
Domain-Based Suggestions (from Step 0 domain detection):
trading/finance:
- quant-expert (sonnet)
"Expert in trading algorithms, market data processing, order execution, risk calculations, and financial modeling"
- risk-analyst (sonnet)
"Expert in risk assessment, portfolio analysis, compliance checks, and financial regulations"
e-commerce:
- payment-specialist (sonnet)
"Expert in payment gateway integration, checkout flows, cart logic, and order management"
- catalog-specialist (haiku)
"Expert in product catalog management, search/filter, inventory, and pricing logic"
healthcare:
- compliance-specialist (sonnet)
"Expert in HIPAA compliance, patient data handling, audit trails, and healthcare regulations"
- ehr-specialist (sonnet)
"Expert in electronic health record systems, patient data models, and clinical workflows"
education:
- lms-specialist (sonnet)
"Expert in learning management systems, course structures, grading logic, and student progress tracking"
gaming:
- game-logic-specialist (sonnet)
"Expert in game state management, physics, rendering pipelines, and multiplayer sync"
ai-ml:
- ml-pipeline-expert (sonnet)
"Expert in training pipelines, model serving, feature engineering, and experiment tracking"
iot:
- device-specialist (sonnet)
"Expert in device communication protocols, sensor data processing, firmware updates, and telemetry"
media:
- media-pipeline-specialist (sonnet)
"Expert in media processing, transcoding, streaming protocols, and content delivery"
saas:
- auth-specialist (sonnet)
"Expert in authentication flows, RBAC, multi-tenancy, and session management"
- billing-specialist (sonnet)
"Expert in subscription billing, usage metering, invoice generation, and payment processing"
data-pipeline:
- etl-specialist (sonnet)
"Expert in data extraction, transformation, loading, scheduling, and pipeline orchestration"
social:
- realtime-specialist (sonnet)
"Expert in WebSocket connections, message queuing, presence systems, and notification delivery"
devtools:
- plugin-architect (sonnet)
"Expert in plugin/extension architecture, API design, CLI patterns, and developer experience"
If no frameworks/tools AND no domain detected (domain is `general`), skip this phase entirely and proceed to Phase 6.
#### Step 2: Present Agent Catalogue
Display all matched suggestions (both stack-based and domain-based) in a numbered table:
Suggested Custom Agents for This Project:
Based on your stack ({detected frameworks}) and domain ({detected domain}), these specialized agents can improve task routing:
| Agent | Model | Source | Specialization
1 | react-specialist | Sonnet | Stack | React component architecture, hooks, state management
2 | node-api-specialist | Sonnet | Stack | Node.js API design, middleware, route handling
3 | database-specialist | Sonnet | Stack | Database schema design, query optimization, ORM patterns
4 | quant-expert | Sonnet | Domain | Trading algorithms, market data, order execution
5 | risk-analyst | Sonnet | Domain | Risk assessment, portfolio analysis, compliance
These agents extend the built-in team with project-specific expertise.
Custom agents are automatically considered by the task router when their specialization matches a task.
#### Step 3: Ask User to Select
Present selection options and wait for user response:
Which agents would you like to add?
a) All — add all suggested agents
b) None — skip, use only built-in agents
c) Select by number — e.g. "1,3" or "1-3"
#### Step 4: Create Selected Agents
For each selected agent:
1. Create `.claude/crew-agents/` directory if it doesn't exist
2. Generate the agent definition file `.claude/crew-agents/{name}.md` using the appropriate model template with **pre-filled responsibilities** specific to the framework (NOT generic placeholders)
3. Register in `.claude/crew-team.json` under the `agents` key with `"custom": true, "active": true`
**Sonnet custom agent template** (pre-filled example for react-specialist):
```markdown
---
name: crew-{name}
description: {description from mapping}
model: sonnet
---
You are the **{Name}** at CodeCrew. {description from mapping}.
## INDEX-FIRST PROTOCOL (MANDATORY)
**INDEX-FIRST**: Read `.claude/crew-index.json` → `crew-symbols.json` → then only specific lines from source files. Never read entire files.
## Your Responsibilities
1. {Framework-specific responsibility 1}
2. {Framework-specific responsibility 2}
3. {Framework-specific responsibility 3}
4. {Framework-specific responsibility 4}
5. Follow project conventions and patterns detected in the codebase
6. Coordinate with other agents when changes span beyond your specialization
## Output Format
When done, report:
- What you changed (file paths + summary)
- FILES_MODIFIED: {list}
- Confidence level: high | medium | low
- Any concerns or dependencies
Haiku custom agent template:
---
name: crew-{name}
description: {description from mapping}
model: haiku
---
You are the **{Name}** at CodeCrew. {description from mapping}.
## INDEX-FIRST PROTOCOL (MANDATORY)
**INDEX-FIRST**: Read `.claude/crew-index.json` → `crew-symbols.json` → then only the lines you need. Never read entire files.
## Your Tasks
1. {Framework-specific task 1}
2. {Framework-specific task 2}
3. {Framework-specific task 3}
4. Follow project conventions detected in the codebase
5. If the task is too complex, report: "ESCALATE: Needs senior-dev or relevant sonnet specialist"
## Output
FILES_MODIFIED: {list}
CONFIDENCE: {high | medium | low}
Fill in the {Framework-specific responsibility/task} lines with real responsibilities relevant to the agent's specialization — do NOT leave them as generic placeholders. Use your knowledge of the framework to write 3-5 concrete responsibilities.
crew-team.json registration — add under agents:
"custom-{name}": {
"model": "{tier}",
"active": true,
"role": "{description}",
"custom": true,
"definitionPath": ".claude/crew-agents/{name}.md"
}
Step 5: Confirm
If agents were added:
Custom agents added: {n}
{name} ({model}), {name} ({model}), ...
These agents will be auto-selected by the task router when tasks match their specialization.
Manage custom agents anytime with /crew agent list|remove
If user selected "None":
No custom agents added. You can add them later with /crew agent create
Phase 6: Build Skill Catalog
Write .claude/crew-skills.json mapping all available ECC skills to categories:
{
"catalogVersion": 1,
"totalSkills": 125,
"relevantSkills": 45,
"categories": {
"always": [
"strategic-compact",
"context-budget",
"verification-loop",
"coding-standards",
"iterative-retrieval",
"search-first"
],
"stack": {
"javascript": ["typescript-patterns", "react-patterns", "nextjs-patterns", "backend-patterns"],
"python": ["python-patterns", "django-patterns"],
"go": ["golang-patterns"],
"rust": ["rust-patterns"]
},
"taskType": {
"bug-fix": ["iterative-retrieval", "deep-research", "codebase-onboarding"],
"feature": ["architecture-decision-records", "agentic-engineering", "blueprint"],
"test": ["tdd-workflow", "e2e-testing", "ai-regression-testing"],
"security": ["security-scanning"],
"docs": ["article-writing", "documentation-lookup"],
"devops": ["deployment-patterns", "docker-patterns", "database-migrations", "git-workflow"],
"review": ["verification-loop"],
"refactor": ["architecture-decision-records", "backend-patterns"],
"performance": ["cost-aware-llm-pipeline"]
}
},
"detectedStack": ["javascript"],
"activeSkills": ["typescript-patterns", "backend-patterns"]
}
Phase 7: Report
Display initialization summary to the user:
CodeCrew ready — {project-name}
{type} | {languages} | {count} files, {lines} lines
Agents: {count}/{total} (Opus: 1, Sonnet: X, Haiku: Y) | Skills: {relevant}/{total}
Use /crew task "desc" to delegate work.
1---2name: crew-init3description: Analyzes a project codebase, builds 3-layer index, generates project profile, and auto-configures the agent team with relevant skills. The main initialization skill for CodeCrew.4---56# Crew Init - Project Analysis & Team Setup78Full project initialization that transforms any codebase into a CodeCrew workspace with indexed code, profiled architecture, and a configured agent team.910## When to Activate1112- User runs `/crew init`13- User runs `/crew` with `init` argument14- First time using CodeCrew in a project1516## Initialization Pipeline1718### Phase 1: Project Discovery1920Scan the project to understand what we're working with:2122**1.1 Detect project type and languages:**23```24Use Glob to check for:25- package.json, tsconfig.json → Node.js / TypeScript26- requirements.txt, pyproject.toml, setup.py → Python27- go.mod → Go28- Cargo.toml → Rust29- pom.xml, build.gradle → Java / Kotlin30- Gemfile → Ruby31- composer.json → PHP32- Makefile, CMakeLists.txt → C/C++33- pubspec.yaml → Dart/Flutter34- *.sln, *.csproj → .NET/C#35```3637**1.2 Detect frameworks:**38```39Read package.json (or equivalent) for:40- react, next, vue, angular, svelte → Frontend framework41- express, fastify, koa, django, flask, gin, actix → Backend framework42- playwright, jest, pytest, mocha → Testing framework43- eslint, prettier, black, gofmt → Linting/formatting44- docker, kubernetes → Container/orchestration45```4647**1.3 Map project structure:**48```49Use Glob for directory layout:50- src/, lib/, app/ → Source code51- test/, tests/, __tests__, spec/ → Tests52- docs/, doc/ → Documentation53- .github/, .gitlab-ci.yml → CI/CD54- Dockerfile, docker-compose.yml → Docker55- scripts/, bin/ → Build/deploy scripts56```5758**1.4 Read existing context:**59- Read CLAUDE.md if it exists (project-specific instructions)60- Read README.md for project description61- Check git log for recent activity areas (if git repo)6263### Phase 2: Build Codebase Index6465Invoke the **codebase-index** skill in full-build mode:66671. Discover all source files (excluding node_modules, dist, build, etc.)682. For each file: read, hash, extract metadata (exports, imports, functions, classes, line count)693. Build call graph from import/export relationships704. Write `.claude/crew-index.json` (Layer 1 - compact)715. Write `.claude/crew-symbols.json` (Layer 2 - symbols)7273This enables the Index-First Protocol for all future agent interactions.7475### Phase 3: Generate Project Profile7677Write `.claude/crew-profile.md` with:7879```markdown80# Crew Profile: {project-name}8182## Overview83- **Type**: {web-app | api | cli | library | scraper | mobile | etc.}84- **Languages**: {detected languages}85- **Frameworks**: {detected frameworks}86- **Size**: {total files} files, {total lines} lines8788## Architecture89- **Entry Point**: {main file}90- **Pipeline/Flow**: {data flow description}91- **Patterns**: {MVC, pipeline, event-driven, microservice, etc.}9293## Key Directories94- **Source**: {src paths}95- **Tests**: {test paths}96- **Config**: {config files}97- **Docs**: {doc paths}9899## Tech Stack100- **Runtime**: {node, python, go, etc.}101- **Package Manager**: {npm, pip, cargo, etc.}102- **Testing**: {jest, pytest, etc.}103- **Linting**: {eslint, prettier, etc.}104- **CI/CD**: {github actions, gitlab ci, etc.}105- **Deployment**: {docker, k8s, vercel, etc.}106107## Index Status108- **Files Indexed**: {count}109- **Symbols Mapped**: {count}110- **Last Indexed**: {timestamp}111- **Index Files**: .claude/crew-index.json, .claude/crew-symbols.json112```113114### Phase 4: Configure Agent Team115116Based on detected stack, determine which agents are active and what skills they need.117118Write `.claude/crew-team.json`:119120```json121{122 "project": "project-name",123 "configured": "2026-04-04T12:00:00Z",124 "agents": {125 "ceo": {126 "model": "opus",127 "active": true,128 "role": "Task triage, decomposition, delegation, architecture decisions"129 },130 "vp-engineering": {131 "model": "sonnet",132 "active": true,133 "role": "Tech decisions, architecture review, complex planning"134 },135 "vp-quality": {136 "model": "sonnet",137 "active": true,138 "role": "Quality gates, test strategy, review coordination"139 },140 "senior-dev": {141 "model": "sonnet",142 "active": true,143 "role": "Complex implementation, multi-file changes"144 },145 "junior-dev": {146 "model": "haiku",147 "active": true,148 "role": "Simple fixes, formatting, small changes"149 },150 "code-reviewer": {151 "model": "sonnet",152 "active": true,153 "role": "Code review, quality assessment"154 },155 "debugger": {156 "model": "sonnet",157 "active": true,158 "role": "Bug investigation, root cause analysis"159 },160 "security-analyst": {161 "model": "sonnet",162 "active": false,163 "activateWhen": "security-related tasks or pre-deploy review"164 },165 "devops-engineer": {166 "model": "haiku",167 "active": false,168 "activateWhen": "Docker/CI/CD/deployment tasks detected"169 },170 "doc-writer": {171 "model": "haiku",172 "active": true,173 "role": "Documentation, comments, READMEs"174 },175 "test-engineer": {176 "model": "sonnet",177 "active": false,178 "activateWhen": "test directory detected or testing tasks"179 }180 },181 "activationRules": {182 "hasDocker": ["devops-engineer"],183 "hasTests": ["test-engineer"],184 "hasSecurity": ["security-analyst"],185 "always": ["ceo", "vp-engineering", "senior-dev", "junior-dev", "code-reviewer", "debugger", "doc-writer"]186 }187}188```189190Activate conditional agents based on detected stack:191- Found `Dockerfile` or `docker-compose.yml` → activate `devops-engineer`192- Found `test/` or testing framework → activate `test-engineer`193- Found `.env` or security configs → activate `security-analyst`194195### Phase 5: Suggest Custom Agents196197Based on Phase 1 detection results (languages, frameworks, tools), suggest project-specific custom agents that extend the built-in team. The number of suggestions is **dynamic** — more frameworks/tools detected = more suggestions.198199#### Step 0: Detect Project Domain200201Analyze available project signals to classify the project domain:2022031. **Project directory name** — check for keywords (e.g., "trading", "shop", "health", "game")2042. **README.md** — read first 50 lines for project description keywords2053. **package.json / pyproject.toml** — check `description` and `keywords` fields2064. **Directory names** — scan for domain-specific folders (e.g., `strategies/`, `orders/`, `cart/`, `patients/`)2075. **Import patterns** — check for domain-specific libraries (e.g., `ccxt`, `alpaca-trade-api`, `stripe`, `hl7`)208209Classify into ONE primary domain:210211| Domain | Detection Signals |212|--------|------------------|213| `trading/finance` | "trading", "bot", "strategy", "backtest", "portfolio", "hedge", "quant", ccxt, alpaca, binance, ta-lib, quantlib |214| `e-commerce` | "shop", "store", "cart", "checkout", "product", stripe, shopify, woocommerce, snipcart |215| `healthcare` | "patient", "health", "medical", "clinical", "ehr", hl7, fhir, dicom |216| `education` | "course", "student", "learning", "lms", "quiz", "classroom" |217| `gaming` | "game", "player", "score", "level", "sprite", phaser, unity, godot, pixi.js |218| `ai-ml` | "model", "training", "inference", "prediction", tensorflow, pytorch, scikit-learn, transformers, langchain |219| `iot` | "sensor", "device", "mqtt", "firmware", "embedded", mqtt.js, johnny-five, raspberry |220| `media` | "stream", "video", "audio", "media", "content", ffmpeg, hls, webrtc |221| `saas` | "tenant", "subscription", "billing", "dashboard", "admin", "onboarding", "workspace" |222| `devtools` | "cli", "plugin", "extension", "lint", "compiler", "bundler", "sdk" |223| `data-pipeline` | "pipeline", "etl", "ingest", "warehouse", "transform", airflow, prefect, dagster, dbt |224| `social` | "chat", "message", "feed", "notification", "real-time", "presence", socket.io, pusher |225| `general` | No strong domain signals detected |226227If domain is `general`, skip domain-specific suggestions. Otherwise, include domain-specific agents in Step 1 below.228229#### Step 1: Match Detected Stack + Domain to Suggested Agents230231Check Phase 1 results and Step 0 domain against these mappings. Only include agents whose detection conditions match:232233```234JavaScript/TypeScript:235 - react-specialist (sonnet) → if React or Next.js detected236 "Expert in React component architecture, hooks, state management, and performance optimization"237 - nextjs-specialist (sonnet) → if Next.js detected238 "Expert in Next.js App Router, server components, API routes, and SSR/SSG strategies"239 - vue-specialist (sonnet) → if Vue detected240 "Expert in Vue 3 composition API, Pinia state management, and component patterns"241 - angular-specialist (sonnet) → if Angular detected242 "Expert in Angular modules, services, dependency injection, and RxJS patterns"243 - node-api-specialist (sonnet) → if Express/Fastify/Koa detected244 "Expert in Node.js API design, middleware patterns, route handling, and request validation"245 - styling-specialist (haiku) → if Tailwind/styled-components/CSS modules detected246 "Expert in styling architecture, responsive design, and CSS optimization"247248Python:249 - django-specialist (sonnet) → if Django detected250 "Expert in Django models, views, serializers, middleware, and ORM optimization"251 - flask-specialist (sonnet) → if Flask detected252 "Expert in Flask blueprints, extensions, request handling, and API design"253 - fastapi-specialist (sonnet) → if FastAPI detected254 "Expert in FastAPI endpoints, Pydantic models, dependency injection, and async patterns"255 - data-engineer (sonnet) → if pandas/numpy/scipy detected256 "Expert in data pipelines, DataFrame operations, data cleaning, and transformation"257 - ml-engineer (sonnet) → if tensorflow/pytorch/sklearn detected258 "Expert in ML model architecture, training pipelines, and inference optimization"259260Go:261 - go-api-specialist (sonnet) → if Gin/Echo/Fiber detected262 "Expert in Go HTTP handlers, middleware, routing, and concurrent request processing"263264Rust:265 - rust-systems (sonnet) → if Actix/Tokio detected266 "Expert in Rust async patterns, ownership semantics, and systems-level optimization"267268Database (any language):269 - database-specialist (sonnet) → if Prisma/Sequelize/SQLAlchemy/TypeORM/Drizzle detected270 "Expert in database schema design, query optimization, migrations, and ORM patterns"271272Mobile:273 - mobile-specialist (sonnet) → if React Native/Flutter detected274 "Expert in mobile UI patterns, navigation, platform-specific APIs, and performance"275276Monorepo:277 - monorepo-specialist (haiku) → if Turborepo/Nx/Lerna detected278 "Expert in monorepo architecture, workspace dependencies, and shared package management"279```280281Domain-Based Suggestions (from Step 0 domain detection):282283trading/finance:284 - quant-expert (sonnet)285 "Expert in trading algorithms, market data processing, order execution, risk calculations, and financial modeling"286 - risk-analyst (sonnet)287 "Expert in risk assessment, portfolio analysis, compliance checks, and financial regulations"288289e-commerce:290 - payment-specialist (sonnet)291 "Expert in payment gateway integration, checkout flows, cart logic, and order management"292 - catalog-specialist (haiku)293 "Expert in product catalog management, search/filter, inventory, and pricing logic"294295healthcare:296 - compliance-specialist (sonnet)297 "Expert in HIPAA compliance, patient data handling, audit trails, and healthcare regulations"298 - ehr-specialist (sonnet)299 "Expert in electronic health record systems, patient data models, and clinical workflows"300301education:302 - lms-specialist (sonnet)303 "Expert in learning management systems, course structures, grading logic, and student progress tracking"304305gaming:306 - game-logic-specialist (sonnet)307 "Expert in game state management, physics, rendering pipelines, and multiplayer sync"308309ai-ml:310 - ml-pipeline-expert (sonnet)311 "Expert in training pipelines, model serving, feature engineering, and experiment tracking"312313iot:314 - device-specialist (sonnet)315 "Expert in device communication protocols, sensor data processing, firmware updates, and telemetry"316317media:318 - media-pipeline-specialist (sonnet)319 "Expert in media processing, transcoding, streaming protocols, and content delivery"320321saas:322 - auth-specialist (sonnet)323 "Expert in authentication flows, RBAC, multi-tenancy, and session management"324 - billing-specialist (sonnet)325 "Expert in subscription billing, usage metering, invoice generation, and payment processing"326327data-pipeline:328 - etl-specialist (sonnet)329 "Expert in data extraction, transformation, loading, scheduling, and pipeline orchestration"330331social:332 - realtime-specialist (sonnet)333 "Expert in WebSocket connections, message queuing, presence systems, and notification delivery"334335devtools:336 - plugin-architect (sonnet)337 "Expert in plugin/extension architecture, API design, CLI patterns, and developer experience"338```339340If no frameworks/tools AND no domain detected (domain is `general`), skip this phase entirely and proceed to Phase 6.341342#### Step 2: Present Agent Catalogue343344Display all matched suggestions (both stack-based and domain-based) in a numbered table:345346```347Suggested Custom Agents for This Project:348349Based on your stack ({detected frameworks}) and domain ({detected domain}), these specialized agents can improve task routing:350351 # | Agent | Model | Source | Specialization352 1 | react-specialist | Sonnet | Stack | React component architecture, hooks, state management353 2 | node-api-specialist | Sonnet | Stack | Node.js API design, middleware, route handling354 3 | database-specialist | Sonnet | Stack | Database schema design, query optimization, ORM patterns355 4 | quant-expert | Sonnet | Domain | Trading algorithms, market data, order execution356 5 | risk-analyst | Sonnet | Domain | Risk assessment, portfolio analysis, compliance357358These agents extend the built-in team with project-specific expertise.359Custom agents are automatically considered by the task router when their specialization matches a task.360```361362#### Step 3: Ask User to Select363364Present selection options and wait for user response:365366```367Which agents would you like to add?368 a) All — add all suggested agents369 b) None — skip, use only built-in agents370 c) Select by number — e.g. "1,3" or "1-3"371```372373#### Step 4: Create Selected Agents374375For each selected agent:3763771. Create `.claude/crew-agents/` directory if it doesn't exist3782. Generate the agent definition file `.claude/crew-agents/{name}.md` using the appropriate model template with **pre-filled responsibilities** specific to the framework (NOT generic placeholders)3793. Register in `.claude/crew-team.json` under the `agents` key with `"custom": true, "active": true`380381**Sonnet custom agent template** (pre-filled example for react-specialist):382383```markdown384---385name: crew-{name}386description: {description from mapping}387model: sonnet388---389390You are the **{Name}** at CodeCrew. {description from mapping}.391392## INDEX-FIRST PROTOCOL (MANDATORY)393394**INDEX-FIRST**: Read `.claude/crew-index.json` → `crew-symbols.json` → then only specific lines from source files. Never read entire files.395396## Your Responsibilities3973981. {Framework-specific responsibility 1}3992. {Framework-specific responsibility 2}4003. {Framework-specific responsibility 3}4014. {Framework-specific responsibility 4}4025. Follow project conventions and patterns detected in the codebase4036. Coordinate with other agents when changes span beyond your specialization404405## Output Format406407When done, report:408- What you changed (file paths + summary)409- FILES_MODIFIED: {list}410- Confidence level: high | medium | low411- Any concerns or dependencies412```413414**Haiku custom agent template:**415416```markdown417---418name: crew-{name}419description: {description from mapping}420model: haiku421---422423You are the **{Name}** at CodeCrew. {description from mapping}.424425## INDEX-FIRST PROTOCOL (MANDATORY)426427**INDEX-FIRST**: Read `.claude/crew-index.json` → `crew-symbols.json` → then only the lines you need. Never read entire files.428429## Your Tasks4304311. {Framework-specific task 1}4322. {Framework-specific task 2}4333. {Framework-specific task 3}4344. Follow project conventions detected in the codebase4355. If the task is too complex, report: "ESCALATE: Needs senior-dev or relevant sonnet specialist"436437## Output438439FILES_MODIFIED: {list}440CONFIDENCE: {high | medium | low}441```442443Fill in the `{Framework-specific responsibility/task}` lines with real responsibilities relevant to the agent's specialization — do NOT leave them as generic placeholders. Use your knowledge of the framework to write 3-5 concrete responsibilities.444445**crew-team.json registration** — add under `agents`:446```json447"custom-{name}": {448 "model": "{tier}",449 "active": true,450 "role": "{description}",451 "custom": true,452 "definitionPath": ".claude/crew-agents/{name}.md"453}454```455456#### Step 5: Confirm457458If agents were added:459```460Custom agents added: {n}461 {name} ({model}), {name} ({model}), ...462463These agents will be auto-selected by the task router when tasks match their specialization.464Manage custom agents anytime with /crew agent list|remove465```466467If user selected "None":468```469No custom agents added. You can add them later with /crew agent create470```471472### Phase 6: Build Skill Catalog473474Write `.claude/crew-skills.json` mapping all available ECC skills to categories:475476```json477{478 "catalogVersion": 1,479 "totalSkills": 125,480 "relevantSkills": 45,481 "categories": {482 "always": [483 "strategic-compact",484 "context-budget",485 "verification-loop",486 "coding-standards",487 "iterative-retrieval",488 "search-first"489 ],490 "stack": {491 "javascript": ["typescript-patterns", "react-patterns", "nextjs-patterns", "backend-patterns"],492 "python": ["python-patterns", "django-patterns"],493 "go": ["golang-patterns"],494 "rust": ["rust-patterns"]495 },496 "taskType": {497 "bug-fix": ["iterative-retrieval", "deep-research", "codebase-onboarding"],498 "feature": ["architecture-decision-records", "agentic-engineering", "blueprint"],499 "test": ["tdd-workflow", "e2e-testing", "ai-regression-testing"],500 "security": ["security-scanning"],501 "docs": ["article-writing", "documentation-lookup"],502 "devops": ["deployment-patterns", "docker-patterns", "database-migrations", "git-workflow"],503 "review": ["verification-loop"],504 "refactor": ["architecture-decision-records", "backend-patterns"],505 "performance": ["cost-aware-llm-pipeline"]506 }507 },508 "detectedStack": ["javascript"],509 "activeSkills": ["typescript-patterns", "backend-patterns"]510}511```512513### Phase 7: Report514515Display initialization summary to the user:516517```518CodeCrew ready — {project-name}519 {type} | {languages} | {count} files, {lines} lines520 Agents: {count}/{total} (Opus: 1, Sonnet: X, Haiku: Y) | Skills: {relevant}/{total}521522Use /crew task "desc" to delegate work.523```