Files
claude-archeflow-plugin/README.md

369 lines
16 KiB
Markdown

# ArcheFlow -- Multi-Agent Orchestration for Claude Code
**Structured quality through archetypal collaboration.** ArcheFlow coordinates multiple Claude Code agents through PDCA cycles, where each agent embodies a Jungian archetype with defined strengths and known failure modes.
Zero dependencies. No build step. Install and go.
## What It Does
Large coding tasks benefit from multiple perspectives, but "just spawn more agents" creates chaos. Agents duplicate work, miss each other's output, argue in circles, or go rogue. The problem is not intelligence -- it is coordination.
ArcheFlow solves this by giving each agent an *archetype*: a behavioral protocol that defines what the agent cares about, what context it receives, and how its output feeds into the next phase. Seven archetypes collaborate through **Plan-Do-Check-Act cycles**, where each iteration builds on structured feedback from the last. No unreviewed code reaches your main branch.
The key insight: archetypes are not just system prompts. Each one has a **virtue** (its unique contribution) and a **shadow** (the dysfunction it falls into when pushed too far). ArcheFlow monitors for shadow activation and course-corrects automatically -- replacing an agent that blocks everything, reining in one that researches forever, or escalating when a maker goes off-script.
## Quick Start
### 1. Install
**From the marketplace** (recommended):
```bash
# Add the marketplace (one time)
/plugin marketplace add https://git.xorwell.de/c/claude-archeflow-plugin
# Install the plugin
/plugin install archeflow@claude-archeflow-plugin
```
**From Git URL directly:**
```bash
/plugin marketplace add https://git.xorwell.de/c/claude-archeflow-plugin.git
/plugin install archeflow --scope user
```
**Local development:**
```bash
claude --plugin-dir ./archeflow
```
After installing, run `/reload-plugins` or restart Claude Code. ArcheFlow activates automatically on session start.
#### Verify installation
```
/plugin # Opens plugin manager — check "Installed" tab
/af-status # Should show "no active run"
```
#### Scopes
- `--scope user` — available in all your projects (recommended)
- `--scope project` — only in the current project
- `--scope local` — only in the current directory
### 2. Run your first orchestration
Just describe a task. ArcheFlow activates automatically for multi-file changes:
```
> Add input validation to all API endpoints
```
Or invoke it explicitly:
```
> archeflow:run "Add JWT authentication" --workflow standard
```
### 3. What happens
ArcheFlow selects a workflow (fast, standard, or thorough) and runs a PDCA cycle:
```
Plan --> Explorer researches codebase context, Creator designs a proposal
Do --> Maker implements in an isolated git worktree
Check --> Reviewers assess in parallel (Guardian, Skeptic, Sage, Trickster)
Act --> All approved? Merge. Issues found? Cycle back with structured feedback.
Each cycle catches what the last one missed.
```
Progress is visible in real time:
```
--- ArcheFlow: Add JWT authentication ---------
Workflow: standard (2 cycles max)
🔍 [Plan] Explorer researching... done (35s)
🏗️ [Plan] Creator designing proposal... done (25s, confidence: 0.8)
⚒️ [Do] Maker implementing... done (90s, 4 files, 8 tests)
🛡️ [Check] Guardian reviewing... APPROVED
🤔 [Check] Skeptic challenging... APPROVED (1 INFO)
📚 [Check] Sage reviewing... APPROVED
[Act] All approved -- merging... merged to main
--- Complete: 3m 10s, 1 cycle -----------------
```
## The Seven Archetypes
| Archetype | Phase | Virtue | Shadow | Role |
|-----------|-------|--------|--------|------|
| 🔍 **Explorer** | Plan | Contextual Clarity | Rabbit Hole | Researches codebase, maps dependencies, synthesizes findings |
| 🏗️ **Creator** | Plan | Decisive Framing | Over-Architect | Designs solution proposals with architecture decisions and test strategy |
| ⚒️ **Maker** | Do | Execution Discipline | Rogue | Implements code in an isolated git worktree, commits per phase |
| 🛡️ **Guardian** | Check | Threat Intuition | Paranoid | Reviews for security vulnerabilities, reliability risks, breaking changes |
| 🤔 **Skeptic** | Check | Assumption Surfacing | Paralytic | Challenges assumptions, identifies untested scenarios, proposes alternatives |
| 🃏 **Trickster** | Check | Adversarial Creativity | False Alarm | Adversarial testing, boundary attacks, edge case exploitation |
| 📚 **Sage** | Check | Maintainability Judgment | Bureaucrat | Holistic quality review -- code quality, test coverage, engineering judgment |
Shadow detection is quantitative, not vibes. Explorer output exceeding 2000 words without a recommendation triggers Rabbit Hole. Guardian blocking three consecutive items triggers Paranoid. First detection: correction prompt. Second: replace agent. Third: escalate to user.
## Skills Reference
ArcheFlow ships with 24 skills organized by function.
### Core Orchestration
| Skill | Description |
|-------|-------------|
| `archeflow:run` | Automated PDCA execution loop -- single-command orchestration with `--start-from`, `--dry-run`, and cycle-back |
| `archeflow:orchestration` | Step-by-step PDCA execution guide for manual orchestration |
| `archeflow:plan-phase` | Explorer and Creator output formats and protocols |
| `archeflow:do-phase` | Maker implementation rules and worktree commit strategy |
| `archeflow:check-phase` | Shared reviewer protocols and output format |
| `archeflow:act-phase` | Post-Check decision logic: collect findings, route fixes, exit or cycle |
### Quality and Safety
| Skill | Description |
|-------|-------------|
| `archeflow:shadow-detection` | Quantitative dysfunction detection and automatic correction |
| `archeflow:attention-filters` | Context optimization per archetype -- each agent gets only what it needs |
| `archeflow:convergence` | Detects convergence, stalling, and oscillation in multi-cycle runs |
| `archeflow:artifact-routing` | Inter-phase artifact protocol -- naming, storage, routing, archiving |
### Process Intelligence
| Skill | Description |
|-------|-------------|
| `archeflow:process-log` | Event-sourced JSONL logging with DAG parent relationships |
| `archeflow:memory` | Cross-run memory that learns recurring findings and injects lessons |
| `archeflow:effectiveness` | Archetype scoring on signal-to-noise, fix rate, cost efficiency |
| `archeflow:progress` | Live progress file watchable from a second terminal |
### Integration
| Skill | Description |
|-------|-------------|
| `archeflow:colette-bridge` | Bridges ArcheFlow with the Colette writing platform |
| `archeflow:git-integration` | Git-per-phase commits, branch-per-run, rollback to any phase boundary |
| `archeflow:multi-project` | Cross-repo orchestration with dependency DAG and shared budget |
### Configuration
| Skill | Description |
|-------|-------------|
| `archeflow:custom-archetypes` | Create domain-specific roles (database reviewer, compliance auditor, etc.) |
| `archeflow:workflow-design` | Design custom workflows with per-phase archetype assignment and exit conditions |
| `archeflow:domains` | Domain adapters for writing, research, and other non-code workflows |
| `archeflow:cost-tracking` | Budget enforcement, per-agent cost aggregation, model tier recommendations |
| `archeflow:templates` | Template gallery for sharing workflows, teams, and setup bundles |
| `archeflow:autonomous-mode` | Unattended overnight sessions with progress logging and safe stopping |
### Meta
| Skill | Description |
|-------|-------------|
| `archeflow:using-archeflow` | Session-start skill -- activation criteria, workflow selection, quick reference |
## Library Scripts
Eight shell scripts in `lib/` power the process infrastructure.
| Script | Purpose | Usage |
|--------|---------|-------|
| `archeflow-event.sh` | Append structured JSONL events to a run log | `archeflow-event.sh <run_id> <type> <phase> <agent> '<json>'` |
| `archeflow-dag.sh` | Render ASCII DAG from JSONL events | `archeflow-dag.sh events.jsonl --color` |
| `archeflow-report.sh` | Generate Markdown process report | `archeflow-report.sh events.jsonl --output report.md --dag` |
| `archeflow-progress.sh` | Regenerate live progress file from events | `archeflow-progress.sh <run_id>` |
| `archeflow-score.sh` | Score archetype effectiveness from completed runs | `archeflow-score.sh extract events.jsonl` |
| `archeflow-memory.sh` | Cross-run memory: add, list, decay, inject lessons | `archeflow-memory.sh add "Always check for null"` |
| `archeflow-git.sh` | Per-phase commits, branch creation, merge, rollback | `archeflow-git.sh commit <run_id> <phase>` |
| `archeflow-init.sh` | Template gallery: init, save, clone, list | `archeflow-init.sh init writing-short-story` |
## Workflows
### Built-in Workflows
| Workflow | Cycles | Archetypes | Best For |
|----------|:------:|------------|----------|
| `fast` | 1 | Creator, Maker, Guardian | Bug fixes, small changes |
| `standard` | 2 | Explorer + Creator, Maker, Guardian + Skeptic + Sage | Features, refactors |
| `thorough` | 3 | Explorer + Creator, Maker, All 4 reviewers | Security-critical, public APIs |
ArcheFlow picks the workflow automatically based on task complexity, or you can specify:
```
> Implement input validation for the API (use thorough workflow)
```
Workflows adapt at runtime. If Guardian finds 2+ CRITICALs in a fast workflow, it escalates to standard. If reviewers find nothing in standard, it fast-paths past the remaining cycle.
### Custom Workflows
Define your own workflows in `.archeflow/workflows/`:
```yaml
# .archeflow/workflows/api-design.yaml
name: api-design
pdca:
plan: { archetypes: [explorer, creator] }
do: { archetypes: [maker] }
check: { archetypes: [guardian, skeptic, trickster] }
act: { exit_when: all_approved, max_cycles: 2 }
```
### Example: Short Fiction Workflow
ArcheFlow is not limited to code. The included `kurzgeschichte` workflow orchestrates short story development with custom archetypes (story-explorer, story-sage), Colette voice profile integration, and scene-by-scene commits:
```yaml
# examples/workflows/kurzgeschichte.yaml
name: kurzgeschichte
team: story-development
phases:
plan:
archetypes: [story-explorer, creator]
do:
archetypes: [maker]
check:
archetypes: [guardian, story-sage]
act:
exit_when: all_approved
max_cycles: 2
```
## Domain Adapters
ArcheFlow defaults to code-oriented terminology, but domain adapters remap concepts for other workflows:
| Domain | What Changes |
|--------|-------------|
| `code` | Default. Diffs, tests, security review, merge to main. |
| `writing` | Prose quality, voice consistency, dialect authenticity. Auto-activates when `colette.yaml` is detected. |
| `research` | Source quality, argument coherence, citation accuracy. |
Custom domains can be defined in `.archeflow/domains/`.
## Examples
The `examples/` directory contains complete walkthroughs:
- `feature-implementation.md` -- End-to-end feature build with standard workflow
- `security-review.md` -- Thorough review of security-sensitive code
- `custom-workflow.yaml` -- Template for defining your own workflow
- `custom-archetypes/` -- Story-explorer and story-sage for fiction writing
- `teams/` -- Team preset for story development
- `workflows/kurzgeschichte.yaml` -- Short fiction workflow with Colette integration
## Configuration
### Project Configuration
Create `.archeflow/config.yaml` in your project root:
```yaml
workflow: standard # Default workflow
budget: 50000 # Max tokens per run
git:
enabled: true # Per-phase commits
merge_strategy: squash # squash or no-ff
```
### Custom Archetypes
Add domain-specific roles in `.archeflow/archetypes/`:
```markdown
# .archeflow/archetypes/db-specialist.md
---
name: db-specialist
description: Reviews database schemas and migration safety
model: sonnet
---
You are the **Database Specialist**.
Your lens: "Will this scale? Will this corrupt data?"
```
### Team Presets
Define reusable teams in `.archeflow/teams/`:
```yaml
# .archeflow/teams/backend-review.yaml
name: backend-review
archetypes: [explorer, creator, maker, guardian, db-specialist]
```
### Environment Variables
- `ARCHEFLOW_BUDGET` -- Override default token budget
- `ARCHEFLOW_WORKFLOW` -- Override default workflow selection
## Architecture
```
archeflow/
├── .claude-plugin/plugin.json # Plugin manifest (v0.5.0)
├── agents/ # 7 archetype personas (behavioral protocols)
│ ├── explorer.md # Plan: research and context mapping
│ ├── creator.md # Plan: solution design and proposals
│ ├── maker.md # Do: implementation in isolated worktree
│ ├── guardian.md # Check: security and reliability review
│ ├── skeptic.md # Check: assumption challenging
│ ├── trickster.md # Check: adversarial testing
│ └── sage.md # Check: holistic quality review
├── skills/ # 24 behavioral skills
│ ├── run/ # Automated PDCA loop
│ ├── orchestration/ # Manual PDCA execution guide
│ ├── plan-phase/ # Plan protocols
│ ├── do-phase/ # Do protocols
│ ├── check-phase/ # Check protocols
│ ├── act-phase/ # Act phase decision logic
│ ├── shadow-detection/ # Dysfunction detection
│ ├── attention-filters/ # Context optimization
│ ├── convergence/ # Cycle convergence detection
│ ├── artifact-routing/ # Inter-phase artifact protocol
│ ├── process-log/ # Event-sourced JSONL logging
│ ├── memory/ # Cross-run learning
│ ├── effectiveness/ # Archetype scoring
│ ├── progress/ # Live progress file
│ ├── colette-bridge/ # Colette writing platform bridge
│ ├── git-integration/ # Per-phase git commits
│ ├── multi-project/ # Cross-repo orchestration
│ ├── custom-archetypes/ # Domain-specific roles
│ ├── workflow-design/ # Custom workflow design
│ ├── domains/ # Domain adapters
│ ├── cost-tracking/ # Budget and cost management
│ ├── templates/ # Template gallery
│ ├── autonomous-mode/ # Unattended sessions
│ └── using-archeflow/ # Session-start activation
├── lib/ # 8 shell scripts (process infrastructure)
├── hooks/ # Auto-activation (SessionStart)
├── examples/ # Walkthroughs, templates, custom archetypes
└── docs/ # Roadmap, changelog
```
The flow: skills define behavioral rules (what agents should do), agents define personas (how they think), lib scripts handle tooling (event logging, git, reporting), and hooks wire it all together at session start. Events are emitted at every phase transition, forming a DAG that can be rendered, reported, or scored after the run.
## Philosophy
1. **Strength has a shadow.** Every capability becomes destructive when unchecked. The Explorer who never stops researching. The Guardian who blocks everything. The Maker who ships without review. ArcheFlow names these shadows and corrects them automatically.
2. **Quality is a spiral, not a gate.** A single review pass misses things. PDCA cycles spiral upward -- each iteration catches what the previous one missed, until the reviewers have nothing left to find.
3. **Autonomy needs structure.** Agents given clear roles, typed communication, and quality gates produce exceptional work -- even overnight, even unattended.
## Version History
See [CHANGELOG.md](CHANGELOG.md) for detailed release notes.
## License
MIT