跳到正文
FunCoding

搜索

搜索文档、Skill 和 MCP

writing-relayflows

文档与办公867.openskills/writing-relayflows/SKILL.md

安装

把这段话发给 Claude Code、Codex 或 Cursor。智能体会先检查安全性,你确认后才安装。

读取 https://funcoding.ai/skills/agentworkforce/relay/openskills-writing-relayflows/install.md ,按里面的步骤帮我安装这个 Skill。

SKILL.md

Writing Relayflows

Use when authoring a Relayflows flow (@relayflows/surface / @relayflows/sdk, the journal-based v2 engine — the CLI is flows, package versions 2.0.x) in TypeScript or YAML/JSON. Covers the three-rung ladder (run/llm/agent), the resident verbs (human/dispatch/done), verification gates, TypeScript vs YAML authoring, per-step cli/model selection and its resolution order, flows.json, and flows check/run/resume with their real refusal shapes and exit codes. Not for the older, unrelated @relayflows/core WorkflowBuilder engine (.pattern('dag')/.agent()/.step() chains) that writing-agent-relay-workflows and migrating-persona-to-relayflow cover — that's a different product despite the similar name.

Overview

Relayflows turns a coding-agent task into steps a journal can inspect, verify, and resume. A flow is data (YAML/JSON) or code (TypeScript) that compiles to the same journal-backed kernel spec. Every effect is journaled before it's treated as real — a journal write that fails fails the step, with no silent fallback.

