v3/implementation/adrs/ADR-052-statusline-observability-system.md
Status: Implemented Date: 2026-02-10 Authors: RuvNet, Claude Flow Team Version: 1.0.0 Related: ADR-051 (Infinite Context), ADR-048 (Auto Memory Integration), ADR-006 (Unified Memory), ADR-026 (3-Tier Model Routing)
Claude Code operates with multiple concurrent subsystems — swarm agents, memory backends, neural learning, security scanning, context management — but provides no unified visibility into their state. Developers working in long sessions need to know:
Without real-time feedback, developers make blind decisions about when to start new sessions, whether agents are drifting, and if the system is operating optimally.
Claude Code supports a statusLine configuration in .claude/settings.json:
{
"statusLine": {
"type": "command",
"command": "<shell command>",
"refreshMs": 5000,
"enabled": true
}
}
The command receives JSON on stdin with workspace metadata, model info, and optional context window data. Its stdout is displayed as a persistent status bar in the Claude Code terminal UI.
A multi-tier statusline system with 4 implementations, a TypeScript generator for
npx claude-flow init, and real-time data feeds from 8+ subsystems.
Implement a layered statusline architecture:
.claude/statusline.sh) — Bash script for the current
project, read from settings.json statusLine.command.claude/helpers/statusline.cjs) — CommonJS script
created by npx claude-flow init, comprehensive with 12+ metric panels.claude/statusline.mjs) — ES module for agentic-flow
integration, compact pipe-separated format.claude/statusline-command.sh) — JSON-input focused,
shows swarm topology and task metricsv3/@claude-flow/cli/src/init/statusline-generator.ts) — TypeScript
that produces the .cjs script during project initialization┌─────────────────────────────────────────────────────────────────────┐
│ Claude Code Terminal │
│ │
│ ┌─────────────────────────────────────────────────────────────┐ │
│ │ statusLine.command executes every refreshMs (5000ms) │ │
│ │ │ │
│ │ stdin: { workspace, model, context_window } │ │
│ │ stdout: ANSI-colored multi-line status display │ │
│ └──────────────────────┬──────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────────────────────────────┐ │
│ │ .claude/statusline.sh (active) │ │
│ │ │ │
│ │ Reads 8 data sources: │ │
│ │ │ │
│ │ ┌─────────────────┐ ┌──────────────────────┐ │ │
│ │ │ autopilot-state │ │ v3-progress.json │ │ │
│ │ │ .json │ │ (DDD domains) │ │ │
│ │ │ Context: 27% │ │ Domains: 5/5 │ │ │
│ │ └─────────────────┘ └──────────────────────┘ │ │
│ │ │ │
│ │ ┌─────────────────┐ ┌──────────────────────┐ │ │
│ │ │ learning.json │ │ audit-status.json │ │ │
│ │ │ Intel: 86% │ │ CVE: 3/3 CLEAN │ │ │
│ │ └─────────────────┘ └──────────────────────┘ │ │
│ │ │ │
│ │ ┌─────────────────┐ ┌──────────────────────┐ │ │
│ │ │ patterns.db │ │ transcript-archive │ │ │
│ │ │ (SQLite) │ │ .db (SQLite) │ │ │
│ │ │ Quality: 0.999 │ │ Entries: 35 │ │ │
│ │ └─────────────────┘ └──────────────────────┘ │ │
│ │ │ │
│ │ ┌─────────────────┐ ┌──────────────────────┐ │ │
│ │ │ swarm-activity │ │ ps aux (process) │ │ │
│ │ │ .json │ │ Node/MCP detection │ │ │
│ │ │ Agents: 3/15 │ │ Memory: 2782MB │ │ │
│ │ └─────────────────┘ └──────────────────────┘ │ │
│ │ │ │
│ │ Output (4 lines + separators): │ │
│ │ ▊ Claude Flow V3 ● user │ ⎇ branch │ Model │ │
│ │ ───────────────────────────────────────── │ │
│ │ 🏗️ DDD Domains [●●●●●] 5/5 ⚡ 1.0x → 2.49x-7.47x │ │
│ │ 🤖 Swarm ◉ [3/15] 👥 0 🟢 CVE 3/3 💾 2782MB │ │
│ │ 🛡️ 27% 54.7K ⊘ 🧠 86% │ │
│ │ 🔧 Architecture DDD ●79% │ Security ●CLEAN │ │
│ │ Memory ●AgentDB │ Integration ● │ │
│ │ ───────────────────────────────────────── │ │
│ └──────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────┘
| Source File | Subsystem | Metrics | Updated By |
|---|---|---|---|
.claude-flow/data/autopilot-state.json | Context Autopilot (ADR-051) | Token %, token count, prune cycles, growth trend | context-persistence-hook.mjs on every UserPromptSubmit |
.claude-flow/metrics/v3-progress.json | DDD Architecture | Domain count, DDD progress %, active agents | init command, manual updates |
.claude-flow/security/audit-status.json | Security | CVE count, audit status (CLEAN/PENDING) | security scan command |
.claude-flow/metrics/performance.json | Performance | Flash Attention speedup | performance benchmark command |
.claude-flow/metrics/learning.json | Intelligence | Score (0-100), routing accuracy, SONA status | hooks post-task, neural training |
.claude-flow/learning/patterns.db | Pattern DB (SQLite) | Short/long-term pattern counts, avg quality | hooks intelligence, neural training |
.claude-flow/data/transcript-archive.db | Context Archive (SQLite) | Entry count, session count | context-persistence-hook.mjs |
.claude-flow/metrics/swarm-activity.json | Swarm Monitor | Active agent count, swarm state | Swarm monitor daemon |
ps aux (process table) | System | Node/MCP memory, active processes | Real-time OS query |
git (VCS) | Repository | Branch name, status | Real-time git query |
gh api (GitHub) | GitHub | Username | Cached API call |
.claude/statusline.sh (432 lines)The currently wired script in settings.json. Bash-based for maximum compatibility.
Display Layout:
Line 0: ▊ Claude Flow V3 ● user │ ⎇ branch │ Model
Line -: ─────────────────────────────────────────
Line 1: 🏗️ DDD Domains [●●●●●] 5/5 ⚡ speedup → target
Line 2: 🤖 Swarm ◉ [N/15] 👥 sub 🟢 CVE X/3 💾 MEM 🛡️ CTX% 🧠 INT%
Line 3: 🔧 Architecture DDD ●N% │ Security ●STATUS │ Memory ●AgentDB │ Integration ●
Line -: ─────────────────────────────────────────
Metric Icons:
| Icon | Metric | Source |
|---|---|---|
🏗️ | DDD domain progress | v3-progress.json |
⚡ | Flash Attention speedup | performance.json |
🤖 | Swarm agent count | swarm-activity.json + ps |
◉/○ | Active/inactive processes | ps aux |
👥 | Sub-agent count | ps aux (Task tool agents) |
📨 | Message queue depth | swarm-comms.sh |
🟢/🟡/🔴 | Security CVE status | audit-status.json |
💾 | Node process memory | ps aux RSS |
🛡️/📂 | Context % (autopilot/legacy) | autopilot-state.json |
⊘/⟳N | Compaction blocked / prune cycles | autopilot-state.json |
🧠 | Intelligence score | learning.json + patterns.db |
🔧 | Architecture status | v3-progress.json |
Color Thresholds:
| Metric | Green | Cyan | Yellow | Red |
|---|---|---|---|---|
| Context % | 0-49 | 50-69 | 70-84 | 85+ |
| Intelligence % | 75+ | 50-74 | 25-49 | 0-24 |
| Agents | 8+ | — | 1-7 | 0 |
| Domains | 5 | — | 1-4 | 0 |
Context Autopilot Integration (ADR-051):
The statusline reads from autopilot-state.json which is written by the
context-persistence-hook.mjs on every UserPromptSubmit hook:
{
"sessionId": "f1bd5b59-...",
"lastTokenEstimate": 54700,
"lastPercentage": 0.274,
"pruneCount": 0,
"warningIssued": false,
"history": [{ "ts": ..., "tokens": ..., "pct": ..., "turns": ... }]
}
When autopilot is active:
📂 (folder) to 🛡️ (shield)54.7K)⊘ (no prunes needed) or ⟳N (N prune cycles)Intelligence Score Computation:
Base: learning.json → intelligence.score (0-100)
+ Boost: patterns.db → AVG(quality) × 20 (up to +20)
+ Boost: transcript-archive.db → COUNT(*) / 10 (up to +10)
= Final: capped at 100
.claude/helpers/statusline.cjs (1,193 lines)Created by npx claude-flow init. CommonJS for ES module project compatibility.
12 Metric Panels:
| Panel | Function | Lines |
|---|---|---|
| User Info | getUserInfo() | Git user, branch, model |
| Learning Stats | getLearningStats() | Intelligence loop data |
| V3 Progress | getV3Progress() | DDD from real metrics |
| Security | getSecurityStatus() | CVE tracking |
| Swarm | getSwarmStatus() | Cross-platform agent detection |
| System Metrics | getSystemMetrics() | Memory, intelligence, context |
| ADR Status | getADRStatus() | Architecture decision compliance |
| Hooks | getHooksStatus() | Hook enablement tracking |
| AgentDB | getAgentDBStats() | Vector count, HNSW index |
| Tests | getTestStats() | Test file/case counting |
| Integration | getIntegrationStatus() | MCP, database, API |
| Git | getGitStatus() | Modified, staged, untracked |
Output Modes:
--json: Pretty-printed JSON of all metrics--compact: Minified JSON.claude/statusline.mjs (110 lines)ES module for agentic-flow integration. Compact pipe-separated format with 5-second cache TTL for swarm status.
.claude/statusline-command.sh (177 lines)JSON-input focused. Shows swarm topology configuration, CPU/memory (with color-coded thresholds), session duration, task success rate with streak tracking, and hooks activity status.
v3/@claude-flow/cli/src/init/statusline-generator.ts (1,317 lines)Produces the .cjs script during npx claude-flow init:
function generateStatuslineScript(options: InitOptions): string {
// Generates 1,193-line CommonJS script with all metric panels
// Configurable via StatuslineConfig interface
}
function generateStatuslineHook(options: InitOptions): string {
// Generates shell integration hook for bash/zsh/starship
}
v3/@claude-flow/cli/src/init/settings-generator.tsWires the statusline into .claude/settings.json:
function generateStatusLineConfig(options: InitOptions): object {
return {
type: 'command',
command: 'node .claude/helpers/statusline.cjs',
refreshMs: config.refreshInterval, // Default: 5000
enabled: config.enabled,
};
}
v3/@claude-flow/cli/src/init/executor.tsDuring init:
.sh, .mjs) from package source if available.cjs + hook via statusline-generator.tsv3/@claude-flow/cli/src/init/types.tsinterface StatuslineConfig {
enabled: boolean; // Enable statusline
showProgress: boolean; // V3 DDD progress
showSecurity: boolean; // CVE status
showSwarm: boolean; // Swarm agent count
showHooks: boolean; // Hooks metrics
showPerformance: boolean; // Performance targets
refreshInterval: number; // Refresh ms (default: 5000)
}
| Preset | Statusline |
|---|---|
full | All panels enabled, 5s refresh |
minimal | Disabled (only core functionality) |
security | Security + swarm panels |
development | All panels enabled |
| File | Lines | Language | Role |
|---|---|---|---|
.claude/statusline.sh | 432 | Bash | Active statusline (settings.json) |
.claude/helpers/statusline.cjs | 1,193 | CommonJS | Generated comprehensive statusline |
.claude/statusline.mjs | 110 | ES Module | Lightweight agentic-flow statusline |
.claude/statusline-command.sh | 177 | Bash | JSON-input command statusline |
v3/@claude-flow/cli/src/init/statusline-generator.ts | 1,317 | TypeScript | Generator for .cjs during init |
v3/@claude-flow/cli/src/init/settings-generator.ts | ~20 | TypeScript | Wires statusLine into settings.json |
v3/@claude-flow/cli/src/init/executor.ts | ~60 | TypeScript | Copy/generate during init |
v3/@claude-flow/cli/src/init/types.ts | ~20 | TypeScript | StatuslineConfig interface |
| Operation | Budget | Actual |
|---|---|---|
| statusline.sh full execution | 1000ms | ~200ms |
| JSON file reads (jq) | 50ms each | ~10ms each |
| SQLite queries (sqlite3) | 100ms each | ~5ms each |
| Process detection (ps aux) | 200ms | ~50ms |
| Git operations | 100ms | ~20ms |
| GitHub API (gh, cached) | 500ms | ~100ms (first), ~0ms (cached) |
| Total refresh | 5000ms | ~400ms |
2>/dev/null)🛡️ 27% 54.7K ⊘ display confirms compaction
is blocked and shows exact token usage — no surprises🧠 86% score motivates pattern storage and shows
the system is learning from session interactionsps aux | grep is fragile for counting agents.
Mitigation: swarm-activity.json from the monitor daemon is preferred when availablepatterns.db and
transcript-archive.db via sqlite3 CLI. Mitigation: falls back to learning.json
if sqlite3 is not installedrefreshMs: 5000 balances freshness with CPU costStatuslineConfig▁▂▃▅▇ for rising usage)statusLine config: @anthropic-ai/claude-agent-sdk settings schema