Kick off background validation agents (coverage, tests, linting) while performing documentation/memory work in parallel, then merge results. Saves wall-clock time by overlapping verification with wrap-up tasks.
Overlap verification (coverage, tests, lint) with documentation/memory work by running validation in background agents while the orchestrator handles wrap-up tasks in the foreground. This pattern consistently saves 30-60% wall-clock time versus sequential verify→document workflows.
| Input | Required | Description |
|---|
verification_commands | Yes | List of commands/checks to run in background (e.g., pytest --cov, ruff check) |
foreground_tasks | Yes | List of documentation/memory/contract tasks to do in parallel |
working_dir | No | Working directory (defaults to project root) |
timeout_ms | No | Background agent timeout (default: 300000 / 5 min) |
Before splitting work, confirm:
If any foreground task needs verification output (e.g., "write coverage % in the report"), move that task to post-merge and do it after results arrive.
Launch one or more background agents for verification work:
Agent(
description: "Background coverage analysis",
prompt: "Run the following verification commands in {working_dir} and report results:
{verification_commands}
Report: (1) command, (2) exit code, (3) summary metrics (coverage %, test counts, lint issues), (4) full failure output for any failures. Do not fix anything — only report.",
subagent_type: "general-purpose",
run_in_background: true
)
If multiple independent verification types exist (tests, coverage, lint), group them into a single agent unless they conflict. Only split into separate agents if they would interfere with each other.
While background verification runs, execute the foreground tasks directly:
Do NOT poll or sleep waiting for background agents. Work continuously on foreground tasks.
After foreground work is complete, the system notifies when background agents finish. Collect all results.
If foreground work finishes before background agents:
## CONTRACT
verification_result:
commands_run: <N>
overall: <PASS | FAIL | ERROR>
details:
- command: <cmd> | exit_code: <n> | summary: <metrics>
failures: <list or "none">
foreground_work_done:
- <task_1>: DONE
- <task_2>: DONE
wall_clock_savings: "~{N}s saved by overlapping verification with {M} foreground tasks"
merged_verdict: <CLEAN | NEEDS_FIXES>
If background verification found issues:
Do NOT retroactively modify documentation unless the fix invalidates what was documented.
| Scenario | Action |
|---|---|
| Background agent times out | Mark verification as ERROR, complete foreground work, retry sequentially |
| Background agent crashes | Retry verification commands directly via Bash |
| Foreground task fails | Complete it before merging — do not let verification results mask foreground failures |
| Verification reveals implementation bugs | Fix bugs first, then re-verify; do not rewrite docs unless fix changes documented behavior |
| All foreground tasks depend on verification | Abort this pattern — run verification first, then foreground work sequentially |
Variant A: Single Background + Multiple Foreground (most common) — One verification agent, orchestrator handles 2-4 foreground tasks directly.
Variant B: Multiple Background + Single Foreground — Several verification agents (tests, coverage, lint) all in background, one substantial foreground task.
Variant C: Split Background + Split Foreground — Both verification AND documentation delegated to separate background agents. Orchestrator only merges.
After completing a bug fix to novatrade/monitor/degradation_detector.py:
Background (spawn immediately):
Agent: "Run pytest tests/test_strategy_degradation_detection.py --cov=novatrade/monitor -v"
Foreground (do while tests run):
1. Write workflow learning to Obsidian vault
2. Upsert decision memory to Fusion Memory
3. Update TASKS/ file status to DONE
4. Write OUTPUT/ result file
After background completes:
Merge: verification PASS + 4 foreground tasks DONE → merged_verdict: CLEAN
Wall-clock time: ~45s (parallel) vs ~75s (sequential) = ~40% savings.
The file write keeps getting blocked by permissions. Please approve the write to .claude/skills/concurrent-background-verification/SKILL.md and I'll save it, or you can accept one of the pending permission prompts.