rust-installable-cli
БесплатноБез исполняемых скриптовНе проверенInstallable Rust CLI: embedded default config, config layers, user dirs, clap input beside subcommands. Use when making a binary run outside its repo.
от laurigates★ 61 звезда на GitHubОб этом скилле
rust-installable-cli — Patterns for a Rust CLI That Runs Outside Its Repo
A CLI that only ever ran from its own checkout can read configs/ by relative
path, write into the working tree and keep its cache beside the sources. Once it
is installed (cargo install, a release archive, a Homebrew formula) none of
that exists. This skill covers what replaces it: config embedded in the binary,
a layered config with a user file, user directories, a clap shape that accepts
an input file next to subcommands, and copying results out of a cache.
Code for every section is in REFERENCE.md. The snippets were compiled and tested against clap 4.6 and toml 1.2.
When to Use This Skill
| Use this skill when... | Use instead when... |
|---|---|
| The binary must work from any directory after install | Building and publishing release archives, installers or a formula: rust-plugin:cargo-dist |
| Moving default config out of the repo and into the binary | Shell completions for the installed binary: configure-plugin:configure-completions |
| Adding a user config file or a cache directory | Everyday Rust language and cargo work: rust-plugin:rust-development |
A positional input and subcommands must share one clap parser |
Starting a new crate from a template: rust-plugin:cargo-generate |
Take project facts from the project, or ask
Nothing here assumes an application name, config file name or variable prefix.
Read them from the project, and ask with AskUserQuestion for what the files do
not settle:
| Fact | Where to look first |
|---|---|
| Binary and app name | Cargo.toml (bin, [package] name) |
| Default config file | The repo's configs/ or equivalent, and the code that opens it |
Override variable names (<APP>_CONFIG_DIR, <APP>_CACHE_DIR) |
Existing env::var calls, the README |
| Which tables replace whole entries | Config tables keyed by tool or plugin name |
| Supported OSes | CI matrix, release targets |
1. Embed the defaults, layer the rest
Compile the default config into the binary with include_str!, so the binary
needs no file beside it. Build the effective config from layers, lowest first:
- built-in defaults (embedded)
- the user's
config.tomlin the config directory (section 3) - config files beside the input
- the input file's own config
- command-line overrides
Merge each layer into the result as a toml::Table, recursing into nested
tables. Tables keyed by tool or plugin name are the exception: a higher layer's
entry replaces the lower entry whole. A user who redefines [tools.<name>]
means "use this definition", and a field-by-field merge keeps defaults they
never wrote, such as extra args.
include_str! paths are relative to the source file. A path that leaves the
package directory works for cargo install --git and release builds, but
cargo package leaves the file out of the tarball and its verify build fails
with couldn't read, so the crate cannot be published. Either keep the path
inside the package, or keep a copy there and add a test that the copy equals the
repo file, so the two cannot drift.
2. Keep the library's loader hermetic
The library's load() takes the user layer as a parameter and never reads
$HOME or the process environment. Only main (or the CLI module) resolves the
config directory, reads config.toml and passes it in. Tests, recipes and CI
then get the same result on every machine, whatever the developer has in their
own config.
3. User directories without a dependency
Write the lookup as pure functions that take an injected environment lookup
(&dyn Fn(&str) -> Option<OsString>) and the OS name (std::env::consts::OS).
Tests pass a closure over a map, so they never set process environment
variables, which are shared across test threads.
| Directory | Order |
|---|---|
| Config | <APP>_CONFIG_DIR, then $XDG_CONFIG_HOME/<app>, then $HOME/.config/<app> |
| Cache | <APP>_CACHE_DIR, then $XDG_CACHE_HOME/<app>, then $HOME/Library/Caches/<app> on macOS or $HOME/.cache/<app> elsewhere |
Ignore XDG_* values that are not absolute paths; the XDG Base Directory spec
says to treat them as unset. Config stays in ~/.config on macOS too, where
users of command-line tools look for it. This covers Linux and macOS; Windows
needs %APPDATA% and %LOCALAPPDATA%, or the directories crate.
4. clap: a positional input next to subcommands
A CLI that takes tool <video> and also tool run <config> needs an optional
positional and an optional subcommand in one parser.
args_conflicts_with_subcommands = true looks like the fit, but it also
rejects global flags placed before a subcommand: tool --tools x run c.toml
fails with ArgumentConflict, while tool run c.toml --tools x parses. Use
this shape instead:
#[command(arg_required_else_help = true)], so a b
Установить rust-installable-cli в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Bash(cargo test *)Bash(cargo package *)Bash(grep *)ReadWriteEditGrepGlobAskUserQuestionTodoWriteВложенные файлы
FAQ
Что делает скилл rust-installable-cli?
Installable Rust CLI: embedded default config, config layers, user dirs, clap input beside subcommands. Use when making a binary run outside its repo.
Как установить скилл rust-installable-cli?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл rust-installable-cli запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic