Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@
"version": "1.0.0",
"keywords": ["skills", "quality", "patterns"]
},
{
"name": "devflow-ambient",
"source": "./plugins/devflow-ambient",
"description": "Ambient mode — proportional quality enforcement without explicit commands",
"version": "1.0.0",
"keywords": ["ambient", "routing", "quality", "tdd"]
},
{
"name": "devflow-audit-claude",
"source": "./plugins/devflow-audit-claude",
Expand Down
12 changes: 7 additions & 5 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ DevFlow enhances Claude Code with intelligent development workflows. Modificatio

## Architecture Overview

Plugin marketplace with 8 self-contained plugins, each following the Claude plugins format (`.claude-plugin/plugin.json`, `commands/`, `agents/`, `skills/`).
Plugin marketplace with 9 self-contained plugins, each following the Claude plugins format (`.claude-plugin/plugin.json`, `commands/`, `agents/`, `skills/`).

| Plugin | Purpose | Teams Variant |
|--------|---------|---------------|
Expand All @@ -22,6 +22,7 @@ Plugin marketplace with 8 self-contained plugins, each following the Claude plug
| `devflow-resolve` | Review issue resolution | Optional |
| `devflow-debug` | Competing hypothesis debugging | Optional |
| `devflow-self-review` | Self-review (Simplifier + Scrutinizer) | No |
| `devflow-ambient` | Ambient mode — proportional quality enforcement | No |
| `devflow-core-skills` | Auto-activating quality enforcement | No |
| `devflow-audit-claude` | Audit CLAUDE.md files (optional) | No |

Expand All @@ -35,13 +36,13 @@ Commands with Teams Variant ship as `{name}.md` (parallel subagents) and `{name}

```
devflow/
├── shared/skills/ # 24 skills (single source of truth)
├── shared/skills/ # 26 skills (single source of truth)
├── shared/agents/ # 10 shared agents (single source of truth)
├── plugins/devflow-*/ # 8 self-contained plugins
├── plugins/devflow-*/ # 9 self-contained plugins
├── docs/reference/ # Detailed reference documentation
├── scripts/ # Helper scripts (statusline, docs-helpers)
│ └── hooks/ # Working Memory hooks (stop, session-start, pre-compact)
├── src/cli/ # TypeScript CLI (init, list, uninstall)
│ └── hooks/ # Working Memory + ambient hooks (stop, session-start, pre-compact, ambient-prompt)
├── src/cli/ # TypeScript CLI (init, list, uninstall, ambient)
└── .claude-plugin/ # Marketplace registry
```

Expand Down Expand Up @@ -92,6 +93,7 @@ All generated docs live under `.docs/` in the project root:
- `/resolve` — N Resolver agents + Git
- `/debug` — Agent Teams competing hypotheses
- `/self-review` — Simplifier then Scrutinizer (sequential)
- `/ambient` — Intent classification + proportional skill loading (no agents, main session only)
- `/audit-claude` — CLAUDE.md audit (optional plugin)

**Shared agents** (10): git, synthesizer, skimmer, simplifier, coder, reviewer, resolver, shepherd, scrutinizer, validator
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ After setup, DevFlow commands (`/code-review`, `/implement`, etc.) are available

```
devflow/
├── shared/skills/ # 24 skills (single source of truth)
├── shared/skills/ # 26 skills (single source of truth)
├── shared/agents/ # 10 shared agents (single source of truth)
├── plugins/devflow-*/ # 8 self-contained plugins
├── plugins/devflow-*/ # 9 self-contained plugins
├── scripts/hooks/ # Working Memory hooks
├── src/cli/ # TypeScript CLI (init, list, uninstall)
├── tests/ # Test suite (Vitest)
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ DevFlow adds structured commands that handle the full lifecycle: specify feature
- **Full-lifecycle implementation** — spec, explore, plan, code, validate, refine in one command
- **Automatic session memory** — survives restarts, `/clear`, and context compaction
- **Parallel debugging** — competing hypotheses investigated simultaneously
- **24 quality skills** — 11 auto-activating, plus specialized review and agent skills
- **26 quality skills** — 12 auto-activating, plus specialized review and agent skills

## Quick Start

Expand All @@ -48,6 +48,7 @@ Then in Claude Code:
| `devflow-resolve` | `/resolve` | Process review issues — fix or defer to tech debt |
| `devflow-debug` | `/debug` | Parallel hypothesis debugging |
| `devflow-self-review` | `/self-review` | Self-review workflow (Simplifier + Scrutinizer) |
| `devflow-ambient` | `/ambient` | Ambient mode — proportional quality enforcement |
| `devflow-core-skills` | (auto) | Auto-activating quality enforcement skills |

## Command Details
Expand Down Expand Up @@ -116,6 +117,7 @@ The `devflow-core-skills` plugin provides quality enforcement skills that activa
| `git-safety` | Rebasing, force-pushing, merge conflicts |
| `git-workflow` | Staging files, creating commits, PRs |
| `github-patterns` | GitHub API operations, PR comments, releases |
| `test-driven-development` | Implementing new features (RED-GREEN-REFACTOR) |
| `test-patterns` | Writing or modifying tests |
| `input-validation` | Creating API endpoints |
| `typescript` | Working in TypeScript codebases |
Expand Down Expand Up @@ -209,6 +211,8 @@ Session context is saved and restored automatically via Working Memory hooks —
| `npx devflow-kit init` | Install all plugins |
| `npx devflow-kit init --plugin=<names>` | Install specific plugin(s) |
| `npx devflow-kit list` | List available plugins |
| `npx devflow-kit ambient --enable` | Enable always-on ambient mode |
| `npx devflow-kit ambient --disable` | Disable ambient mode |
| `npx devflow-kit uninstall` | Remove DevFlow |

### Init Options
Expand Down
7 changes: 7 additions & 0 deletions plugins/devflow-ambient/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "devflow-ambient",
"description": "Ambient mode — proportional quality enforcement without explicit commands",
"version": "1.0.0",
"agents": [],
"skills": ["ambient-router"]
}
49 changes: 49 additions & 0 deletions plugins/devflow-ambient/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# devflow-ambient

