create-railcode-agent

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Create Railcode Agent

创建Railcode Agent

Update First

先更新

Before answering a Railcode agent or CLI question or running a
railcode
command, update the installed Railcode skills and CLI, then confirm npm's published version:
bash
npx skills add Railcode-HQ/railcode-skills
npm install -g railcode@latest
railcode --version
npm view railcode version
If the skill changes, re-read this file from the top. If npm is unreachable, state that the latest version could not be verified and do not claim this guidance is current. This version was checked against published Railcode CLI 0.1.28. Agent input is free-form; the
system
prompt defines its contract. The backend validates manifest tools and limits, so save-time validation is authoritative over this snapshot.
Since 0.1.28 the CLI self-updates within its major version — but only on an interactive terminal, and agent-driven sessions are non-interactive, so keep running the explicit
npm install -g railcode@latest
above rather than assuming you're on the latest.
在解答Railcode Agent或CLI相关问题,或执行
railcode
命令前,请先更新已安装的Railcode技能和CLI,然后确认npm上的发布版本:
bash
npx skills add Railcode-HQ/railcode-skills
npm install -g railcode@latest
railcode --version
npm view railcode version
如果技能有更新,请从头重新阅读本文档。如果无法访问npm,请说明无法验证最新版本,且不要声称本指南为当前最新内容。本版本已与发布的Railcode CLI 0.1.28进行核对。Agent输入为自由格式;
system
提示词定义了其约定。后端会验证清单工具和限制,因此保存时的验证结果比本文档快照更具权威性。
从0.1.28版本开始,CLI会在其主版本范围内自动更新,但仅在交互式终端中生效,而Agent驱动的会话为非交互式,因此请持续执行上述显式的
npm install -g railcode@latest
命令,不要假设已处于最新版本。

Map The Request To Railcode

将请求映射到Railcode功能

Use this table before authoring the manifest. If the request names an external product or data source, always check data connections/saved queries, service connectors, and personal connectors before deciding what is available; the detailed discovery commands are in the scoping step.
Hard file boundary: whenever AI must read, understand, extract, summarize, transform, or generate a file, use a managed agent with
tools.app_files
and its sandbox. The companion app may upload, store, list, download, and display files, but its in-page
llm.generate()
/
llm.stream()
must never consume file contents, file URLs, file-derived payloads, or generate file artifacts as a substitute. Publish durable results back through
tools.app_data_write
.
What the user asks forUse this Railcode feature
"Analyze company metrics/orders/customers from our database"
tools.saved_queries
(default); use
tools.adhoc_sql
only when direct SQL is explicitly requested
"Use our team's shared Stripe, CRM, or other SaaS account"
tools.connectors
plus
tools.docs
; the org owns the service-connector credential
"Use my Gmail, Slack, or another account I personally connected"
tools.personal_connectors
on a personal agent; calls run as the agent owner
"Connect my account to a product Railcode does not bundle"A custom MCP personal connector works for an app, not an agent; offer a companion app, service connector, or data import path
"Read records people manage in a Railcode app"
tools.app_data
, usually with a companion app
"Read, extract, summarize, transform, or generate a file with AI"Managed agent with
tools.app_files
+ sandbox; never the companion app's in-page LLM
"Edit this Word document / DOCX and preserve it as a file"Managed agent + companion app: the app stores/manages source and output files; declare
tools.app_files
to load the DOCX and
tools.app_data_write
to publish the edited document
"Create or revise a PowerPoint / PPTX deck"Managed agent + companion app: the app manages templates, inputs, and generated decks; use the sandbox to create/edit the PPTX and
publish_artifact_to_app
to return it
"Create a PDF report, form, or document"Managed agent + companion app: the app manages inputs and downloadable outputs; generate and verify the PDF in the sandbox, then publish it through
tools.app_data_write
"Analyze this Excel / XLSX workbook"Managed agent + companion app: the app stores the workbook and results; load it through
tools.app_files
, parse/analyze it in the sandbox, and publish durable results through
tools.app_data_write
"Write results or publish an artifact back to an app"
tools.app_data_write
(
app_kv_*
/
publish_artifact_to_app
)
"Remember state between runs"
tools.agent_kv
; use app storage instead when humans need to view or edit it
"Parse files, produce documents, or run code"Managed-agent sandbox plus
tools.app_files
; publish durable outputs back to an app with
tools.app_data_write
"Email a report from the system"
tools.email
; use a Gmail personal connector when it must send from the owner's own mailbox
"Run every morning, from Slack, or after a browser closes"Managed agent plus a cron schedule or the built-in Slack invocation path
"Give people a UI to upload inputs, trigger runs, or review results"A companion Railcode app using
agents.invoke()
/
agents.start()
"Call an arbitrary website/API"First look for service or bundled personal connectors; otherwise offer connector setup/import—a managed agent cannot fetch the open web or declare custom MCP toolkits
在编写清单前,请使用下表。如果请求涉及外部产品或数据源,在决定可用功能前,请务必检查数据连接/已保存查询、服务连接器以及个人连接器;详细的发现命令在范围界定步骤中。
文件处理边界:每当AI需要读取、理解、提取、总结、转换或生成文件时,请使用带有
tools.app_files
和沙箱的托管Agent。配套应用可上传、存储、列出、下载和显示文件,但页面内的
llm.generate()
/
llm.stream()
绝不能处理文件内容、文件URL、文件衍生负载,也不能生成文件产物来替代。请通过
tools.app_data_write
发布持久化结果。
用户需求使用的Railcode功能
"分析我们数据库中的公司指标/订单/客户数据"默认使用
tools.saved_queries
;仅当明确要求直接SQL时才使用
tools.adhoc_sql
"使用我们团队共享的Stripe、CRM或其他SaaS账户"
tools.connectors
+
tools.docs
;组织拥有服务连接器凭证
"使用我个人连接的Gmail、Slack或其他账户"个人Agent上使用
tools.personal_connectors
;调用以Agent所有者身份运行
"将我的账户连接到Railcode未捆绑的产品"自定义MCP个人连接器适用于应用而非Agent;可提供配套应用、服务连接器或数据导入路径
"读取用户在Railcode应用中管理的记录"
tools.app_data
,通常搭配配套应用
"用AI读取、提取、总结、转换或生成文件"
tools.app_files
+ 沙箱的托管Agent;绝不能使用页面内LLM
"编辑此Word文档/DOCX并保留为文件格式"托管Agent + 配套应用:应用存储/管理源文件和输出文件;声明
tools.app_files
以加载DOCX,使用
tools.app_data_write
发布编辑后的文档
"创建或修改PowerPoint/PPTX演示文稿"托管Agent + 配套应用:应用管理模板、输入内容和生成的演示文稿;使用沙箱创建/编辑PPTX,通过
publish_artifact_to_app
返回结果
"创建PDF报告、表单或文档"托管Agent + 配套应用:应用管理输入内容和可下载输出;在沙箱中生成并验证PDF,然后通过
tools.app_data_write
发布
"分析此Excel/XLSX工作簿"托管Agent + 配套应用:应用存储工作簿和结果;通过
tools.app_files
加载,在沙箱中解析/分析,通过
tools.app_data_write
发布持久化结果
"将结果写入或发布产物回应用"
tools.app_data_write
app_kv_*
/
publish_artifact_to_app
"在多次运行间保留状态"
tools.agent_kv
;当人类需要查看或编辑状态时,请改用应用存储
"解析文件、生成文档或运行代码"托管Agent沙箱 +
tools.app_files
;通过
tools.app_data_write
将持久化输出发布回应用
"从系统发送报告邮件"
tools.email
;当需要从所有者邮箱发送时,请使用Gmail 个人连接器
"每天早上运行、从Slack运行或在浏览器关闭后运行"托管Agent + cron调度或内置Slack调用路径
"为用户提供上传输入、触发运行或查看结果的UI"使用
agents.invoke()
/
agents.start()
的配套Railcode应用
"调用任意网站/API"首先查找服务或捆绑的个人连接器;否则提供连接器设置/导入方案——托管Agent无法访问开放网络或声明自定义MCP工具包