Name collision warning. This repo also has skills for an older, unrelated engine that is also casually called "Relayflow" (singular) — @relayflows/core's WorkflowBuilder, a chained builder (workflow('name').pattern('dag').agent(...).step(...).run()). That's writing-agent-relay-workflows and migrating-persona-to-relayflow's territory. This skill is the v2 engine: @relayflows/surface's flow() function and the YAML/JSON dialect compiled by @relayflows/sdk. If you see .pattern(, .agent( as a chained builder call, or ctx.workflow.run(), you're in the other engine — stop and use one of those skills instead.

When to use this skill

  • Writing a new .flow.ts or .flow.yaml/.flow.json for the flows CLI (package @relayflows/sdk, binary name flows).
  • Deciding whether a step needs run (shell), llm (bare model call), or agent (harnessed coding agent in a workspace).
  • Wiring up cli/model for an agent or llm step, in either language.
  • Debugging a REFUSED [...] message from flows check or flows run.
  • Choosing between TypeScript and YAML for a given flow.

The ladder

Three step verbs, one per rung — never more (packages/sdk/src/spec.ts, export type StepType = 'deterministic' | 'llm' | 'agent';):

  1. run / deterministic — a shell command. No model. Implicit gate is exit_code == 0.
  2. llm / llm — a bare model call. Prompt in, verified output out. No workspace, no tool use.
  3. agent / agent — a harnessed coding agent in a workspace. Returns { summary, artifacts }, not raw text.

Plus four resident verbs that aren't ladder rungs: human (durable approval), dispatch (hand off to a child flow), done (typed finish), and in YAML, on/triggers (event entry points — out of scope for this skill).

Most flows only need run and llm. Climb to agent once a step needs hands on a real workspace.

Two ways to author the same thing

TypeScript

import { flow } from '@relayflows/surface';

export default flow('hello', async (f) => {
  const greeting = await f.run('echo "Hello from Relayflows"');
  console.log(greeting.trim());

  const answer = await f.agent('greeter', {
    task: 'Reply with one short hello sentence. Do not use tools or modify files.',
    cli: 'claude',
    model: 'claude-sonnet-4-6',
  });
  console.log(answer.summary);

  f.done('success');
});

YAML

version: '0.1.0'
name: hello
steps:
  - id: greeting
    type: deterministic
    command: 'echo "Hello from Relayflows"'
  - id: greeter
    type: agent
    dependsOn: [greeting]
    instruction: 'Reply with one short hello sentence. Do not use tools or modify files.'
    cli: claude
    model: claude-sonnet-4-6

The real Ctx contract (TypeScript)

packages/surface/src/context.ts, current as of origin/main@86a2ec2:

export interface AgentResult {
  summary: string;
  artifacts: string[];
}

export interface AgentOptions {
  task: string;
  workspace?: string;
  cli?: string;
  model?: string;
}

export interface Ctx {
  run(command: string): Step<string>;
  llm(strings: TemplateStringsArray, ...values: unknown[]): Step<string>;
  llm(
    prompt: string,
    options: { output: Record<string, unknown>; cli?: string; model?: string }
  ): Step<unknown>;
  agent(name: string, options: AgentOptions): Step<AgentResult>;
  human(question: string, options: { to: string }): Promise<boolean>;
  dispatch<T>(flow: string, input: unknown): Promise<T>;
  done(reason: RunCompletionReason): void;
  cloud: CloudHelper;
  slack: SlackHelper;
}

The real step shapes (YAML/JSON, packages/sdk/src/spec.ts)

```ts

interface DeterministicStepSpec {
  type: 'deterministic';
  id: string;
  command: string;
  dependsOn?: string[];
  timeoutMs?: number;
  verification?: VerificationSpec; // omit for implicit exit_code
}

interface LlmStepSpec {
  type: 'llm';
  id: string;
  prompt: string;
  dependsOn?: string[];
  verification?: OutputVerificationSpec;
  model?: string;
  cli?: string;
}

interface AgentStepSpec {
  type: 'agent';
  id: string;
  instruction: string;
  dependsOn?: string[];
  verification?: OutputVerificationSpec;
  agent?: string; // selects a named FlowSpec.agents entry
  cli?: string;
  model?: string;
  surfaces?: { workspace?: { surface: string }[]; streams?: { stream: string }[]; external?: string[] };
  recoveryMode?: 'reset' | 'inspect' | 'manual'; // default 'reset'
  permissions?: {
    fileGlobs?: string[];
    networkAllowlist?: string[];
    accessPreset?: 'readonly' | 'readwrite';
  };
}

interface FlowSpec {
  version: string; // required, e.g. '0.1.0' — not optional
  name?: string;
  cli?: string; // flow-level CLI default
  agents?: Record<string, { cli: string; model: string }>; // both fields required
  steps: StepSpec[];
  budget?: { maxTokensIn?: number; maxTokensOut?: number; maxDollars?: string };
}

Verification gates

Verification is control flow, not decoration — a gate decides whether a step actually completed, not just whether the process exited cleanly (packages/sdk/src/spec.ts, VerificationGateType):

- id: classify
  type: llm
  prompt: 'Classify this ticket as bug, feature, or question: "the export button does nothing"'
  cli: claude
  model: claude-sonnet-4-6
  verification:
    type: output_contains
    value: bug

cli / model: what a step actually runs on

Both YAML and TypeScript agent/llm steps can set cli and model directly (TypeScript since flows#310, AgentOptions.cli?/.model?). Resolution order for cli — checked once per step by preflight.ts's resolveCli (packages/sdk/src/preflight.ts:265-282), identical regardless of authoring language because both compile to the same StepSpec:

$ flows check hello.flow.yaml   # agent step, no cli anywhere
REFUSED [cli_unresolved] Step "greeter" has no CLI at step, flow, or project level. No flows.json was found from "..." to the filesystem root.

flows.json

{ "cli": "claude", "executors": ["cron"], "models": ["claude-sonnet-4-6"] }

Human approval and dispatch (TypeScript resident verbs)

```ts

import { flow } from '@relayflows/surface';

export default flow('ship-feature', async (f) => {
  const plan = await f.agent('planner', {
    task: 'Research and plan: add OAuth2 support',
    workspace: 'acme/api: readonly', // compiles to relayauth path scopes
  });

  const ok = await f.human(`Ship this?\n${plan.summary}`, { to: 'khaliq' });
  if (!ok) return f.done('canceled');

  const pr = await f.dispatch('garden/implement', plan); // hands off to a child flow
  f.done('success');
});

Running it: flows check / run / resume

Real usage (packages/sdk/src/cli.ts):

flows check [--json] <flow.yaml|spec.json>
flows run [--json] [--no-spawn] [--no-observer-link] [--data-dir <dir>] [--local-agent] <flow.yaml|spec.json>
flows run [--json] [--no-spawn] [--no-observer-link] [--data-dir <dir>] [--local-agent] <flow.ts> --input <inline-json-or-file>
flows resume [--json] [--no-spawn] [--no-observer-link] [--data-dir <dir>] <run-id>

Common mistakes

  • Forgetting version in a YAML/JSON FlowSpec. It's required, not optional — flows check refuses a spec without it.
  • Adding agents: to a TypeScript flow() header. FlowHeader has no such field; it throws TypeError: flow header has unknown fields: agents at authoring time. Named-agent maps + agent: selector are YAML/JSON-only (flows#300 tracks TypeScript composition via use:, not yet shipped).
  • Assuming flows.json's models sets a default model. It only validates models already declared elsewhere; it never selects one.
  • Not awaiting a step, or manually .then()-chaining one. Both are refused (unawaited_step / unsupported_verb) rather than silently ignored — the executor closes every root operation's lifecycle explicitly.
  • Running a .flow.ts without --input. Required even for flows that don't use their input argument.
  • Expecting a fifth done() reason. The set is closed: success | step_failed | canceled | budget_exceeded. Don't invent partial or skipped.

What this skill does NOT cover

  • Named-agent maps in TypeScript (agents: { reviewer: { cli, model } } + reuse across steps by name) — YAML/JSON only today. Tracked for TS composition via use: at flows#300.
  • recoveryMode, permissions, surfaces, budget, memory on agent steps — real YAML/JSON fields with no TypeScript equivalent. Author that step in YAML and reach it from TypeScript with f.dispatch if you need them.
  • Cloud execution (flows run --cloud), triggers/webhooks, memory retrieval, and the f.mcp/f.slack helper namespaces — each is its own surface with its own gotchas; see the Relayflows product docs for what's shipped versus designed-but-not-yet-implemented.
  • The older @relayflows/core WorkflowBuilder engine — see writing-agent-relay-workflows and migrating-persona-to-relayflow in this repo.

Quick reference

Verb / fieldLanguageNotes
f.run(command) / type: deterministicbothshell command, implicit exit_code gate
f.llm(...) / type: llmbothbare model call, no workspace
f.agent(name, opts) / type: agentbothharnessed coding agent, returns {summary, artifacts}
f.human(question, {to})TS onlydurable approval; YAML has no equivalent yet
f.dispatch(flow, input)TS onlyhand off to a named child flow
f.done(reason) / —TS / kernelone of success | step_failed | canceled | budget_exceeded
options.cli / step.clibothper-call/step CLI override (TS: flows#310)
options.model / step.modelbothper-call/step model; no flow/project default
agent: <name> + agents: {...}YAML/JSON onlynamed cli/model pair, reused by selector
flows check <file>CLIpure validate + preflight, no daemon
flows run <file> [--input ...]CLIactually executes; .flow.ts needs --input
flows resume <run-id>CLIresume a parked/crashed run

Verified against

AgentWorkforce/flows@86a2ec2 (origin/main). Built packages/surface and packages/sdk from source in a clean worktree (published npm @relayflows/[email protected] is stale — it predates flows#310 and lacks cli/model on AgentOptions; local build was symlinked in instead), then ran the real CLI:

$ flows check hello.flow.yaml         # this skill's YAML example, cli/model added, flows.json models allowlist set
CHECK PASSED hello.flow.yaml            # exit 0

$ flows check hello.flow.ts            # this skill's TypeScript example
CHECK PASSED hello.flow.ts              # exit 0

$ flows check extract.flow.yaml        # this skill's output_contains example
CHECK PASSED extract.flow.yaml          # exit 0

$ flows check hello.flow.yaml           # same YAML, no flows.json anywhere
REFUSED [cli_unresolved] Step "greeter" has no CLI at step, flow, or project level. ...   # exit 2

$ flows check hello.flow.yaml           # step model not in flows.json's models[]
REFUSED [model_unknown] Step "greeter" declares model "claude-sonnet-4-6" ... not listed in project model registry ...   # exit 2

相似的 Skill

pdf
anthropics/skills180k

pdf

Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.

文档与办公

discernment-nudge
anthropics/skills180k

discernment-nudge

After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals, or emails, estimates or projections, analysis or interpretation of data, factual claims they may rely on, or a multi-step argument — invoke this skill BEFORE finalizing your reply and then, if it applies, append 2-3 short follow-up questions, each tied to something specific in what you just produced, that help the user check key facts, probe the reasoning or assumptions, and notice missing context. Do this at most once per conversation. Skip it when the user asked a trivial how-to or simple lookup, wants a purely educational explanation, asked you only to format, convert, or assemble a file from content they provided, is writing code they will run, is doing creative writing or casual chat, or already asked you to double-check, cite, or review — the skill file explains these boundaries and the exact output format.

文档与办公

doc-coauthoring
anthropics/skills180k

doc-coauthoring

Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks.

文档与办公

docx
anthropics/skills180k

docx

Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.

文档与办公

pptx
anthropics/skills180k

pptx

Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill.

文档与办公

canvas-design
anthropics/skills180k

canvas-design

Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.

文档与办公