Ambient mode — proportional quality enforcement without explicit command invocation.

## Command

### `/ambient`

Classify user intent and apply proportional skill enforcement to any prompt.

```bash
/ambient add a login form # BUILD/STANDARD — loads TDD + implementation-patterns
/ambient fix the auth error # DEBUG/STANDARD — loads test-patterns + core-patterns
/ambient where is the config? # EXPLORE/QUICK — responds normally, zero overhead
/ambient refactor the auth system # BUILD/ESCALATE — suggests /implement
```

## Always-On Mode

Enable ambient classification on every prompt without typing `/ambient`:

```bash
devflow ambient --enable # Register UserPromptSubmit hook
devflow ambient --disable # Remove hook
devflow ambient --status # Check if enabled
```

When enabled, a `UserPromptSubmit` hook injects a classification preamble before every prompt. Slash commands (`/implement`, `/code-review`, etc.) and short confirmations ("yes", "ok") are skipped automatically.

## How It Works

1. **Classify intent** — BUILD, DEBUG, REVIEW, PLAN, EXPLORE, or CHAT
2. **Classify depth** — QUICK (zero overhead), STANDARD (2-3 skills), or ESCALATE (workflow nudge)
3. **Apply proportionally**:
- QUICK: respond normally
- STANDARD: load relevant skills, enforce TDD for BUILD
- ESCALATE: respond + recommend full workflow command

## Depth Tiers

| Depth | When | Overhead |
|-------|------|----------|
| QUICK | Chat, exploration, < 20 words, no file refs | ~0 tokens |
| STANDARD | BUILD/DEBUG/REVIEW/PLAN, 1-5 file scope | ~500-1000 tokens (skill reads) |
| ESCALATE | Multi-file, architectural, system-wide scope | ~0 extra tokens (nudge only) |

## Skills

- `ambient-router` — Intent + depth classification, skill selection matrix
110 changes: 110 additions & 0 deletions plugins/devflow-ambient/commands/ambient.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
---
description: Ambient mode — classify intent and apply proportional quality enforcement to any prompt
---

# Ambient Command

Classify user intent and apply proportional quality enforcement. No agents spawned — enhances the main session only.

## Usage

```
/ambient <prompt> Classify and respond with skill enforcement
/ambient Show usage
```

## Phases

### Phase 1: Load Router

Read the `ambient-router` skill:
- `~/.claude/skills/ambient-router/SKILL.md`

### Phase 2: Classify

Apply the ambient-router classification to `$ARGUMENTS`:

1. **Intent:** BUILD | DEBUG | REVIEW | PLAN | EXPLORE | CHAT
2. **Depth:** QUICK | STANDARD | ESCALATE

If no arguments provided, output:

