Pipeline Commands
このコンテンツはまだ日本語訳がありません。
Pipeline Commands
Section titled “Pipeline Commands”rtk pipeline is how you inspect and debug the compression engine: what pipeline is active, what it does to a given input, and why a particular rule fired. See Pipelines for the concepts and Methods for the transforms themselves.
Quick reference
Section titled “Quick reference”rtk pipeline show # print the resolved pipelinertk pipeline validate # validate every pipeline file, non-zero on errorrtk pipeline test # parse, resolve and validate every loaded filertk pipeline status # last recorded pipeline load problem, if anyrtk pipeline explain # what fires for a given agent/tool, and whyrtk pipeline bench <file> # before/after tokens over a local filertk pipeline share # paste-ready markdown card of a pipelinertk pipeline share publish # publish it: GitHub repo (recommended) or gistrtk pipeline add <source> # adopt a shared pipeline: validate, install, report what it needsrtk pipeline search [query] # find shared pipelines on GitHub (topic rtk-pipeline)rtk pipeline promote <name> # move a shadow install live (--discard to drop it)rtk pipeline eval <name> # shadow-evaluate an installed pipeline on your live sessionsrtk pipeline log tail # the opt-in decision logInspecting what is active
Section titled “Inspecting what is active”rtk pipeline showPrints the pipeline that actually resolved for this directory. To print a built-in verbatim instead, name it:
rtk pipeline show rtk:defaultrtk pipeline show rtk:posthookValidating your own pipelines
Section titled “Validating your own pipelines”validate exits non-zero on errors, which makes it usable as a pre-commit or CI check:
rtk pipeline validatetest is the broader check — it parses, resolves and validates every pipeline file RTK loads, not just the active one. When RTK silently fell back because a file failed to load, status is where the reason is recorded:
rtk pipeline testrtk pipeline statusValidation never writes anything into the agent’s session. If a file fails to load while the agent is working, RTK drops that file only — your other pipeline files, their deny rules included, stay active — records the problem silently, and shows it the next time you run rtk gain, rtk pipeline status or validate. Every code is listed in Errors and Warnings.
Explaining a decision
Section titled “Explaining a decision”explain answers “why did this get compressed the way it did?” for a hypothetical input:
rtk pipeline explain --agent claude-code --tool Bash --command "git log -20"rtk pipeline explain --tool Read --file src/main.rsrtk pipeline explain --tool Read --file big.json --ranged| Flag | Meaning |
|---|---|
--agent | Agent to explain for (claude-code, cursor, cline, …) |
--tool | Tool name (Bash, Read, Grep, WebFetch, …). Defaults to Bash, or Read with --file |
--file | File path, for the before_tool.read conditions (file_lines, extension, …) |
--ranged | With --file: simulate a ranged read rather than a whole-file read |
--format | Content format (term, json, web, matches, lockfile) |
--command | Command line, for the command_* conditions |
--last | Explain the most recent real decision from the log instead of a hypothetical |
--file reads the same facts the hook reads, so a dry run cannot disagree with the live decision. Pipe output in to supply the after-tool size conditions (bytes, lines, tokens); without it a rule gated on output size cannot match:
rtk pipeline explain --tool Grep < output.txtIt reports the position, the rule that fired and why, the methods applied, tokens before and after, the recovery hint — and, for a rule that cannot run on your agent, which capability is missing.
--last is usually the fastest route when something surprising just happened — it needs the decision log enabled.
Shadow mode
Section titled “Shadow mode”[[hook.after_tool.shell]]name = "gentle-term"when = { is_rtk_command = false }use = ["ansi", "dedup"]shadow = trueThe rule runs, its decision and would-be savings are logged, nothing is emitted. rtk gain --shadow shows what it would have saved; turn shadow off when the numbers convince you. Transforms only, and hook rules only: a shadow proxy rule is skipped (W018). To try a whole shared pipeline the same way, see shadow installs.
Measuring a pipeline
Section titled “Measuring a pipeline”bench runs the resolved chain over a local file and reports before/after tokens:
rtk pipeline bench my-output.txtUse it to check whether a pipeline change helps on your own data.
The decision log
Section titled “The decision log”Off by default. When enabled it records decisions and commands, never content:
rtk pipeline log onrtk pipeline log tail # most recent 20 entriesrtk pipeline log tail --limit 100rtk pipeline log show --rule my-rule # filter by rule namertk pipeline log show --limit 200rtk pipeline log offEach entry records timestamp, session, position, tool category, the command as the agent issued it, the rule that fired, action or methods, tokens before and after, shadow flag and recovery hint — never a tool’s output, a file’s contents or a directive’s text. It lives at ~/.local/share/rtk/pipeline.log (JSON lines).
12:04:11 hook.after_tool.shell cargo test term-default term 3,812 → 640 recall 1f3a9c12:04:15 hook.before_tool.read src/Service.java shunt-large-read route → bulk-read12:04:31 hook.after_tool.shell rtk bulk-read … — skipped: is_rtk_commandEnable it while debugging a pipeline, then turn it off — it is the input rtk pipeline explain --last reads.
Recovery reporting
Section titled “Recovery reporting”RTK counts how often the agent asks for an original back. Reads of the recall store are recorded per tool and reported by rtk gain --recalls and the recovery-reads table in rtk gain --by-method.
It is reporting only: RTK never disables a rule on its own.
rtk gain also breaks savings down --by-rule, --by-method, --by-layer and --shadow; directives appear net of their standing cost and tasks net of worker cost. See Token Savings Analytics.
Sharing a pipeline
Section titled “Sharing a pipeline”share renders a pipeline’s measured impact and the pipeline file itself as one artifact. On a terminal it draws a clean, screenshot-able card; piped or redirected — or with --md — it emits the paste-ready markdown card instead (so rtk pipeline share > card.md keeps working), and the two renderings never mix on one stream.
rtk pipeline share # the active pipeline (terminal card)rtk pipeline share rtk:default # a named onertk pipeline share --md # the markdown card, even on a terminalThe card has two panels. What it does is derived from the resolved rules, never hand-written. Measured impact reports percentages per lever — command filtering and agent hooks as the share of a tool’s output bytes removed, delegated reads as the absolute context a worker kept out of your window, and prompt-cache as the share of input served from cache. Figures are estimates (≈ bytes/4): ratios are reliable, absolutes approximate. Percentages travel between setups; token counts and costs do not, which is why the card leads with percentages.
Publishing
Section titled “Publishing”rtk pipeline share publish is the interactive publisher. It offers two channels and walks you through validate → secret scan → preview of what leaves your machine → one confirmation:
- GitHub repository (recommended) — one public repo per pipeline, in your account:
pipeline.tomlplus a README card. The repo description carries the one-line install command, the repo gets thertk-pipelinetopic sortk pipeline searchfinds it, and stars on github.com/topics/rtk-pipeline are the leaderboard. - GitHub repository (private) — same repo, visible only to accounts you grant access. For a team or your own machines: anyone with access installs it with the same
rtk pipeline add github:you/repoline (theirghlogin provides the access). No topic, no search listing — and private is one visibility toggle away from public, so the secret scan and the warnings apply unchanged. - GitHub gist — a single public link with no discovery. Also available non-interactively as
rtk pipeline share --gist.
Other hosts: publishing targets GitHub, but installing does not — rtk pipeline add <url> accepts a raw file URL from anywhere (GitLab raw links included), so nothing stops a pipeline living wherever your team keeps code.
rtk pipeline share publish # interactive: choose repo or gist, confirm, publishrtk pipeline share --gist # non-interactive gist; prints: rtk pipeline add <url>Everything goes through your own gh CLI — RTK never sees or stores a token. If gh is missing or logged out, the publisher prints the exact manual steps instead. Publishing the same pipeline again updates the same repo, so its link and stars survive. If the pipeline was itself installed from someone else’s repo, the publisher offers to fork that repo instead of creating a fresh one, keeping the attribution chain visible on GitHub.
What leaves your machine: the pipeline file and the aggregate percentages from your share card. No commands, no paths, no history — and every number is labeled self-reported on the published card.
Adopting a shared pipeline
Section titled “Adopting a shared pipeline”add is the other half of share: one command validates a shared pipeline, installs it, and tells you what it needs.
rtk pipeline add github:owner/repo # a published repo (see `share publish`)rtk pipeline add github:owner/repo@<ref> # a specific commit, tag, or branchrtk pipeline add card.md # a saved share card (the TOML is auto-extracted)rtk pipeline add - < card.md # or pasted on stdinrtk pipeline add https://example.com/p # or any URLrtk pipeline add https://gist.github.com/u/ID # or a gist link from `share --gist`rtk pipeline add card.md --name flash # name it (default: the pipeline's own name, or the file stem)rtk pipeline add github:owner/repo --shadow # try it silently instead of installing (see below)A github: source (a plain https://github.com/owner/repo link works too) fetches the repo’s pipeline.toml pinned to a resolved commit — the commit is recorded locally, so nothing the author pushes later changes what you installed. A gist.github.com page link is resolved to its raw content automatically.
It validates in memory first — a pipeline that does not parse or type-check installs nothing. On success it writes a named pipeline to ~/.config/rtk/pipelines/<name>.toml (merged with your others, active immediately), then prints any missing auth as the exact export to run, and a rtk llm-proxy start line only if the pipeline actually has proxy rules.
On a terminal, after showing the pipeline’s rules, add offers three choices: install now, try silently first (a shadow install — see below), or quit. Re-adding a name that is already installed never replaces it silently: add shows a line diff of the change (and the commit movement, for pinned sources), repeats that you are responsible for what you pull and use, and asks. Non-interactively (pipes, scripts, CI) nothing installs without an explicit opt-in: pass --force to accept the disclosure, or --shadow to try the pipeline without applying anything. The same rule applies to publishing: share --gist in a pipe needs --force, and the interactive publisher asks for an explicit “I understand” after its warning.
Trying a pipeline silently (shadow installs)
Section titled “Trying a pipeline silently (shadow installs)”--shadow (or answering try silently interactively) installs into a shadow slot: the pipeline is evaluated and measured on your live sessions but applied to nothing — no rewrites, no filtering, no denies, no tasks. After a few sessions, compare and decide:
rtk pipeline eval <name> # what it would have done, vs your active pipeline, same trafficrtk pipeline promote <name> # go live (shows the diff against any installed version, confirms)rtk pipeline promote <name> --discard # drop it; nothing was ever appliedinstalled: ~/.config/rtk/pipelines/flash.tomlauth needed: export GEMINI_API_KEY=... (upstream `flash` — task `bulk-read`)active now, merged with your other pipelines — see `rtk pipeline show`The shared file names the environment variable for each key (api_key_env), never the key itself — you supply your own.
Discovering shared pipelines
Section titled “Discovering shared pipelines”rtk pipeline search # shared pipelines, most-starred firstrtk pipeline search rust # filtered by a free-text queryDiscovery is GitHub’s own index of the rtk-pipeline topic. Each result shows the repo, its stars, and its description (which carries the author’s headline number and the install line). The leaderboard is simply github.com/topics/rtk-pipeline sorted by stars. Descriptions and numbers are self-reported by their authors — rtk verifies nothing; rtk pipeline add shows every rule before anything installs, and --shadow lets you measure a pipeline on your own traffic before it touches anything.
Evaluating a pipeline on your own usage
Section titled “Evaluating a pipeline on your own usage”eval answers “would this pipeline do better on my workload?” without adopting it and without storing any conversation content. While armed, every tool output your sessions produce is also run through the candidate’s transforms in memory; only the before/after sizes are recorded, the content is discarded, and your agent’s output is untouched.
rtk pipeline eval squeeze-term --start # arm the candidate (must be installed — see `add`)# ...work normally for a few sessions...rtk pipeline eval squeeze-term # compare: candidate vs your active pipeline, same trafficrtk pipeline eval squeeze-term --stop # disarmPipeline eval — `squeeze-term` · last 30 days · vs raw, same trajectory candidate 5.1K → 3.2K tokens (37% removed · 214 outputs) est. active now 5.1K → 4.0K tokens (22% removed · 214 outputs) est. ~ tokens est. ≈ bytes/4; both measured on the same live outputs ~ classifier/route effects excluded from the candidateBoth lines are measured on the same outputs, so the comparison is apples-to-apples. Limits, stated on the report itself: token counts are bytes÷4 estimates; a candidate’s classifier- or route-driven rules are excluded (they would need live LLM calls), so eval covers its deterministic transforms.
The continuous counterpart lives in rtk gain: a per-mechanism efficiency section (filter+compress, LLM-spend, recalls, directives, proxy bill actual-vs-without) with a confidence tag on every line — measured where real provider usage exists, est. where it is a size estimate.
Related commands
Section titled “Related commands”rtk methods list # every registered method with its contractrtk tasks list # every configured task with its kind and upstream