Sandbox Capabilities

沙箱功能

Managed agents run in a per-run code sandbox when sandboxing is configured for the deployment; there is no manifest key or per-agent switch to request it. The sandbox provides shell and file tools so the agent can write and run code, inspect and transform files, and use appropriate libraries for tasks such as parsing Excel/CSV data, extracting or assembling PDFs, editing documents, unpacking archives, and producing generated artifacts.
The sandbox is ephemeral and carries no credentials or standing org access. Bring tenant files in with
tools.app_files
, reach other systems only through explicit manifest authorities, and publish durable files or records back through
tools.app_data_write
. Anything left only in the sandbox disappears when the run ends.
当部署配置了沙箱时,托管Agent会在每次运行的代码沙箱中执行;无需清单密钥或每个Agent的开关来请求沙箱。沙箱提供Shell和文件工具,使Agent能够编写和运行代码、检查和转换文件,并使用合适的库完成解析Excel/CSV数据、提取或组装PDF、编辑文档、解压归档以及生成产物等任务。
沙箱是临时的,不携带凭证或持续的组织访问权限。通过
tools.app_files
引入租户文件,仅通过明确的清单权限访问其他系统,并通过
tools.app_data_write
发布持久化文件或记录。仅留在沙箱中的任何内容会在运行结束后消失。

When To Use A Managed Agent vs The In-Page LLM

何时使用托管Agent vs 页面内LLM

A managed agent (this skill) runs server-side under its own ratified manifest, with a code sandbox and durable, auditable runs. The in-page LLM (
llm.generate
/
llm.stream
with
tools
, via
$create-railcode-app
) runs in the app viewer's tab with the app's SDK authority and dies with the tab. Pick the first matching row:
The AI feature…Use
Summarizes / classifies / analyzes data the app already reads — user watching, done in secondsIn-page LLM
Reads, understands, extracts, summarizes, transforms, or generates any fileManaged agent (
app_files
+ sandbox); never the in-page LLM
Writes and runs codeManaged agent (sandbox)
Is triggered outside the app (Slack, cron, API)Managed agent
Runs unattended, must survive tab close, or needs retriesManaged agent
Has effects that must not depend on who's viewing (shared writes, send as the system)Managed agent
Needs a run history someone will audit or debugManaged agent
The planes compose: the app keeps its chat shell in the page and delegates heavy steps by calling
agents.invoke
/
agents.start
from an LLM tool's
run
(the app manifest declares
agents: [name]
; this agent declares
app_files: [app]
to reach uploaded files).
托管Agent(本技能)在服务器端运行,拥有已批准的清单,配备代码沙箱和持久化、可审计的运行记录。页面内LLM(通过
$create-railcode-app
使用的
llm.generate
/
llm.stream
搭配
tools
)在应用查看者的浏览器标签页中运行,使用应用的SDK权限,标签页关闭后即终止。请选择第一个匹配的场景:
AI功能场景…使用方案
总结/分类/分析应用已读取的数据——用户实时查看,几秒内完成页面内LLM
读取、理解、提取、总结、转换或生成任何文件托管Agent
app_files
+ 沙箱);绝不能使用页面内LLM
编写并运行代码托管Agent(沙箱)
在应用外部触发(Slack、cron、API)托管Agent
无人值守运行、需在标签页关闭后仍能运行或需要重试托管Agent
效果不依赖于查看者身份(共享写入、以系统身份发送)托管Agent
需要可审计或调试的运行历史托管Agent
两者可组合使用:应用在页面中保留聊天界面,通过LLM工具的
run
调用
agents.invoke
/
agents.start
来委托执行繁重步骤(应用清单声明
agents: [name]
;此Agent声明
app_files: [app]
以访问上传的文件)。

Start From An Example

从示例开始

