legion-cc 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -4
- package/VERSION +1 -1
- package/agents/legion-orchestrator.md +25 -0
- package/bin/lib/config.cjs +56 -0
- package/bin/lib/state.cjs +6 -0
- package/commands/legion/codebase/init.md +67 -0
- package/commands/legion/codebase/update.md +58 -0
- package/commands/legion/dev/analyze.md +61 -0
- package/commands/legion/dev/cycle.md +60 -0
- package/commands/legion/dev/quick.md +59 -0
- package/commands/legion/devops/cycle.md +6 -6
- package/commands/legion/devops/quick.md +7 -7
- package/commands/legion/status.md +1 -1
- package/package.json +1 -1
- package/references/codebase/agent-map.md +130 -0
- package/references/codebase/output-specs.md +362 -0
- package/references/codebase/routing-rules.md +174 -0
- package/references/dev/agent-map.md +187 -0
- package/references/dev/pipeline-patterns.md +140 -0
- package/references/dev/sub-agents/analyze-sub-agents.md +76 -0
- package/references/dev/sub-agents/architect-sub-agents.md +37 -0
- package/references/dev/sub-agents/code-analyst-sub-agents.md +39 -0
- package/references/dev/sub-agents/implement-sub-agents.md +48 -0
- package/references/dev/sub-agents/plan-sub-agents.md +50 -0
- package/references/dev/sub-agents/review-sub-agents.md +48 -0
- package/references/dev/sub-agents/task-designer-sub-agents.md +44 -0
- package/references/dev/sub-agents/verify-sub-agents.md +71 -0
- package/references/devops/agent-map.md +38 -7
- package/references/devops/pipeline-patterns.md +12 -3
- package/references/domain-registry.md +33 -8
- package/templates/codebase/BRIEF.md +32 -0
- package/templates/codebase/CHANGELOG.md +21 -0
- package/templates/codebase/INDEX.md +35 -0
- package/templates/dev/analyze-output.md +390 -0
- package/templates/dev/cycle-output.md +196 -0
- package/templates/state.md +1 -0
- package/workflows/codebase/init.md +543 -0
- package/workflows/codebase/update.md +294 -0
- package/workflows/core/context-load.md +22 -2
- package/workflows/dev/analyze.md +168 -0
- package/workflows/dev/cycle.md +551 -0
- package/workflows/dev/quick.md +250 -0
- package/workflows/devops/architect.md +126 -0
- package/workflows/devops/cycle.md +239 -177
- package/workflows/devops/execute.md +115 -0
- package/workflows/devops/plan.md +111 -0
- package/workflows/devops/quick.md +133 -35
- package/workflows/devops/review.md +109 -0
- package/workflows/settings.md +1 -1
- package/workflows/status.md +2 -2
- package/commands/legion/devops/init.md +0 -53
- package/workflows/devops/init.md +0 -100
package/README.md
CHANGED
|
@@ -65,7 +65,8 @@ npx legion-cc@latest --uninstall # remove Legion
|
|
|
65
65
|
| `/legion:devops:architect <task>` | Design infrastructure architecture with the `devops-architect` agent (opus). |
|
|
66
66
|
| `/legion:devops:plan [path]` | Decompose architecture into an implementation plan with `delivery-planner` (sonnet). Uses latest architect artifact if no path given. |
|
|
67
67
|
| `/legion:devops:execute [path]` | Implement the plan with `infra-executor` (opus). Supports `--task T1` to run a single task. |
|
|
68
|
-
| `/legion:
|
|
68
|
+
| `/legion:codebase:init` | Scan the codebase with 9 parallel mapper agents, create `.legion/codebase/` documentation. |
|
|
69
|
+
| `/legion:codebase:update [ref]` | Incrementally update `.legion/codebase/` docs based on git changes since last run. |
|
|
69
70
|
| `/legion:devops:review [path]` | Review changes against architectural intent with `devops-architect` in review mode (sonnet). |
|
|
70
71
|
| `/legion:devops:cycle <task>` | Run the full pipeline (architect → plan → execute → review) with checkpoints after architect and plan. |
|
|
71
72
|
|
|
@@ -87,7 +88,8 @@ legion/
|
|
|
87
88
|
│ └── lib/ # Modules: config, core, domain, init, session, state
|
|
88
89
|
├── commands/ # Claude Code slash commands (.md frontmatter + execution prompt)
|
|
89
90
|
│ └── legion/
|
|
90
|
-
│ ├──
|
|
91
|
+
│ ├── codebase/ # /legion:codebase:* commands (init, update)
|
|
92
|
+
│ ├── devops/ # /legion:devops:* commands
|
|
91
93
|
│ ├── resume.md
|
|
92
94
|
│ └── status.md
|
|
93
95
|
├── hooks/ # Claude Code hooks (Node.js)
|
|
@@ -97,13 +99,16 @@ legion/
|
|
|
97
99
|
│ ├── agent-routing.md
|
|
98
100
|
│ ├── domain-registry.md
|
|
99
101
|
│ ├── ui-brand.md
|
|
102
|
+
│ ├── codebase/ # agent-map.md, output-specs.md, routing-rules.md
|
|
100
103
|
│ └── devops/
|
|
101
104
|
│ ├── agent-map.md
|
|
102
105
|
│ └── pipeline-patterns.md
|
|
103
106
|
├── templates/ # State, session, artifact, and config templates
|
|
107
|
+
│ ├── codebase/ # INDEX.md, BRIEF.md, CHANGELOG.md templates
|
|
104
108
|
│ └── devops/ # Artifact templates (architect, plan, execution, review)
|
|
105
109
|
├── workflows/ # Step-by-step execution logic referenced by commands
|
|
106
110
|
│ ├── core/ # init, context-load, completion (shared across domains)
|
|
111
|
+
│ ├── codebase/ # init.md, update.md
|
|
107
112
|
│ └── devops/ # One workflow per command
|
|
108
113
|
├── package.json
|
|
109
114
|
└── VERSION
|
|
@@ -118,7 +123,7 @@ legion/
|
|
|
118
123
|
| `devops-architect` | Senior/Lead DevOps Architect — infrastructure design, security assessment, migration planning, HA/DR | opus (architect) / sonnet (review) | `architect`, `review`, `cycle` |
|
|
119
124
|
| `delivery-planner` | Senior Delivery Planner — work decomposition, phased planning, dependency mapping, risk assessment | sonnet | `plan`, `cycle` |
|
|
120
125
|
| `infra-executor` | Elite Infrastructure Execution Specialist — Terraform, CI/CD, Kubernetes, AWS resource management | opus | `execute`, `cycle` |
|
|
121
|
-
| `codebase-builder` | Elite Codebase Builder — project scaffolding, `.legion/codebase/` documentation creation, existing project analysis | opus | `init` |
|
|
126
|
+
| `codebase-builder` | Elite Codebase Builder — project scaffolding, `.legion/codebase/` documentation creation, existing project analysis | opus | `codebase:init` |
|
|
122
127
|
|
|
123
128
|
The `devops-architect` agent doubles as reviewer: the same agent definition is invoked with a review prompt at sonnet model for the review stage.
|
|
124
129
|
|
|
@@ -179,7 +184,7 @@ Checkpoints default to ON after architect and plan, OFF after execute and review
|
|
|
179
184
|
|
|
180
185
|
**Documentation first** — existing project without `.legion/codebase/` docs:
|
|
181
186
|
```
|
|
182
|
-
/legion:
|
|
187
|
+
/legion:codebase:init
|
|
183
188
|
/legion:devops:architect "migration plan"
|
|
184
189
|
```
|
|
185
190
|
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.9.0
|
|
@@ -24,28 +24,53 @@ Analyze the task and classify into one of these categories:
|
|
|
24
24
|
|
|
25
25
|
### architecture
|
|
26
26
|
**Agent**: devops-architect (opus)
|
|
27
|
+
**What it does**: Analyzes existing infrastructure, designs target-state architecture, evaluates technology trade-offs, produces architecture decision records
|
|
27
28
|
**Triggers**: Design decisions, technology evaluation, migration strategy, HA/DR planning, security architecture, infrastructure design, capacity planning, comparing options
|
|
28
29
|
**Keywords**: design, architect, propose, evaluate, strategy, migration, HA, DR, compare options, should we use, how to design
|
|
30
|
+
**Example tasks**:
|
|
31
|
+
- "Design a multi-AZ RDS setup with read replicas"
|
|
32
|
+
- "Evaluate options for migrating from self-managed Redis to ElastiCache"
|
|
33
|
+
- "Should we use ECS Fargate or EKS for our microservices?"
|
|
29
34
|
|
|
30
35
|
### planning
|
|
31
36
|
**Agent**: delivery-planner (sonnet)
|
|
37
|
+
**What it does**: Decomposes architecture into phased task cards with dependencies, risk levels, rollback procedures, and validation gates
|
|
32
38
|
**Triggers**: Breaking down work, creating implementation plans, task decomposition, phased rollout planning, dependency analysis
|
|
33
39
|
**Keywords**: plan, decompose, break down, create tasks, implementation plan, phases, rollout, what steps, how to implement
|
|
40
|
+
**Example tasks**:
|
|
41
|
+
- "Break down the EKS migration into implementation tasks"
|
|
42
|
+
- "Create a rollout plan for the new monitoring stack"
|
|
43
|
+
- "What steps are needed to enable IRSA across all services?"
|
|
34
44
|
|
|
35
45
|
### execution
|
|
36
46
|
**Agent**: infra-executor (opus)
|
|
47
|
+
**What it does**: Writes Terraform modules, modifies CI/CD pipelines, updates Kubernetes manifests, validates with `terraform fmt/validate/plan`, reports evidence
|
|
37
48
|
**Triggers**: Writing Terraform code, modifying infrastructure, fixing configs, updating pipelines, creating AWS resources, changing security groups
|
|
38
49
|
**Keywords**: implement, create, add, write, fix, update, change, terraform, pipeline, module, resource, deploy, configure
|
|
50
|
+
**Example tasks**:
|
|
51
|
+
- "Add ingress rule for port 8443 to eks-node security group"
|
|
52
|
+
- "Create a Terraform module for SQS with DLQ"
|
|
53
|
+
- "Fix the GitHub Actions workflow for staging deployments"
|
|
39
54
|
|
|
40
55
|
### init
|
|
41
56
|
**Agent**: codebase-builder (opus)
|
|
57
|
+
**What it does**: Scans project structure, dispatches mapper agents, generates `.legion/codebase/` documentation with architecture, dependencies, and concerns
|
|
42
58
|
**Triggers**: New project setup, scaffolding, creating .legion/codebase/ documentation, initializing project structure
|
|
43
59
|
**Keywords**: scaffold, init, setup, create project, new project, .legion/codebase/, document structure, bootstrap
|
|
60
|
+
**Example tasks**:
|
|
61
|
+
- "Scan this project and create documentation"
|
|
62
|
+
- "Initialize .legion/codebase/ for the backend service"
|
|
63
|
+
- "Scaffold a new Terraform project for our AWS infrastructure"
|
|
44
64
|
|
|
45
65
|
### review
|
|
46
66
|
**Agent**: devops-architect (sonnet, review mode)
|
|
67
|
+
**What it does**: Validates code against architecture design, checks for security issues, drift, and regressions, reports findings with severity levels
|
|
47
68
|
**Triggers**: Code review, security audit, architecture validation, compliance check, best practices review
|
|
48
69
|
**Keywords**: review, audit, check, validate, security review, compliance, best practices
|
|
70
|
+
**Example tasks**:
|
|
71
|
+
- "Review the RDS module for security best practices"
|
|
72
|
+
- "Audit IAM policies in ./aws/modules/iam/"
|
|
73
|
+
- "Check if the EKS changes match the original architecture design"
|
|
49
74
|
|
|
50
75
|
## Classification Process
|
|
51
76
|
|
package/bin/lib/config.cjs
CHANGED
|
@@ -97,6 +97,62 @@ const DOMAIN_DEFAULTS = {
|
|
|
97
97
|
discovery: true,
|
|
98
98
|
},
|
|
99
99
|
},
|
|
100
|
+
dev: {
|
|
101
|
+
version: '0.1.0',
|
|
102
|
+
domain: 'dev',
|
|
103
|
+
agents: {
|
|
104
|
+
architect: 'general-purpose',
|
|
105
|
+
codeAnalyst: 'general-purpose',
|
|
106
|
+
taskDesigner: 'general-purpose',
|
|
107
|
+
planner: 'delivery-planner',
|
|
108
|
+
implementer: 'general-purpose',
|
|
109
|
+
verifier: 'general-purpose',
|
|
110
|
+
reviewer: 'general-purpose',
|
|
111
|
+
postAnalyze: 'general-purpose',
|
|
112
|
+
briefWriter: 'general-purpose'
|
|
113
|
+
},
|
|
114
|
+
models: {
|
|
115
|
+
architect: 'haiku',
|
|
116
|
+
codeAnalyst: 'sonnet',
|
|
117
|
+
taskDesigner: 'opus',
|
|
118
|
+
planner: 'sonnet',
|
|
119
|
+
implementer: 'opus',
|
|
120
|
+
verifier: 'sonnet',
|
|
121
|
+
reviewer: 'sonnet',
|
|
122
|
+
postAnalyze: 'sonnet',
|
|
123
|
+
briefWriter: 'haiku'
|
|
124
|
+
},
|
|
125
|
+
pipeline: ['architect', 'code-analyst', 'task-designer', 'plan', 'implement', 'verify', 'review', 'post-analyze', 'brief'],
|
|
126
|
+
checkpoints: {
|
|
127
|
+
after_task_designer: true,
|
|
128
|
+
after_planner: true,
|
|
129
|
+
after_verifier: false,
|
|
130
|
+
after_post_analyze: false,
|
|
131
|
+
after_brief_writer: false
|
|
132
|
+
},
|
|
133
|
+
parallelism: { minAgents: 5, maxAgents: 12 },
|
|
134
|
+
mcp: {
|
|
135
|
+
enforce: true,
|
|
136
|
+
discovery: true
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
codebase: {
|
|
140
|
+
version: '0.1.0',
|
|
141
|
+
domain: 'codebase',
|
|
142
|
+
agents: {
|
|
143
|
+
builder: 'codebase-builder',
|
|
144
|
+
},
|
|
145
|
+
models: {
|
|
146
|
+
builder: 'sonnet',
|
|
147
|
+
},
|
|
148
|
+
pipeline: ['init'],
|
|
149
|
+
checkpoints: {},
|
|
150
|
+
parallelism: { minAgents: 9, maxAgents: 12 },
|
|
151
|
+
mcp: {
|
|
152
|
+
enforce: true,
|
|
153
|
+
discovery: true,
|
|
154
|
+
},
|
|
155
|
+
},
|
|
100
156
|
};
|
|
101
157
|
|
|
102
158
|
// ─── Config Functions ────────────────────────────────────────────────────────
|
package/bin/lib/state.cjs
CHANGED
|
@@ -22,6 +22,7 @@ function loadState(planningDir) {
|
|
|
22
22
|
project: {
|
|
23
23
|
domain: '',
|
|
24
24
|
lastActivity: '',
|
|
25
|
+
lastCodebaseUpdate: '',
|
|
25
26
|
},
|
|
26
27
|
currentWork: {
|
|
27
28
|
pipeline: '',
|
|
@@ -65,6 +66,9 @@ function loadState(planningDir) {
|
|
|
65
66
|
|
|
66
67
|
const activityMatch = line.match(/^Last activity:\s*(.+)$/);
|
|
67
68
|
if (activityMatch) state.project.lastActivity = activityMatch[1].trim();
|
|
69
|
+
|
|
70
|
+
const codebaseUpdateMatch = line.match(/^Last codebase update:\s*(.+)$/);
|
|
71
|
+
if (codebaseUpdateMatch) state.project.lastCodebaseUpdate = codebaseUpdateMatch[1].trim();
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
if (section === 'currentWork') {
|
|
@@ -136,6 +140,7 @@ function saveState(planningDir, stateObj) {
|
|
|
136
140
|
lines.push('## Project');
|
|
137
141
|
lines.push(`Domain: ${stateObj.project.domain}`);
|
|
138
142
|
lines.push(`Last activity: ${stateObj.project.lastActivity}`);
|
|
143
|
+
lines.push(`Last codebase update: ${stateObj.project.lastCodebaseUpdate}`);
|
|
139
144
|
lines.push('');
|
|
140
145
|
lines.push('## Current Work');
|
|
141
146
|
lines.push(`Pipeline: ${stateObj.currentWork.pipeline}`);
|
|
@@ -300,6 +305,7 @@ function initState(planningDir, domain) {
|
|
|
300
305
|
project: {
|
|
301
306
|
domain: domain || 'devops',
|
|
302
307
|
lastActivity: `${currentTimestamp('date')} \u2014 initialized`,
|
|
308
|
+
lastCodebaseUpdate: '',
|
|
303
309
|
},
|
|
304
310
|
currentWork: {
|
|
305
311
|
pipeline: 'init -> cycle -> quick',
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: legion:codebase:init
|
|
3
|
+
description: "Create comprehensive project documentation in .legion/codebase/ using 9 parallel mapper agents"
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- Read
|
|
6
|
+
- Write
|
|
7
|
+
- Edit
|
|
8
|
+
- Glob
|
|
9
|
+
- Grep
|
|
10
|
+
- Bash
|
|
11
|
+
- Task
|
|
12
|
+
- WebSearch
|
|
13
|
+
- WebFetch
|
|
14
|
+
- ToolSearch
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Legion Codebase Init
|
|
18
|
+
|
|
19
|
+
Create a living knowledge base about the project. Scans the codebase with 9 parallel mapper agents, then synthesizes INDEX.md and BRIEF.md.
|
|
20
|
+
|
|
21
|
+
## Execution
|
|
22
|
+
|
|
23
|
+
Follow the workflow at @~/.claude/legion/workflows/codebase/init.md
|
|
24
|
+
|
|
25
|
+
### Quick Reference
|
|
26
|
+
|
|
27
|
+
**Initialization**: @~/.claude/legion/workflows/core/init.md
|
|
28
|
+
**Context Loading**: @~/.claude/legion/workflows/core/context-load.md
|
|
29
|
+
**Completion**: @~/.claude/legion/workflows/core/completion.md
|
|
30
|
+
**Agent Map**: @~/.claude/legion/references/codebase/agent-map.md
|
|
31
|
+
**Output Specs**: @~/.claude/legion/references/codebase/output-specs.md
|
|
32
|
+
**Routing Rules**: @~/.claude/legion/references/codebase/routing-rules.md
|
|
33
|
+
|
|
34
|
+
### What It Creates
|
|
35
|
+
|
|
36
|
+
Up to 12 documentation files in `.legion/codebase/`:
|
|
37
|
+
|
|
38
|
+
**Always generated (7)**:
|
|
39
|
+
- STACK.md — Technology stack
|
|
40
|
+
- ARCHITECTURE.md — System architecture
|
|
41
|
+
- CONVENTIONS.md — Code conventions
|
|
42
|
+
- DEPENDENCIES.md — Dependency graph
|
|
43
|
+
- CONCERNS.md — Tech debt & risks
|
|
44
|
+
- INDEX.md — Document map
|
|
45
|
+
- BRIEF.md — 30-second overview
|
|
46
|
+
|
|
47
|
+
**Conditionally generated (4)** — only if relevant code found:
|
|
48
|
+
- INFRASTRUCTURE.md — Cloud/infra (if terraform/helm/k8s files detected)
|
|
49
|
+
- CI_CD.md — Pipelines (if CI configs detected)
|
|
50
|
+
- SECURITY.md — Security posture (if security configs detected)
|
|
51
|
+
- OPERATIONS.md — Monitoring & ops (if ops configs detected)
|
|
52
|
+
|
|
53
|
+
### Pipeline Position
|
|
54
|
+
|
|
55
|
+
Standalone command — replaces `/legion:devops:init` for documentation:
|
|
56
|
+
```
|
|
57
|
+
[codebase:init] → codebase:update (for keeping docs fresh)
|
|
58
|
+
→ devops:cycle (for infrastructure work)
|
|
59
|
+
→ devops:quick (for single tasks)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Key Rules
|
|
63
|
+
- Fingerprints the project first to determine which mappers to run
|
|
64
|
+
- Only dispatches mappers for which relevant files exist
|
|
65
|
+
- All mappers use `subagent_type="codebase-builder"`
|
|
66
|
+
- arch-mapper uses opus model, all others use sonnet
|
|
67
|
+
- MCP tools mandatory (ToolSearch before file operations)
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: legion:codebase:update
|
|
3
|
+
description: "Incrementally update .legion/codebase/ documentation based on git changes"
|
|
4
|
+
argument-hint: "[since-ref]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Edit
|
|
9
|
+
- Glob
|
|
10
|
+
- Grep
|
|
11
|
+
- Bash
|
|
12
|
+
- Task
|
|
13
|
+
- WebSearch
|
|
14
|
+
- WebFetch
|
|
15
|
+
- ToolSearch
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Legion Codebase Update
|
|
19
|
+
|
|
20
|
+
Incrementally update project documentation based on git changes. Uses routing rules to dispatch only the mapper agents affected by recent changes.
|
|
21
|
+
|
|
22
|
+
## Execution
|
|
23
|
+
|
|
24
|
+
Follow the workflow at @~/.claude/legion/workflows/codebase/update.md
|
|
25
|
+
|
|
26
|
+
### Quick Reference
|
|
27
|
+
|
|
28
|
+
**Initialization**: @~/.claude/legion/workflows/core/init.md
|
|
29
|
+
**Context Loading**: @~/.claude/legion/workflows/core/context-load.md
|
|
30
|
+
**Completion**: @~/.claude/legion/workflows/core/completion.md
|
|
31
|
+
**Agent Map**: @~/.claude/legion/references/codebase/agent-map.md
|
|
32
|
+
**Routing Rules**: @~/.claude/legion/references/codebase/routing-rules.md
|
|
33
|
+
|
|
34
|
+
### How It Works
|
|
35
|
+
|
|
36
|
+
1. Analyzes `git diff` since last update (or provided ref)
|
|
37
|
+
2. Routes changed files to appropriate mappers using routing rules
|
|
38
|
+
3. Only dispatches affected mappers (not all 9)
|
|
39
|
+
4. Re-runs synthesizers (INDEX, BRIEF, CHANGELOG)
|
|
40
|
+
5. Appends entry to CHANGELOG.md
|
|
41
|
+
|
|
42
|
+
### Input
|
|
43
|
+
|
|
44
|
+
Optional: `$ARGUMENTS` can specify a git ref to diff against (commit hash, tag, or branch). If not provided, uses the last update timestamp from STATE.md.
|
|
45
|
+
|
|
46
|
+
### Pipeline Position
|
|
47
|
+
|
|
48
|
+
Maintenance command — run after making changes:
|
|
49
|
+
```
|
|
50
|
+
[codebase:init] → [codebase:update] → [codebase:update] → ...
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Key Rules
|
|
54
|
+
- `.legion/codebase/` must exist first (run `/legion:codebase:init`)
|
|
55
|
+
- concerns-mapper always runs on every update
|
|
56
|
+
- Mappers do FULL rewrites (not patches) of their files
|
|
57
|
+
- CHANGELOG.md is only generated in update mode
|
|
58
|
+
- Conditional mappers only dispatch if their output file already exists
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: legion:dev:analyze
|
|
3
|
+
description: "Code optimization scan — 6 parallel agents analyze performance, reliability, architecture, and cost"
|
|
4
|
+
argument-hint: "[scope: path or concern]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Edit
|
|
9
|
+
- Glob
|
|
10
|
+
- Grep
|
|
11
|
+
- Bash
|
|
12
|
+
- Task
|
|
13
|
+
- WebSearch
|
|
14
|
+
- WebFetch
|
|
15
|
+
- ToolSearch
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Legion Dev Analyze
|
|
19
|
+
|
|
20
|
+
Standalone code optimization scan. Dispatches 6 parallel agents to find bottlenecks, reliability issues, architecture smells, and cost optimization opportunities. Analysis only — no implementation.
|
|
21
|
+
|
|
22
|
+
## Execution
|
|
23
|
+
|
|
24
|
+
Follow the workflow at @~/.claude/legion/workflows/dev/analyze.md
|
|
25
|
+
|
|
26
|
+
### Quick Reference
|
|
27
|
+
|
|
28
|
+
**Initialization**: @~/.claude/legion/workflows/core/init.md
|
|
29
|
+
**Context Loading**: @~/.claude/legion/workflows/core/context-load.md
|
|
30
|
+
**Completion**: @~/.claude/legion/workflows/core/completion.md
|
|
31
|
+
**Agent Map**: @~/.claude/legion/references/dev/agent-map.md
|
|
32
|
+
|
|
33
|
+
### Scope Parameter
|
|
34
|
+
|
|
35
|
+
| Usage | What it scans |
|
|
36
|
+
|-------|--------------|
|
|
37
|
+
| `/legion:dev:analyze` | Entire project |
|
|
38
|
+
| `/legion:dev:analyze src/api/` | Specific directory |
|
|
39
|
+
| `/legion:dev:analyze "database performance"` | Specific concern across codebase |
|
|
40
|
+
|
|
41
|
+
### Parallel Agents
|
|
42
|
+
|
|
43
|
+
| Agent | Focus | Model |
|
|
44
|
+
|-------|-------|-------|
|
|
45
|
+
| opt-perf-hotpaths | CPU/memory bottlenecks, hot code paths | sonnet |
|
|
46
|
+
| opt-db-queries | N+1 queries, missing indexes, ORM anti-patterns | sonnet |
|
|
47
|
+
| opt-io-network | Timeouts, retry logic, batching, compression | haiku |
|
|
48
|
+
| opt-memory-gc | Memory leaks, allocations, cache sizing | haiku |
|
|
49
|
+
| opt-arch-smells | Circular deps, layer violations, duplication | haiku |
|
|
50
|
+
| opt-infra-cost | Over-provisioning, autoscaling, log/storage costs | haiku |
|
|
51
|
+
|
|
52
|
+
### Output
|
|
53
|
+
|
|
54
|
+
- `OPTIMIZATION_REPORT.md` — Full analysis with top-10 findings, categorized issues, recommendations
|
|
55
|
+
- `SUMMARY.md` — Quick overview with key findings and quick wins
|
|
56
|
+
|
|
57
|
+
### Follow-Up
|
|
58
|
+
|
|
59
|
+
To implement findings:
|
|
60
|
+
- `/legion:dev:cycle "Implement optimization: {finding}"` — for complex changes
|
|
61
|
+
- `/legion:dev:quick "Fix: {quick win}"` — for simple improvements
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: legion:dev:cycle
|
|
3
|
+
description: "Full Dev pipeline — 9-stage cycle: architect → code-analyst → task-designer → plan → implement → verify → review → post-analyze → brief"
|
|
4
|
+
argument-hint: "<task description>"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Edit
|
|
9
|
+
- Glob
|
|
10
|
+
- Grep
|
|
11
|
+
- Bash
|
|
12
|
+
- Task
|
|
13
|
+
- WebSearch
|
|
14
|
+
- WebFetch
|
|
15
|
+
- ToolSearch
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Legion Dev Cycle
|
|
19
|
+
|
|
20
|
+
Run the complete Dev pipeline in one command with approval checkpoints.
|
|
21
|
+
|
|
22
|
+
## Execution
|
|
23
|
+
|
|
24
|
+
Follow the workflow at @~/.claude/legion/workflows/dev/cycle.md
|
|
25
|
+
|
|
26
|
+
### Quick Reference
|
|
27
|
+
|
|
28
|
+
**Initialization**: @~/.claude/legion/workflows/core/init.md
|
|
29
|
+
**Context Loading**: @~/.claude/legion/workflows/core/context-load.md
|
|
30
|
+
**Completion**: @~/.claude/legion/workflows/core/completion.md
|
|
31
|
+
**Agent Map**: @~/.claude/legion/references/dev/agent-map.md
|
|
32
|
+
|
|
33
|
+
### Pipeline Stages
|
|
34
|
+
|
|
35
|
+
| Stage | Role | Model | What it does | Checkpoint |
|
|
36
|
+
|-------|------|-------|-------------|------------|
|
|
37
|
+
| 1. Architect | general-purpose | haiku | Maps repo structure, boundaries, conventions, infra touchpoints | — |
|
|
38
|
+
| 2. Code Analyst | general-purpose | sonnet | Traces call graphs, data flows, external deps, test coverage | — |
|
|
39
|
+
| 3. Task Designer | general-purpose | opus | Designs solution options, contracts, migrations, security | ✓ User approval |
|
|
40
|
+
| 4. Planner | delivery-planner | sonnet | Decomposes design into ordered tasks with deps and rollback | ✓ User approval |
|
|
41
|
+
| 5. Implementer | general-purpose | opus | Writes code, configs, infra changes per plan | — |
|
|
42
|
+
| 6. Verifier | general-purpose | sonnet | Runs tests, lint, IaC validation | — |
|
|
43
|
+
| 7. Reviewer | general-purpose | sonnet | Reviews arch fit, code quality, security, ops, API compat | — |
|
|
44
|
+
| 8. Post-Analyze | general-purpose | sonnet | Finds perf bottlenecks, DB issues, arch smells, cost optimizations | — |
|
|
45
|
+
| 9. Brief Writer | general-purpose | haiku | Produces SUMMARY.md, updates codebase docs | — |
|
|
46
|
+
|
|
47
|
+
### Checkpoints
|
|
48
|
+
|
|
49
|
+
After stages 3 (task-designer) and 4 (planner), the workflow pauses and asks the user to confirm. Options:
|
|
50
|
+
- **Approve** — continue to next stage
|
|
51
|
+
- **Revise** — re-run the stage with feedback
|
|
52
|
+
- **Stop** — save progress and exit (resume with `/legion:resume`)
|
|
53
|
+
|
|
54
|
+
### Pipeline Flow
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
[architect] → [code-analyst] → [task-designer] ──checkpoint──►
|
|
58
|
+
[planner] ──checkpoint──► [implementer] → [verifier] →
|
|
59
|
+
[reviewer] → [post-analyze] → [brief-writer]
|
|
60
|
+
```
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: legion:dev:quick
|
|
3
|
+
description: "Fast context-aware Dev task execution — reads .legion/codebase/, analyzes impact, implements with auto-escalation to cycle for complex tasks"
|
|
4
|
+
argument-hint: "<task description>"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Edit
|
|
9
|
+
- Glob
|
|
10
|
+
- Grep
|
|
11
|
+
- Bash
|
|
12
|
+
- Task
|
|
13
|
+
- WebSearch
|
|
14
|
+
- WebFetch
|
|
15
|
+
- ToolSearch
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Legion Dev Quick
|
|
19
|
+
|
|
20
|
+
Fast context-aware execution for development tasks. Reads project context, analyzes impact, implements, and verifies — with auto-escalation to full cycle when complexity is detected.
|
|
21
|
+
|
|
22
|
+
## Execution
|
|
23
|
+
|
|
24
|
+
Follow the workflow at @~/.claude/legion/workflows/dev/quick.md
|
|
25
|
+
|
|
26
|
+
### Quick Reference
|
|
27
|
+
|
|
28
|
+
**Initialization**: @~/.claude/legion/workflows/core/init.md
|
|
29
|
+
**Context Loading**: @~/.claude/legion/workflows/core/context-load.md
|
|
30
|
+
**Completion**: @~/.claude/legion/workflows/core/completion.md
|
|
31
|
+
**Agent Map**: @~/.claude/legion/references/dev/agent-map.md
|
|
32
|
+
|
|
33
|
+
### Pipeline (Shortened)
|
|
34
|
+
|
|
35
|
+
| Step | Agent | Model | What it does |
|
|
36
|
+
|------|-------|-------|-------------|
|
|
37
|
+
| 1. Quick Analysis | 4 parallel agents | haiku/sonnet | Context, locations, impact, verify plan |
|
|
38
|
+
| 2. Escalation Check | orchestrator | — | Detects complex scope, asks user |
|
|
39
|
+
| 3. Planner-Lite | delivery-planner | sonnet | 3-7 step compact plan |
|
|
40
|
+
| 4. Implement | general-purpose | opus | Execute plan step by step |
|
|
41
|
+
| 5. Verify-Lite | general-purpose | sonnet | Run tests + lint on changed files |
|
|
42
|
+
| 6. Brief | general-purpose | haiku | SUMMARY.md + codebase update |
|
|
43
|
+
|
|
44
|
+
### Auto-Escalation Triggers
|
|
45
|
+
|
|
46
|
+
If the impact analysis detects any of these, the workflow suggests switching to `/legion:dev:cycle`:
|
|
47
|
+
- Auth/security/permissions changes
|
|
48
|
+
- Database migrations
|
|
49
|
+
- Infrastructure/CI/CD changes
|
|
50
|
+
- Public API contract changes
|
|
51
|
+
- Wide cascading impact (>5 files across >2 modules)
|
|
52
|
+
|
|
53
|
+
The user always decides — no automatic escalation.
|
|
54
|
+
|
|
55
|
+
### Key Rules
|
|
56
|
+
- ALWAYS read .legion/codebase/ before starting
|
|
57
|
+
- If task is unclear, ASK the user
|
|
58
|
+
- Pass full context summary to spawned agents
|
|
59
|
+
- Update STATE.md after completion
|
|
@@ -32,12 +32,12 @@ Follow the workflow at @~/.claude/legion/workflows/devops/cycle.md
|
|
|
32
32
|
|
|
33
33
|
### Pipeline Stages
|
|
34
34
|
|
|
35
|
-
| Stage | Agent | Model | Checkpoint |
|
|
36
|
-
|
|
37
|
-
| 1. Architect | devops-architect | opus | ✓ User approval required |
|
|
38
|
-
| 2. Plan | delivery-planner | sonnet | ✓ User approval required |
|
|
39
|
-
| 3. Execute | infra-executor | opus | — |
|
|
40
|
-
| 4. Review | devops-architect | sonnet | — |
|
|
35
|
+
| Stage | Agent | Model | What it does | Checkpoint |
|
|
36
|
+
|-------|-------|-------|-------------|------------|
|
|
37
|
+
| 1. Architect | devops-architect | opus | Analyzes current state, designs target architecture, evaluates options | ✓ User approval required |
|
|
38
|
+
| 2. Plan | delivery-planner | sonnet | Decomposes architecture into ordered tasks with dependencies and rollback points | ✓ User approval required |
|
|
39
|
+
| 3. Execute | infra-executor | opus | Implements planned changes file-by-file, validates with terraform fmt/validate/plan | — |
|
|
40
|
+
| 4. Review | devops-architect | sonnet | Validates execution against original design, checks for drift and regressions | — |
|
|
41
41
|
|
|
42
42
|
### Checkpoints
|
|
43
43
|
|
|
@@ -32,13 +32,13 @@ Follow the workflow at @~/.claude/legion/workflows/devops/quick.md
|
|
|
32
32
|
|
|
33
33
|
### Agent Routing
|
|
34
34
|
|
|
35
|
-
| Task Type | Agent | subagent_type | Model |
|
|
36
|
-
|
|
37
|
-
| Architecture/design | devops-architect | devops-architect | opus |
|
|
38
|
-
| Planning/decomposition | delivery-planner | delivery-planner | sonnet |
|
|
39
|
-
| Infrastructure execution | infra-executor | infra-executor | opus |
|
|
40
|
-
| Review/validation | devops-architect | devops-architect | sonnet |
|
|
41
|
-
| Codebase scaffolding | codebase-builder | codebase-builder | opus |
|
|
35
|
+
| Task Type | Agent | subagent_type | Model | What the agent does |
|
|
36
|
+
|-----------|-------|---------------|-------|-------------------|
|
|
37
|
+
| Architecture/design | devops-architect | devops-architect | opus | Designs infrastructure, evaluates technology options, produces architecture decisions |
|
|
38
|
+
| Planning/decomposition | delivery-planner | delivery-planner | sonnet | Breaks work into phased tasks with dependencies, risks, and validation gates |
|
|
39
|
+
| Infrastructure execution | infra-executor | infra-executor | opus | Writes Terraform/CI/CD/K8s code, validates changes, reports evidence |
|
|
40
|
+
| Review/validation | devops-architect | devops-architect | sonnet | Reviews code for security, best practices, drift from architecture |
|
|
41
|
+
| Codebase scaffolding | codebase-builder | codebase-builder | opus | Scans project, generates `.legion/codebase/` docs or scaffolds new projects |
|
|
42
42
|
|
|
43
43
|
### Key Rules
|
|
44
44
|
- ALWAYS read .legion/codebase/ before starting work
|
|
@@ -29,7 +29,7 @@ Follow the workflow at @~/.claude/legion/workflows/status.md
|
|
|
29
29
|
4. Route to next action:
|
|
30
30
|
- If pipeline in progress → suggest `/legion:devops:cycle` to continue
|
|
31
31
|
- If no active work → suggest `/legion:devops:quick` or `/legion:devops:cycle`
|
|
32
|
-
- If no Legion state found → suggest initializing with `/legion:
|
|
32
|
+
- If no Legion state found → suggest initializing with `/legion:codebase:init`
|
|
33
33
|
|
|
34
34
|
### Display Format
|
|
35
35
|
|