```
## Ambient Mode

Classify intent and apply proportional quality enforcement.

Usage: /ambient <your prompt>

Examples:
/ambient add a login form → BUILD/STANDARD (loads TDD + implementation-patterns)
/ambient fix the auth error → DEBUG/STANDARD (loads test-patterns + core-patterns)
/ambient where is the config? → EXPLORE/QUICK (responds normally)
/ambient refactor the auth system → BUILD/ESCALATE (suggests /implement)

Always-on: devflow ambient --enable
```

Then stop.

### Phase 3: State Classification

- **QUICK:** Skip this phase entirely. Respond directly in Phase 4.
- **STANDARD:** Output one line: `Ambient: {INTENT}/{DEPTH}. Loading: {skill1}, {skill2}.`
- **ESCALATE:** Skip — recommendation happens in Phase 4.

### Phase 4: Apply

**QUICK:**
Respond to the user's prompt normally. Zero skill loading. Zero overhead.

**STANDARD:**
Read the selected skills based on the ambient-router's skill selection matrix:

| Intent | Primary Skills | Secondary (conditional) |
|--------|---------------|------------------------|
| BUILD | test-driven-development, implementation-patterns | typescript (.ts), react (.tsx), frontend-design (CSS/UI), input-validation (forms/API), security-patterns (auth/crypto) |
| DEBUG | test-patterns, core-patterns | git-safety (if git ops) |
| REVIEW | self-review, core-patterns | test-patterns |
| PLAN | implementation-patterns | core-patterns |

Read up to 3 skills from `~/.claude/skills/{name}/SKILL.md`. Apply their patterns and constraints when responding to the user's prompt.

For BUILD intent: enforce RED-GREEN-REFACTOR from test-driven-development. Write failing tests before production code.

**ESCALATE:**
Respond to the user's prompt with your best effort, then append:

> This task spans multiple files/systems. Consider `/implement` for full lifecycle management (exploration → planning → implementation → review).

## Architecture

```
/ambient <prompt> (main session, no agents)
├─ Phase 1: Load ambient-router skill
├─ Phase 2: Classify intent + depth
├─ Phase 3: State classification (STANDARD only)
└─ Phase 4: Apply
├─ QUICK → respond directly
├─ STANDARD → load 2-3 skills, apply patterns, respond
└─ ESCALATE → respond + workflow nudge
```

## Edge Cases

| Case | Handling |
|------|----------|
| No arguments | Show usage and stop |
| Single word ("help") | Classify — likely CHAT/QUICK |
| Prompt references `/implement` etc. | Classify as normal — user chose /ambient intentionally |
| Mixed intent ("fix and add test") | Use higher-overhead intent (BUILD > DEBUG) |
| User says "no enforcement" | Respect immediately — treat as QUICK |

## Principles

1. **No agents** — Ambient enhances the main session, never spawns subagents
2. **Proportional** — QUICK gets zero overhead, STANDARD gets 2-3 skills, ESCALATE gets a nudge
3. **Transparent** — State classification for STANDARD/ESCALATE, silent for QUICK
4. **Respectful** — Never over-classify; when in doubt, go one tier lower
5. **TDD for BUILD** — STANDARD depth BUILD tasks enforce test-first workflow
1 change: 1 addition & 0 deletions plugins/devflow-core-skills/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"github-patterns",
"input-validation",
"react",
"test-driven-development",
"test-patterns",
"typescript"
]
Expand Down
48 changes: 48 additions & 0 deletions scripts/hooks/ambient-prompt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

# Ambient Mode: UserPromptSubmit Hook
# Injects a classification preamble before every user prompt so Claude applies
# proportional quality enforcement via the ambient-router skill.
# Zero file I/O beyond stdin — static injection only.

set -euo pipefail

# jq is required to parse hook input JSON — silently no-op if missing
if ! command -v jq &>/dev/null; then exit 0; fi

INPUT=$(cat)

CWD=$(echo "$INPUT" | jq -r '.cwd // ""' 2>/dev/null)
if [ -z "$CWD" ]; then
exit 0
fi

PROMPT=$(echo "$INPUT" | jq -r '.prompt // ""' 2>/dev/null)

