/cospan:flowfrom cospan
Defines programmable cross-harness workflows using agent, synthesize, orchestrate, and refine primitives. Useful for chaining AI model calls, parallel analysis, dynamic orchestrator-workers, and iterative refinement.
Ships in cospan. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Run saved flows — workspace-first (<workspace>/.cospan/flows/<name>/flow.mjs, default for repo workflows and shadowing global ~/.cospan/flows/<name>/flow.mjs, or single-file <name>.mjs) — or pass an explicit .mjs file / flow directory path via cospan_flow (preferred) or CLI:
cospan_flow({ cwd, flow: "<name-or-path>", prompt: "<prompt>" }) -> cospan_wait({ cwd, id: "<flow-id>", timeout: "30m" })node "<skill-dir>/../../bin/cospan.mjs" flow <name-or-path> --prompt "<prompt>" -> node "<skill-dir>/../../bin/cospan.mjs" wait <flow-id> --timeout 30m (profile: node "<skill-dir>/../../bin/cospan.mjs" flow trace [<flow-id>] [--markdown|--json])import { agent, synthesize, orchestrate, refine } from 'cospan/flow')Mapped directly to Anthropic's effective agent workflow patterns:
agent('<harness>/<model-id>', options) (Chaining / Routing / Parallelism): Stateless preset using globally unique <harness>/<exact-model-id> (e.g. codex/gpt-6.2-sol, agy/gemini-4-neon, claude/claude-sonnet-5-5, dsh/<provider>/<model>, grok/grok-4.7), with optional { effort, readonly, timeout, cwd, instructions, description, schema, role }. Compose with plain JS await, if, Promise.all, and session.touches(globs). Calling await coderAgent.run(prompt, turnOpts?) (optionally passing { cwd } for worktree-isolated parallelism) returns a resumable Session ({ text, data, resumable, cwd, baseHead, touchedFiles, touches(globs), diff, turnDiff, continue(nextPrompt, turnOpts?) }).synthesize(prompt, { agents, synthesizer, stage? }) (Blind Parallel Analysis & Synthesis): Runs agents independently in parallel under readonly: true, then synthesizes consensus and trade-offs via synthesizer.orchestrate(prompt, { lead, workers, isolation?, stage? }) (Dynamic Orchestrator-Workers): Pass workers: { explorer: explorerAgent, coder: coderAgent } (or { agent, description } entries to populate the lead's Worker Selection Table); lead dynamically spawns 0..N parallel workers via cospan flow spawn and collects batches via cospan wait <id1> <id2> ..., returning lead's resumable Session (leadSession) so subsequent refine() or .continue() talks directly to lead while retaining access to the worker roster. isolation ("auto" default | "shared" | "worktree") is a prompt-level coordination suggestion injected into lead (not runtime-enforced).refine(session, { evaluator, criteria?, maxRounds = 2, stage? }) (General Session -> Session Evaluator-Optimizer): Accepts any Session handle (agent.run, orchestrate, or prior refine) and returns a chainable Session with .passed, .blocked, .verdict ('pass' | 'revise' | 'blocked'), .rounds (fix cycles executed, 0..=maxRounds), .summary, .feedback, and .evaluations. evaluator accepts an agent(...) preset (readonly: true, L0 git workspace pointer with baseHead and evaluator session reuse via .continue()) or a JS function (session, { round, stage, criteria }) => { pass, summary?, feedback? } for deterministic shell/test checks. Set maxRounds: 0 for one-shot evaluation without rework.<workspace>/.cospan/flows/<name>/ when authoring flows: Save any workflow that references repo docs, verification gates, or branch conventions (AGENTS.md, REVIEW.md, SIMPLIFY.md, test commands) inside <workspace>/.cospan/flows/<name>/flow.mjs so it stays version-controlled and shared with the repo (workspace flows automatically shadow same-named global flows). Reserve ~/.cospan/flows/<name>/ strictly for personal, repo-agnostic utilities..mjs pure orchestration & never wrap repo docs: Reference repo-native guides directly via path pointers (Follow AGENTS.md, Follow REVIEW.md, Follow SIMPLIFY.md)—never restate them into duplicate wrapper .md files. Only colocate a .md file alongside flow.mjs for genuinely flow-specific prompt text and import it via import taskPrompt from './task.md' (.md and .txt resolve to UTF-8 strings natively).baseHead, changed/untracked file list, diff --stat) and let agents fetch diffs and files via commands on demand instead of pasting raw diffs or full manuals.let coderSession = await coderAgent.run(...); coderSession = await refine(coderSession, ...); return await coderSession.continue(...) directly with zero wrapper unwrapping.await / if / Promise.all for simple chaining, branching, and fan-out; reach for synthesize, orchestrate, or refine only when blind deliberation, dynamic fan-out, or stateful evaluation-optimization loops add real value.session.blocked (true P0 hazards: broken invariants, security/data-loss risk, or missing human decision). When a correctness review loop exhausts maxRounds with real revise blockers still open, keep the deliverable moving but surface them prominently as Unresolved Review Blockers requiring human/host sign-off—never relabel them as non-blocking. Reserve non-blocking FYI downgrades strictly for optional polish passes such as simplify (capped at maxRounds: 1).Promise.all or synthesize, e.g. a standalone multi-lens review report) and partition parallel writers by core conflict domain instead of serializing unrelated work. Keep dependent review-fix passes (e.g. correctness review -> post-fix simplify) cleanly chained with native refine() instead of hand-rolling custom JS evaluators around LLM agents.refine() builds L0 git manifests automatically, and post-step telemetry (such as attaching trace.toMarkdown() / trace.upsertIn(body) to a PR/MR via gh pr edit) should run in best-effort JS (try/catch) after the publishing turn finishes so the timeline is complete, verbatim, and never fails delivery..mjs: Since .mjs has no static type annotations, avoid abbreviations or vague names (work, task, note, res) in the core loop—name agents by role (coderAgent, codeReviewer, diffSimplifier), resumable handles ...Session (coderSession), model inputs ...Prompt / ...Instructions (issuePrompt, openPrPrompt), and intermediate data by full domain nouns (unresolvedBlockers)..cospan/flows/dev/flow.mjs)import { agent, refine } from 'cospan/flow';
// Prefer globally unique `<harness>/<exact-model-id>` identifiers for version determinism:
const coderAgent = agent('agy/gemini-4-neon', {
effort: 'high',
instructions: 'Follow AGENTS.md and run targeted checks before finishing.',
});
const codeReviewer = agent('codex/gpt-6.2-sol', { effort: 'high', readonly: true });
const diffSimplifier = agent('agy/gemini-4-neon', { effort: 'high', readonly: true });
export default async ({ prompt: issuePrompt, cwd, trace }) => {
let coderSession = await coderAgent.run(issuePrompt, { stage: 'dev' });
const unresolvedBlockers = [];
const simplificationNotes = [];
coderSession = await refine(coderSession, {
evaluator: codeReviewer,
criteria: 'Follow REVIEW.md.',
maxRounds: 2,
stage: 'review',
});
if (coderSession.blocked) return coderSession; // halt only on true P0 blockers
if (!coderSession.passed) {
unresolvedBlockers.push(coderSession.feedback || coderSession.summary);
}
coderSession = await refine(coderSession, {
evaluator: diffSimplifier,
criteria: 'Follow SIMPLIFY.md.',
maxRounds: 1,
stage: 'simplify',
});
if (coderSession.blocked) return coderSession;
if (!coderSession.passed) {
simplificationNotes.push(coderSession.feedback || coderSession.summary);
}
const blockerSuffix = unresolvedBlockers.length
? `\n\n## Unresolved Review Blockers (Requires Human/Host Sign-Off — Do Not Auto-Merge)\n- ${unresolvedBlockers.join('\n- ')}`
: '';
const simplifySuffix = simplificationNotes.length
? `\n\n## Optional Simplification Notes (non-blocking)\n- ${simplificationNotes.join('\n- ')}`
: '';
const openPrPrompt =
`Run verification checks and open the PR.${blockerSuffix}${simplifySuffix}`;
const publishedSession = await coderSession.continue(openPrPrompt, { stage: 'pr' });
// Best-effort post-step: attach trace.upsertIn(prBody) via JS/gh after `pr` finishes
return publishedSession;
};
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
7 skills in this plugin
/agyPoint-to-point headless delegation to Google Antigravity (`agy`) via cospan ($cospan:agy). Delegate repository-wide research, multimodal/large-context analysis, code review, or implementation tasks to Google Antigravity CLI. Model shortcuts include `neon`, `carbon`, `hydrogen`, `opus`, `sonnet`./claudePoint-to-point headless delegation to Anthropic Claude Code (`claude`) via cospan ($cospan:claude). Delegate code review, architectural analysis, repository debugging, or scoped implementation tasks to Anthropic Claude Code CLI. Model shortcuts include `sonnet`, `opus`, `haiku`, `fable`./codexPoint-to-point headless delegation to OpenAI Codex (`codex`) via cospan ($cospan:codex). Delegate code review, second-opinion debugging, repository research, scoped implementation tasks, or (only when explicitly requested via Codex) raster image generation/editing to OpenAI Codex CLI. Model shortcuts include `sol`, `terra`, `astra`, `luna`. Use when you need explicit model/effort selection or an isolated detached cospan session./dshPoint-to-point headless delegation to DeepSeek Harness (`dsh`) via cospan ($cospan:dsh). Delegate repository research, verification, second-opinion debugging, or implementation tasks to DeepSeek Harness CLI. Model shortcuts include `flash`, `pro`, `v4.1-flash`, `v4-pro`./grokPoint-to-point headless delegation to xAI Grok Build (`grok`) via cospan ($cospan:grok). Delegate repository research, fast code review, real-time web/X research and verification, second-opinion debugging, or scoped implementation tasks to Grok Build CLI. Model shortcuts include `build`, `fast`./jobsInternal lifecycle reference for cospan detached jobs inside Codex.npx claudepluginhub keli-wen/cospan --plugin cospanOther plugins' skills for the same job