Railcode ships worked, deployable examples at https://github.com/Railcode-HQ/railcode-examples. Read them to learn a pattern; copy one when it covers much of what the user is asking for. Each
agents/
example is a companion app plus its agent manifests, which is the shape most agent work takes.
ExampleWhat it isShowcases
agents/pitch-deck
An app for uploading company materials, paired with an agent that writes a polished pitch-deck PDF from them.App-paired managed agents:
app_data
/
app_files
access, code execution, publishing runs back as tracked versions.
agents/proposals
An app that imports Granola client meetings, paired with an agent that drafts editable
.docx
proposals from a meeting plus stored materials.
Personal connectors (Granola), cron-triggered agent runs, connector calls made directly from the app without an agent.
They pair an app with a managed agent because agents can't own files or storage directly — they work through an app they have data access to. The repo's
apps/
directory holds plain-app examples (kanban, data chat, CRM); reach for those through
$create-railcode-app
.
Ask, don't assume. When the request substantially overlaps an example, put the choice in the step 1 scoping batch, naming the example in the user's own terms:
"Railcode provides an example that already generates client proposals from meeting notes. Should I use that as a starting point, or build from scratch?"
Ask once, alongside the other scoping questions. Never copy an example unprompted, and don't raise the question when nothing matches.
示例说明展示内容
agents/pitch-deck
用于上传公司资料的应用,搭配可从资料生成精美的PDF演示文稿的Agent。应用配对托管Agent:
app_data
/
app_files
访问、代码执行、将运行结果作为跟踪版本发布。
agents/proposals
导入Granola客户会议记录的应用,搭配可从会议记录和存储资料生成可编辑
.docx
提案的Agent。
个人连接器(Granola)、cron触发的Agent运行、直接从应用调用连接器(无需Agent)。
它们将应用与托管Agent配对,因为Agent无法直接拥有文件或存储——它们通过有权访问数据的应用开展工作。仓库的
apps/
目录包含纯应用示例(看板、数据聊天、CRM);请通过
$create-railcode-app
使用这些示例。
询问而非假设。当请求与某个示例高度重叠时,在第1步范围界定环节中,用用户能理解的术语提及该示例,将选择权交给用户:
"Railcode提供了一个可从会议记录生成客户提案的示例。我应该以此为起点,还是从零开始构建?"
与其他范围界定问题一起一次性询问。切勿未经提示就复制示例,且当没有匹配示例时不要提出此问题。

Copying an example

复制示例

Copy only the one directory, as plain files — never
git clone
the repo into the user's project, add it as a submodule, or leave a
.git
behind:
bash
mkdir -p my-proposals
curl -fsSL https://github.com/Railcode-HQ/railcode-examples/archive/refs/heads/main.tar.gz \
  | tar -xz --strip-components=3 -C my-proposals railcode-examples-main/agents/proposals
--strip-components=3
drops
railcode-examples-main/agents/<example>/
, so the example's files land directly in
my-proposals/
. Swap the trailing path for the other row above. To study one manifest without copying anything, fetch it raw from
https://raw.githubusercontent.com/Railcode-HQ/railcode-examples/main/agents/proposals/agents/proposal-writer/agent.yaml
.
The agent manifests live at
agents/<agent-name>/agent.yaml
; the app around them is a normal Railcode app (
railcode.json
+
manifest.yaml
). Make the copy the user's own before authoring behavior:
  • Rename each
    agents/<name>/
    directory and the manifest's
    name
    , so the copy doesn't collide with an agent that already exists in the org.
  • Point
    tools.app_data
    /
    app_files
    /
    app_data_write
    at the renamed companion app slug, and keep
    visibility
    right for the tools declared (
    personal_connectors
    needs
    personal
    ).
  • Cut every tool the new agent doesn't need — a copied manifest carries the example's authority, not the narrowest set for this job — and re-size
    limits
    for the new workload.
  • Rewrite the
    system
    prompt and
    input_schema
    for the new contract; the example's prompt encodes its own step-by-step procedure and input shape.
  • In the app: set
    app
    in
    railcode.json
    , rename
    package.json
    's
    name
    , run
    npm install
    , update the
    agents:
    list in
    manifest.yaml
    and every
    agents.invoke
    /
    agents.start
    call, and replace the example's
    README.md
    if it ships one.
Then test the draft (
railcode agent test --file …
) before creating anything, exactly as in the build workflow below. If the download fails, say so and build from scratch — don't reconstruct an example from memory.
仅复制单个目录作为普通文件——绝不要
git clone
仓库到用户项目中、添加为子模块或留下
.git
目录:
bash
mkdir -p my-proposals
curl -fsSL https://github.com/Railcode-HQ/railcode-examples/archive/refs/heads/main.tar.gz \
  | tar -xz --strip-components=3 -C my-proposals railcode-examples-main/agents/proposals
--strip-components=3
会去掉
railcode-examples-main/agents/<example>/
路径,使示例文件直接保存到
my-proposals/
中。将末尾路径替换为上述其他示例的路径。如需查看单个清单而不复制任何内容,可从
https://raw.githubusercontent.com/Railcode-HQ/railcode-examples/main/agents/proposals/agents/proposal-writer/agent.yaml
获取原始文件。
Agent清单位于
agents/<agent-name>/agent.yaml
;其配套应用是普通的Railcode应用(
railcode.json
+
manifest.yaml
)。在编写行为逻辑前,请先将副本改为用户专属:
  • 重命名每个
    agents/<name>/
    目录和清单中的
    name
    ,避免与组织中已存在的Agent冲突。
  • tools.app_data
    /
    app_files
    /
    app_data_write
    指向重命名后的配套应用slug,并确保声明的工具
    visibility
    设置正确(
    personal_connectors
    需要
    personal
    )。
  • 删除新Agent不需要的所有工具——复制的清单携带示例的权限,而非当前任务所需的最小权限集——并根据新工作负载调整
    limits
  • 重写
    system
    提示词和
    input_schema
    以适配新约定;示例的提示词包含其自身的分步流程和输入格式。
  • 在应用中:设置
    railcode.json
    中的
    app
    、重命名
    package.json
    name
    、执行
    npm install
    、更新
    manifest.yaml
    中的
    agents:
    列表以及所有
    agents.invoke
    /
    agents.start
    调用,并替换示例自带的
    README.md
    (如果有的话)。
然后按照下面的构建流程,在创建任何内容前先测试草稿(
railcode agent test --file …
)。如果下载失败,请告知用户并从零开始构建——不要凭记忆重构示例。

Build Workflow

构建流程

1. Scope the agent

1. 界定Agent范围