# Skip slash commands — they have their own orchestration
if [[ "$PROMPT" == /* ]]; then
exit 0
fi

# Skip short confirmations (< 3 words)
WORD_COUNT=$(echo "$PROMPT" | wc -w | tr -d ' ')
if [ "$WORD_COUNT" -lt 3 ]; then
exit 0
fi

# Inject classification preamble
PREAMBLE="AMBIENT MODE ACTIVE: Before responding, silently classify this prompt:
Intent: BUILD | DEBUG | REVIEW | PLAN | EXPLORE | CHAT
Depth: QUICK (no overhead) | STANDARD (load skills) | ESCALATE (suggest /command)

If STANDARD+: Read the ambient-router skill for classification details and skill selection matrix. For BUILD tasks, also load test-driven-development skill and enforce RED-GREEN-REFACTOR.

If QUICK: Respond normally without stating classification.
Only state classification aloud for STANDARD/ESCALATE."

jq -n --arg ctx "$PREAMBLE" '{
"hookSpecificOutput": {
"hookEventName": "UserPromptSubmit",
"additionalContext": $ctx
}
}'
37 changes: 35 additions & 2 deletions scripts/hooks/background-memory-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,44 @@ fi

# Build instruction
if [ -n "$EXISTING_MEMORY" ]; then
INSTRUCTION="Update the file $MEMORY_FILE with working memory from this session. The file already has content — possibly from a concurrent session that just wrote it moments ago. Merge this session's context with the existing content to produce a single unified working memory snapshot. Both this session and the existing content represent fresh, concurrent work — integrate both fully. Working memory captures what's active now, not a changelog. Deduplicate overlapping information. Keep under 100 lines total. Use the same structure: ## Now, ## Decisions, ## Modified Files, ## Context, ## Session Log.
PATTERNS_INSTRUCTION=""
PATTERNS_FILE="$CWD/.docs/patterns.md"
EXISTING_PATTERNS=""
if [ -f "$PATTERNS_FILE" ]; then
EXISTING_PATTERNS=$(cat "$PATTERNS_FILE")
PATTERNS_INSTRUCTION="

Also update $PATTERNS_FILE by APPENDING any new recurring patterns discovered during this session. Do NOT overwrite existing entries — only add new ones. Skip if no new patterns were observed. Format each entry as: - **Pattern name**: Brief description (discovered: YYYY-MM-DD)

Existing patterns:
$EXISTING_PATTERNS"
else
PATTERNS_INSTRUCTION="

If recurring patterns were observed during this session (coding conventions, architectural decisions, team preferences, tooling quirks), create $PATTERNS_FILE with entries formatted as: - **Pattern name**: Brief description (discovered: YYYY-MM-DD). Only create this file if genuine patterns were observed — do not fabricate entries."
fi

INSTRUCTION="Update the file $MEMORY_FILE with working memory from this session. The file already has content — possibly from a concurrent session that just wrote it moments ago. Merge this session's context with the existing content to produce a single unified working memory snapshot. Both this session and the existing content represent fresh, concurrent work — integrate both fully. Working memory captures what's active now, not a changelog. Deduplicate overlapping information. Keep under 100 lines total. Use the same structure: ## Now, ## Decisions, ## Modified Files, ## Context, ## Session Log.${PATTERNS_INSTRUCTION}

Existing content:
$EXISTING_MEMORY"
else
PATTERNS_INSTRUCTION=""
PATTERNS_FILE="$CWD/.docs/patterns.md"
if [ -f "$PATTERNS_FILE" ]; then
EXISTING_PATTERNS=$(cat "$PATTERNS_FILE")
PATTERNS_INSTRUCTION="

Also update $PATTERNS_FILE by APPENDING any new recurring patterns discovered during this session. Do NOT overwrite existing entries — only add new ones. Skip if no new patterns were observed. Format each entry as: - **Pattern name**: Brief description (discovered: YYYY-MM-DD)

Existing patterns:
$EXISTING_PATTERNS"
else
PATTERNS_INSTRUCTION="

If recurring patterns were observed during this session (coding conventions, architectural decisions, team preferences, tooling quirks), create $PATTERNS_FILE with entries formatted as: - **Pattern name**: Brief description (discovered: YYYY-MM-DD). Only create this file if genuine patterns were observed — do not fabricate entries."
fi

INSTRUCTION="Create the file $MEMORY_FILE with working memory from this session. Keep under 100 lines. Use this structure:

# Working Memory
Expand All @@ -129,7 +162,7 @@ else
<!-- Chronological summary of work done today (2-5 bullets) -->

### This Week
<!-- Broader multi-day context if relevant -->"
<!-- Broader multi-day context if relevant -->${PATTERNS_INSTRUCTION}"
fi

# Resume session headlessly to perform the update
Expand Down
Loading