Add root --skill flag printing the bundled skill text - #15264
Conversation
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
There was a problem hiding this comment.
Pull request overview
Adds a new root-only --skill flag to the but CLI that prints the bundled SKILL.md (with the CLI version injected) to stdout and exits, enabling agents/users to easily load the GitButler skill text into context via piping/redirection.
Changes:
- Added a new top-level
--skillflag and short-circuit execution path to print the bundled base skill text and exit. - Exposed
command::skill::base_skill_text()to reuse the existing skill content preparation/version-injection logic. - Added an integration test asserting
but --skilloutput matches the bundledSKILL.mdwith the runtime--versioninjected, and updatedbut skill --helpdocs to reference the flag.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/but/src/args/mod.rs | Adds the root-only --skill flag and updates skill subcommand help text to reference it. |
| crates/but/src/lib.rs | Implements early-exit behavior that prints the skill text when --skill is set. |
| crates/but/src/command/skill/mod.rs | Introduces base_skill_text() to produce version-injected SKILL.md content for --skill. |
| crates/but/tests/but/command/skill.rs | Adds an integration test validating but --skill output against the bundled SKILL.md with version injection. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // Like `--version`, `--skill` prints and exits without dispatching a subcommand. | ||
| if args.skill { | ||
| print!("{}", command::skill::base_skill_text()?); | ||
| return Ok(()); | ||
| } |
|
Since we already have a |
but --skill writes SKILL.md (with the CLI version injected) to stdout and exits, like --version, so agents can load the base skill without installing it. Also cross-referenced from the but skill command help.
f130cab to
48033fc
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (2)
crates/but/src/lib.rs:297
but --skillwrites viaprint!, which bypasses the CLI’s usual broken-pipe suppression (seeOutputChannel’swrite_strhandling). For pipe-friendly behavior (e.g.but --skill | head), write to stdout and explicitly ignoreErrorKind::BrokenPipeinstead of usingprint!.
// Like `--version`, `--skill` prints and exits without dispatching a subcommand.
if args.skill {
print!("{}", command::skill::base_skill_text()?);
return Ok(());
}
crates/but/src/command/skill/mod.rs:984
command::skillis exported as a public module (crates/but/src/command/mod.rs), so makingbase_skill_textpubexpands the crate’s public API surface. Since it’s only used internally byhandle_args, it should likely bepub(crate)to avoid committing to it as a supported API.
/// The bundled base skill text (SKILL.md) with the CLI version injected,
/// as printed by `but --skill`.
pub fn base_skill_text() -> Result<String> {
prepare_skill_content(option_env!("VERSION").unwrap_or("dev"))
}
but --skillwrites the bundled base skill text (SKILL.md) to stdout and exits, so agents can load the GitButler skill into context directly (e.g.but --skill >> prompt.md) without installing skill files first.What changed
--skillflag onArgs. It short-circuits right after argument parsing, like--version:but --skillprints the skill even if a subcommand follows, andbut status --skillis rejected since the flag is not global.prepare_skill_contentpath via a newcommand::skill::base_skill_text(), so the CLI version is injected into the frontmatter exactly asbut skill installwrites it, and the embedded file is UTF-8 validated.but skill --helplong help now cross-referencesbut --skillfor discoverability.Decisions
SKILL.mdis printed, not thereferences/files; the flag targets bootstrap/context-loading, where the base skill is the entry point.Testing
Integration test asserts
but --skilloutput equals the embeddedSKILL.mdwith the version swapped in, deriving the expected version frombut --versionso it holds for bothdevand release builds.