Ask the scoping questions first, all in one batch — this is the moment the user is still present; questions dribbled out mid-build risk landing after they've stepped away. Phrase them for a non-technical user who knows nothing of Railcode internals: ask about intent and let the answers pick the primitives without naming them. "Should the whole team be able to run this, or just you?" — not "org or personal visibility?". "Should it also run by itself every morning?" — not "do you want a cron schedule?". The bullets below are what you need to learn from the answers, not the words to use.
If the request needs something agents can't do (scraping the open web, reacting to data changes, running continuously — see Hard Limits), say so up front and propose the nearest supported shape. Clarify only choices that materially change the definition:
External source discovery is mandatory. Whenever the user asks for an agent that reads, writes, syncs, searches, or acts on data from a named product or system ("X"), do not jump straight to a manifest or conclude that X is unsupported. Before choosing tools, inspect every Railcode integration plane available to the signed-in user:
bash
railcode db list                       # database/data-source connections
railcode query list                    # admin-published saved queries over those sources
railcode connector list                # org service connectors
railcode personal-connectors list      # per-user bundled and custom toolkits + connection status
Inspect any plausible match before authoring (
railcode connector docs <name>
and/or
railcode personal-connectors tools <toolkit>
), and copy exact connector names, endpoints, tool slugs, and schemas rather than guessing. Prefer saved queries over
adhoc_sql
. A bundled personal toolkit requires
visibility: personal
and runs as the agent owner; an org agent cannot declare personal connectors. If you cannot authenticate or reach the instance, ask what is configured and give the user these discovery commands rather than treating the failed check as evidence that no integration exists.
If no suitable source exists, explain the gap and offer concrete paths: have an admin connect a database and publish a saved query; enable or create an org service connector for a shared credential/API; or connect a bundled personal toolkit and make the agent personal. Also mention a remote custom MCP personal connector when X provides one, but state the boundary clearly:
custom_<slug>
connectors are callable by Railcode apps only, not managed-agent manifests. For an agent workflow, offer a companion app that calls the custom MCP as its viewer, an admin-configured service connector, or importing the needed data into a connected database/app store the agent can read. If X exposes none of those supported surfaces, say Railcode cannot connect to it directly and ask which alternative source the user wants to use.
  • the job it owns and the output expected;
  • the input it accepts — free-form JSON or text; the
    system
    prompt is the input contract;
  • the model and tools it needs;
  • whether it runs on demand, from an app, on a schedule, or by Slack mention;
  • whether it needs a companion app (see Companion Apps);
  • whether to start from an example — when one in Start From An Example covers much of the request, ask: "Railcode provides an example that already generates client proposals from meeting notes. Should I use that as a starting point, or build from scratch?";
  • what real systems, data, spend, or side effects a test may touch;
  • its visibility
    org
    (the default: shared, invokable by anyone with an invoke grant, managed by its creator or any admin) or
    personal
    (owned and invoked by its creator alone, admins included — no grant makes it shared, and it cannot later become
    org
    ). Pick
    personal
    only when the agent needs
    tools.personal_connectors
    (its owner's own Gmail/Slack/etc.) or should otherwise be usable by exactly one person.
Use the narrowest useful tool set and explicit instructions — but size
limits
the other way: match the token budget to the task and leave headroom. Document-editing and file-analysis runs use far more tokens than the defaults; a run that hits a cap dies as
limit_exceeded
, while an unused ceiling costs nothing (see manifest tools reference, "Sizing
limits
"). Do not invent tool identifiers, provider names, or manifest fields; managed-agent manifest fields are server-defined (author the file in JSON or YAML — see step 2). See manifest tools reference for the current
tools.*
vocabulary and
limits
— a snapshot of the server schema, not a contract; a save-time error always wins over this file.
首先一次性批量询问范围界定问题——此时用户仍在场;在构建过程中零散提问可能会在用户离开后才收到回复。请以不了解Railcode内部机制的非技术用户的角度措辞:询问意图,让答案选择合适的功能,而非直接提及功能名称。例如问"整个团队都能运行它,还是只有你可以?"——而非"组织或个人可见性?"。问"它需要每天早上自动运行吗?"——而非"你需要cron调度吗?"。下面的要点是需要从答案中了解的信息,而非提问的措辞。
如果请求需要Agent无法完成的功能(如抓取开放网络、响应数据变化、持续运行——请查看硬限制),请提前说明并提出最接近的支持方案。仅澄清会实质性改变定义的选项:
必须发现外部数据源。每当用户要求Agent读取、写入、同步、搜索或操作指定产品或系统("X")的数据时,不要直接编写清单或断定X不受支持。在选择工具前,请检查登录用户可用的所有Railcode集成渠道:
bash
railcode db list                       # 数据库/数据源连接
railcode query list                    # 管理员发布的基于这些数据源的已保存查询
railcode connector list                # 组织服务连接器
railcode personal-connectors list      # 每个用户的捆绑和自定义工具包 + 连接状态
在编写清单前,请检查任何可能匹配的内容(
railcode connector docs <name>
和/或
railcode personal-connectors tools <toolkit>
),并复制准确的连接器名称、端点、工具slug和模式,而非猜测。优先使用已保存查询而非
adhoc_sql
。捆绑的个人工具包需要
visibility: personal
,并以Agent所有者身份运行;组织Agent无法声明个人连接器。如果无法认证或访问实例,请询问已配置的内容并向用户提供这些发现命令,不要将检查失败视为无集成的证据。
如果没有合适的数据源,请说明差距并提供具体方案:让管理员连接数据库并发布已保存查询;启用或创建组织服务连接器以使用共享凭证/API;或连接捆绑的个人工具包并将Agent设为个人版。当X提供远程自定义MCP个人连接器时也可提及,但需明确边界:
custom_<slug>
连接器仅可被Railcode 应用调用,不可在托管Agent清单中声明。对于Agent工作流,可提供一个配套应用,由其查看者调用自定义MCP,或使用管理员配置的服务连接器,或导入所需数据到Agent可读取的连接数据库/应用存储中。如果X不支持上述任何方式,请说明Railcode无法直接连接,并询问用户想使用哪个替代数据源。
  • 它负责的工作和预期输出;
  • 它接受的输入——自由格式JSON或文本;
    system
    提示词是输入约定;
  • 它需要的模型和工具;
  • 它是按需运行、从应用触发、按调度运行还是通过Slack提及触发;
  • 是否需要配套应用(请查看配套应用);
  • 是否从示例开始——当从示例开始中的某个示例覆盖了请求的大部分内容时,询问:"Railcode提供了一个可从会议记录生成客户提案的示例。我应该以此为起点,还是从零开始构建?"
  • 测试可能涉及的真实系统、数据、费用或副作用;
  • 可见性——
    org
    (默认:共享,任何拥有调用权限的人都可调用,由创建者或任何管理员管理)或
    personal
    (仅由创建者拥有和调用,包括管理员——无法通过授权使其共享,且之后无法转为
    org
    )。仅当Agent需要
    tools.personal_connectors
    (所有者自己的Gmail/Slack等)或仅允许一人使用时,才选择
    personal
使用最窄的有用工具集和明确指令——但
limits
设置相反:将令牌预算与任务匹配并预留余量。文档编辑和文件分析运行比默认值消耗更多令牌;达到上限的运行会以
limit_exceeded
终止,而未使用的上限不会产生任何费用(请查看清单工具参考中的"调整
limits
大小")。不要发明工具标识符、提供商名称或清单字段;托管Agent清单字段由服务器定义(请以JSON或YAML格式编写文件——查看步骤2)。请查看清单工具参考获取当前
tools.*
词汇和
limits
——这是服务器模式的快照,而非约定;保存时的错误始终优先于本文档。

2. Authenticate and inspect

2. 认证和检查

Run
railcode login
if the CLI has no usable saved token. Agent commands use the selected organization context and work from any directory; agents can have
org
or
personal
visibility and do not use
railcode.json
.
Manifest file format.
--file
(on
create
/
update
/
test
) reads the manifest as JSON or YAML; the CLI picks the parser by extension (
.yaml
/
.yml
→ YAML, anything else → JSON), and both parse to the same object the API stores. There is no local manifest-schema validator — treat server validation and ratification warnings as authoritative.
For an existing agent, pull its exact stored manifest before editing:
bash
railcode agent show <agent>
railcode agent pull <agent> --output agent.json
pull
and
show --manifest
emit JSON only — there is no YAML output flag. If the user asks to see or store an agent's definition as YAML, convert that pulled JSON to YAML yourself and write
agent.yaml
; it round-trips back through
--file
unchanged.
For a new agent, author the manifest in the current server-supported shape — or, if the user chose an example in step 1, copy that example's
agent.yaml
and adapt it (see Start From An Example). Write the
system
prompt as described in Writing The System Prompt. Ask the user whether to save the definition in the current working directory. If yes, write it there as YAML (
agent.yaml
) and feed that file to
test
/
create
; if no, keep it in a scratch location outside their project.
如果CLI没有可用的保存令牌,请运行
railcode login
。Agent命令使用选定的组织上下文,可在任何目录中运行;Agent可设置
org
personal
可见性,无需使用
railcode.json
清单文件格式
--file
(用于
create
/
update
/
test
命令)读取JSON或YAML格式的清单;CLI根据扩展名选择解析器(
.yaml
/
.yml
→ YAML,其他 → JSON),两者解析为API存储的同一对象。没有本地清单模式验证器——请以服务器验证和批准警告为准。
对于现有Agent,请在编辑前拉取其准确的存储清单:
bash
railcode agent show <agent>
railcode agent pull <agent> --output agent.json
pull
show --manifest
仅输出JSON——没有YAML输出标志。如果用户要求以YAML格式查看或存储Agent定义,请自行将拉取的JSON转换为YAML并写入
agent.yaml
;它可通过
--file
命令无变化地往返转换。
对于新Agent,请按照当前服务器支持的格式编写清单——或者,如果用户在步骤1中选择了示例,请复制该示例的
agent.yaml
并进行调整(请查看从示例开始)。按照编写System提示词中的描述编写
system
提示词。询问用户是否要将定义保存到当前工作目录。如果是,将其保存为YAML格式(
agent.yaml
)并在
test
/
create
命令中使用该文件;如果否,请将其保存在用户项目外的临时位置。

3. Test the draft

3. 测试草稿

Test an unsaved manifest before creating or replacing an agent:
bash
railcode agent test --file agent.json --input '{"key":"value"}' --trace
Use
--input-file
for larger or sensitive test payloads. Testing invokes real configured models and tools, so it may incur spend, read real data, or cause tool side effects. Get any needed authorization before running a side-effecting test.
An agent that reads a companion app through
app_data
/
app_files
proves nothing against an empty app. Seed it first with
railcode app kv set <collection> <key> '<json>'
and
railcode app files upload <path>
(CLI 0.1.28+, app owner or org admin), using the shape the app itself writes, then clean up anything throwaway.
Do not rely only on the process exit code: a request that reached the runtime can exit 0 even when the run's printed status is failed. Check
Status:
or inspect
--json
.
A draft test does not persist writes.
app_data_write
tools run against a per-run in-memory overlay, while
agent_kv
tools are omitted because no saved agent exists yet. An untouched store after
test
is expected; use
create
+
run
to verify persistence. See manifest tools reference.
在创建或替换Agent前,测试未保存的清单:
bash
railcode agent test --file agent.json --input '{"key":"value"}' --trace
对于较大或敏感的测试负载,请使用
--input-file
。测试会调用真实配置的模型和工具,因此可能产生费用、读取真实数据或导致工具副作用。在运行有副作用的测试前,请获得必要的授权。
通过
app_data
/
app_files
读取配套应用的Agent,在空应用上测试无法验证功能。请先使用
railcode app kv set <collection> <key> '<json>'
railcode app files upload <path>
(CLI 0.1.28+,应用所有者或组织管理员)填充测试数据,使用应用自身写入的格式,然后清理临时数据。
不要仅依赖进程退出代码:即使运行的打印状态为失败,已到达运行时的请求也可能以0退出。请检查
Status:
或查看
--json
输出。
草稿测试不会保留写入操作。
app_data_write
工具针对每次运行的内存覆盖层执行,而
agent_kv
工具会被省略,因为尚未保存Agent。测试后存储未被修改是预期的;请使用
create
+
run
验证持久性。请查看清单工具参考

4. Publish or update

4. 发布或更新

bash
railcode agent create --file agent.yaml            # or agent.json — format is picked by extension
railcode agent create --file agent.yaml --visibility personal
railcode agent update <agent> --file agent.yaml
update
replaces the stored manifest. Preserve fields intentionally by starting from
railcode agent pull
, and read all ratification warnings before considering the change done. While you're in the pulled manifest, audit the
system
prompt for debris left by earlier test rounds — see Writing The System Prompt.
--visibility <org|personal>
on
create
/
update
/
test
sets or changes who the agent belongs to. Omit it on
create
/
test
for the default
org
; omit it on
update
to leave the existing visibility alone (never pass it just to be explicit — an omitted flag and an explicit
org
are different requests server-side). Creating/transitioning to
personal
needs the
agent:create
capability;
org
needs
agent:create_org
— holding one does not imply the other.
personal -> org
is rejected outright;
org -> personal
is allowed but does not retroactively change past shared runs/writes.
bash
railcode agent create --file agent.yaml            # 或agent.json — 格式由扩展名决定
railcode agent create --file agent.yaml --visibility personal
railcode agent update <agent> --file agent.yaml
update
会替换存储的清单。请从
railcode agent pull
开始,有意保留字段,并在完成更改前阅读所有批准警告。在拉取的清单中,请检查
system
提示词是否有之前测试轮次留下的冗余内容——请查看编写System提示词
create
/
update
/
test
命令中的
--visibility <org|personal>
用于设置或更改Agent的归属。在
create
/
test
中省略该标志时默认使用
org
;在
update
中省略该标志时保持现有可见性(不要为了明确而传递该标志——省略标志和显式传递
org
在服务器端是不同的请求)。创建/转换为
personal
需要
agent:create
权限;
org
需要
agent:create_org
权限——拥有其中一个权限并不意味着拥有另一个。
personal -> org
会被直接拒绝;
org -> personal
是允许的,但不会追溯更改过去的共享运行/写入记录。

5. Verify the saved agent

5. 验证已保存的Agent

bash
railcode agent run <agent> --input '{"key":"value"}' --trace
railcode agent show <agent> --manifest
Confirm the saved manifest, run status, output, and relevant trace steps. For organization observability logs, use
$manage-railcode-org
; its
railcode logs agent ...
workflow is an admin capability rather than part of agent authoring.
When the agent writes back through
tools.app_data_write
, a clean run status is not proof the data landed. Check the companion app's stores directly (CLI 0.1.28+, app owner or an org admin):
bash
railcode app kv collections --app <app>              # collections + record counts
railcode app kv list <collection> --app <app>        # what app_kv_set actually wrote
railcode app files list --app <app>                  # what publish_artifact_to_app produced
railcode app files download <name> --app <app>       # open the generated .docx/.pdf yourself
Add
--scope user --user <member-uuid>
or
--scope role --role <role-uuid>
to inspect a non-shared namespace;
--scope all
lists across every scope with owner attribution. This is also the fastest way to catch a personal agent writing into its owner's private scope when the team expected shared records.
bash
railcode agent run <agent> --input '{"key":"value"}' --trace
railcode agent show <agent> --manifest
确认已保存的清单、运行状态、输出和相关跟踪步骤。对于组织可观测性日志,请使用
$manage-railcode-org
;其
railcode logs agent ...
工作流是管理员权限,不属于Agent编写流程的一部分。
当Agent通过
tools.app_data_write
写入数据时,运行状态正常并不代表数据已成功写入。请直接检查配套应用的存储(CLI 0.1.28+,应用所有者或组织管理员):
bash
railcode app kv collections --app <app>              # 集合 + 记录数
railcode app kv list <collection> --app <app>        # app_kv_set实际写入的内容
railcode app files list --app <app>                  # publish_artifact_to_app生成的内容
railcode app files download <name> --app <app>       # 自行打开生成的.docx/.pdf文件
添加
--scope user --user <member-uuid>
--scope role --role <role-uuid>
以查看非共享命名空间;
--scope all
列出所有范围的内容并显示所有者归属。这也是快速发现个人Agent写入所有者私有范围,而团队期望共享记录的最快方式。

6. Schedule only when requested

6. 仅在请求时设置调度

Each managed agent currently has at most one cron schedule. Inspect it first, then use
schedule set
to upsert or a stricter create/update alias when that distinction matters.
bash
railcode agent schedule show <agent>
railcode agent schedule set <agent> --cron "0 9 * * *" --timezone UTC
Use an IANA timezone and a five-field cron expression. Verify the stored schedule after every mutation.
run-now
executes synchronously against real services.
A scheduled run passes null input — there is no per-schedule payload. Write the
system
prompt so a run with no input knows exactly what to do. See example agents (
daily-metrics-report
).
每个托管Agent目前最多有一个cron调度。请先检查现有调度,然后使用
schedule set
更新,或在需要区分时使用更严格的创建/更新别名。
bash
railcode agent schedule show <agent>
railcode agent schedule set <agent> --cron "0 9 * * *" --timezone UTC
使用IANA时区和五位cron表达式。每次修改后请验证存储的调度。
run-now
会同步针对真实服务执行。
调度运行会传递null输入——没有每个调度的负载。请编写
system
提示词,使无输入的运行明确知道要执行的操作。请查看示例Agent
daily-metrics-report
)。

Writing The System Prompt

编写System提示词

The
system
prompt is the agent's whole contract: what job it owns, how to read its input, and what to return. Two habits keep it working as it evolves.
Prefer positive instruction. Say what the agent should do rather than what it shouldn't. "Quote figures only from the uploaded materials, and write a bracketed placeholder where one is missing" gives the model something to aim at; "don't invent figures" forbids one path and leaves the rest to guesswork. This is an encouragement, not a rule — a real boundary ("never email anyone outside the attendee list") is worth stating outright, and hard limits should stay hard. But when a "don't" is standing in for a "do", write the "do".
Audit the whole prompt on every update. Each run reads the prompt cold. The agent has no memory of previous versions, earlier runs, or the bug being chased last week — so prompts accumulate debris that reads fine to us and misleads the agent:
  • Corrections phrased as history"We no longer do X, do Y instead." This agent never did X; the sentence introduces X and asks it to carry both. State only Y.
  • Debug leftovers — a temporary "for now, only process the first three rows", or a workaround for a bug that has since been fixed.
  • Orphaned steps — instructions naming a tool, app, connector, or field the manifest no longer declares.
  • The same rule three times in slightly different words, each added during a different test round. Restatements compete; keep the clearest one.
So before
railcode agent update
, read the stored
system
end to end from
railcode agent pull
— not from memory of what you last wrote — and rewrite it as the procedure someone encountering it cold would follow. A system prompt should read as a specification, never as a changelog.
system
提示词是Agent的完整约定:它负责的工作、如何读取输入以及返回内容。两个习惯可确保其在演进过程中正常工作。
优先使用正向指令。说明Agent应该做什么,而非不应该做什么。例如"仅引用上传材料中的数据,缺失的地方请写入带括号的占位符"为模型提供了明确目标;而"不要编造数据"只禁止了一种路径,其余路径仍需猜测。这是一种建议而非规则——真正的边界(如"绝不要向参会名单外的人发送邮件")值得直接说明,且硬限制应保持严格。但当"不要"可以替换为"要"时,请编写"要"的内容。
每次更新时审核整个提示词。每次运行都会重新读取提示词。Agent没有对之前版本、早期运行或上周修复的bug的记忆——因此提示词会积累对我们来说看似正常,但会误导Agent的冗余内容:
  • 以历史形式表述的修正——例如"我们不再做X,改为做Y"。此Agent从未做过X;这句话引入了X并要求它同时记住两者。请仅说明Y。
  • 调试遗留内容——临时的"目前仅处理前三行",或针对已修复bug的临时解决方案。
  • 孤立步骤——提及清单中不再声明的工具、应用、连接器或字段的指令。
  • 同一规则重复三次,每次表述略有不同,分别在不同测试轮次添加。重复表述会产生冲突;请保留最清晰的版本。
因此在执行
railcode agent update
前,请从
railcode agent pull
中读取存储的
system
提示词从头到尾——不要凭记忆回忆你上次编写的内容——并将其重写为初次接触的人会遵循的流程。System提示词应作为规范,而非变更日志。

Slack (On By Default)

Slack(默认启用)

Once an org admin has connected the org's Slack workspace, every active agent is reachable from Slack with no per-agent setup. Members run one by mentioning the bot in a channel it has been invited to:
@Railcode $<agent-name> summarize this thread
The agent name takes a leading
$
and must be the first token after the mention (a bare name gets a usage hint instead of silently running something). What this means for agent design:
  • Authority is unchanged. The Slack caller is resolved by verified email to a live org member and must hold the normal invoke grant — no match, no run. A
    personal
    agent is therefore reachable on Slack only by its owner.
  • Input arrives as
    { text: <message> }
    .
    Agent input is free-form, so any agent can be mentioned; its
    system
    prompt must explain how to interpret that input.
  • The platform posts the final reply into the mentioning thread, on success and on failure. Whatever the agent returns IS the Slack reply (a Slack-triggered run is told so in its system prompt and to write Slack mrkdwn); it does not need the
    slack
    connector to answer — that connector, when granted, is for interim progress updates only.
So any agent a team will use conversationally should handle free-text input and produce a final answer that reads well as a Slack message.
一旦组织管理员连接了组织的Slack工作区,所有活跃Agent都可从Slack访问,无需每个Agent单独设置。成员可在Agent已加入的频道中提及机器人来运行Agent:
@Railcode $<agent-name> summarize this thread
Agent名称前需加
$
,且必须是提及后的第一个令牌(不带
$
的名称会显示使用提示而非静默运行)。这对Agent设计的意义:
  • 权限不变。Slack调用者会通过验证邮箱解析为组织的活跃成员,且必须拥有正常的调用权限——无匹配则无法运行。因此
    personal
    Agent仅可由其所有者在Slack中访问。
  • 输入格式为
    { text: <message> }
    。Agent输入为自由格式,因此任何Agent都可被提及;其
    system
    提示词必须说明如何解释该输入。
  • 平台会将最终回复发布到提及的线程中,无论成功或失败。Agent返回的内容即为Slack回复(Slack触发的运行会在其system提示词中被告知要编写Slack mrkdwn格式);它不需要
    slack
    连接器来回复——授予该连接器权限仅用于临时进度更新。
因此,团队会以对话方式使用的任何Agent都应处理自由文本输入,并生成适合作为Slack消息的最终答案。

Companion Apps

配套应用

An agent often needs a companion app — a small static app (
$create-railcode-app
) deployed alongside it. Reach for this pattern whenever the agent relies on files or records someone must manage, or people need a place to trigger it and see its output:
  • Storage the agent relies on — the app is the UI for uploading and managing the files and records the agent reads:
    files.upload()
    /
    db
    in the app;
    app_files: [<app-slug>]
    /
    app_data: [<app-slug>]
    in the agent's manifest.
  • A surface for results — the agent writes back via
    app_data_write
    (
    app_kv_set
    ,
    publish_artifact_to_app
    ) and the app renders run outputs.
  • An easy way to test and trigger — a button wired to
    agents.invoke(name, input)
    (app manifest:
    agents: [<agent-name>]
    ) exercises the agent end-to-end far faster than hand-crafting CLI runs, and doubles as the interactive production trigger.
Name the app after the agent (e.g. agent
report-extractor
, app
report-extractor-console
), declare the narrowest slugs on both sides, and build the app with
$create-railcode-app
. The
agents/
rows in Start From An Example are working versions of exactly this pairing — read or copy one instead of assembling it from scratch.
Agent通常需要配套应用——一个部署在其旁边的小型静态应用(
$create-railcode-app
)。当Agent依赖用户必须管理的文件或记录,或用户需要触发Agent和查看输出的界面时,请使用此模式:
  • Agent依赖的存储——应用是上传和管理Agent读取的文件和记录的UI:应用中使用
    files.upload()
    /
    db
    ;Agent清单中使用
    app_files: [<app-slug>]
    /
    app_data: [<app-slug>]
  • 结果展示界面——Agent通过
    app_data_write
    app_kv_set
    publish_artifact_to_app
    )写入数据,应用渲染运行输出。
  • 便捷的测试和触发方式——连接到
    agents.invoke(name, input)
    的按钮(应用清单:
    agents: [<agent-name>]
    )比手动编写CLI运行命令更快地端到端测试Agent,同时可作为交互式生产触发方式。
请以Agent名称命名应用(例如Agent为
report-extractor
,应用为
report-extractor-console
),在双方声明最窄的slug,并使用
$create-railcode-app
构建应用。从示例开始中的
agents/
示例正是这种配对的工作版本——请阅读或复制一个示例,而非从零开始组装。

Hard Limits

硬限制

What a managed agent cannot do, regardless of manifest (the full platform-wide list is in
$create-railcode-app
→ "Limitations"):
  • Reach the open web. Sandbox egress is an allowlist (PyPI, npm, the presigned download host with
    app_files
    ); the
    connector
    tool reaches only ratified endpoints. No scraping, no arbitrary APIs.
  • Run long or continuously. Runs are bounded — at most 300 steps / 1200 s / the token caps in
    limits
    . No daemons, no monitors; recurring work is a cron schedule.
  • React to events. Triggers are app/API call, cron, and Slack mention only — no data-change or inbound-webhook triggers.
  • Invoke other agents. There is no agent→agent tool; compose pipelines through an app or an external caller instead.
  • Use custom MCP personal connectors. A user-added by-URL MCP connector (
    custom_<slug>
    ) works for its owner and for apps, but is not declarable in an agent manifest — ratification checks the static registry. Bundled toolkits only.
  • Keep sandbox state. The sandbox filesystem is per-run; anything worth keeping must be published (
    publish_artifact_to_app
    ) or written to KV before the run ends.
无论清单如何配置,托管Agent无法完成的操作(完整的平台范围限制请查看
$create-railcode-app
→ "限制"):
  • 访问开放网络。沙箱出口为白名单(PyPI、npm、
    app_files
    使用的预签名下载主机);
    connector
    工具仅可访问已批准的端点。无法抓取网页,无法调用任意API。
  • 长时间或持续运行。运行有边界限制——最多300步/1200秒/
    limits
    中的令牌上限。无法运行守护进程或监视器;重复工作需使用cron调度。
  • 响应事件。仅支持应用/API调用、cron和Slack提及触发——不支持数据变化或入站Webhook触发。
  • 调用其他Agent。没有Agent→Agent工具;请通过应用或外部调用者组合流水线。
  • 使用自定义MCP个人连接器。用户通过URL添加的MCP连接器(
    custom_<slug>
    )适用于所有者和应用,但不可在Agent清单中声明——批准检查会验证静态注册表。仅支持捆绑工具包。
  • 保留沙箱状态。沙箱文件系统为每次运行独有;任何需要保留的内容必须在运行结束前发布(
    publish_artifact_to_app
    )或写入KV存储。

Permissions and Boundaries

权限和边界

  • list
    ,
    show
    , and
    pull
    only ever return org agents plus the caller's own personal agents — someone else's personal agent is invisible (a 404, never a 403, to avoid confirming it exists), admins included.
  • For an org agent:
    run
    needs an invoke grant for that agent;
    update
    /
    delete
    /
    test
    / schedule mutations are allowed for the agent's own creator, or any org owner/admin — not every member. Creating (or transitioning an existing agent to)
    org
    additionally needs the
    agent:create_org
    capability.
  • For a personal agent: invoke and manage are both owner-only, with no admin override — there is no break-glass, so even an org owner/admin can't reach someone else's. Creating one needs the broadly-grantable
    agent:create
    capability, not owner/admin.
  • delete
    archives the agent while keeping run history and requires
    --yes
    outside a TTY.
  • Use
    $create-railcode-app
    when building a static app that invokes an agent through
    agents.invoke(name, input)
    . A privileged app manifest declares
    agents: [name]
    .
  • An app can also run its own agentic loop in the page with
    llm.generate({ tools })
    /
    llm.stream({ tools })
    — no managed agent involved. See When To Use A Managed Agent vs The In-Page LLM at the top of this skill for the split.
  • Use
    $manage-railcode-org
    for members, roles/grants, apps/access, connections, service connectors, analytics, and organization logs.
  • list
    show
    pull
    仅返回组织Agent以及调用者自己的个人Agent——其他人的个人Agent是不可见的(返回404,而非403,以避免确认其存在),包括管理员。
  • 对于组织Agent:
    run
    需要该Agent的调用权限;
    update
    /
    delete
    /
    test
    /调度变更仅允许Agent的创建者或任何组织所有者/管理员执行——并非所有成员。创建(或将现有Agent转换为)
    org
    还需要
    agent:create_org
    权限。
  • 对于个人Agent:调用和管理均为仅所有者可用,无管理员覆盖权限——没有应急权限,因此即使组织所有者/管理员也无法访问他人的个人Agent。创建个人Agent需要广泛授予的
    agent:create
    权限,而非所有者/管理员权限。
  • delete
    会归档Agent并保留运行历史,在非TTY环境中需要
    --yes
    参数。
  • 当构建通过
    agents.invoke(name, input)
    调用Agent的静态应用时,请使用
    $create-railcode-app
    。特权应用清单需声明
    agents: [name]
  • 应用也可在页面内通过
    llm.generate({ tools })
    /
    llm.stream({ tools })
    运行自己的Agent循环——无需托管Agent。请查看本文档顶部的何时使用托管Agent vs 页面内LLM了解区分方式。
  • 请使用
    $manage-railcode-org
    管理成员、角色/权限、应用/访问、连接、服务连接器、分析和组织日志。

Reference

参考

Read CLI reference for the exact agent commands, aliases, schedule behavior, inputs, outputs, and failure semantics. Read manifest tools reference for the
tools.*
vocabulary, what each grants, its permission gate, and
limits
. Read example agents for worked, runnable manifests covering a minimal agent and a scheduled query-to-email workflow. For complete agent-plus-companion-app projects (pitch decks, client proposals), read or copy from
railcode-examples
— see Start From An Example.
请阅读CLI参考获取准确的Agent命令、别名、调度行为、输入、输出和失败语义。请阅读清单工具参考获取
tools.*
词汇、每个工具的权限、权限门限和
limits
。请阅读示例Agent获取涵盖最小Agent和调度查询到邮件工作流的可运行清单。如需完整的Agent加配套应用项目(演示文稿、客户提案),请阅读或复制
railcode-examples
中的内容——查看从示例开始