Skip to content

feat: add persistent CLI config defaults#681

Open
elliotllliu wants to merge 3 commits intovercel-labs:mainfrom
elliotllliu:feat/persist-cli-config
Open

feat: add persistent CLI config defaults#681
elliotllliu wants to merge 3 commits intovercel-labs:mainfrom
elliotllliu:feat/persist-cli-config

Conversation

@elliotllliu
Copy link
Contributor

Summary

Closes #678 — adds a skills config command to persist CLI flags across invocations.

Problem

Users who frequently use flags like -y, -g, --agent, --copy, and --json have to re-enter them for every command, which is tedious and error-prone.

Solution

A simple config system stored in ~/.skills/config.json:

# Set defaults
skills config set global true         # always install globally
skills config set yes true            # skip prompts by default
skills config set agent claude-code   # default agent
skills config set json true           # default JSON output
skills config set copy true           # copy instead of symlink

# Manage config
skills config list                    # show current defaults
skills config unset global            # remove a default
skills config path                    # show config file location

Config defaults are automatically merged into add, remove, list, check, and sync commands. Explicit CLI flags always take precedence over config defaults.

Changes

  • src/config.ts: New module — loadConfig(), saveConfig(), runConfig() with validation for known keys
  • src/cli.ts: Import config, add config command, merge defaults into each command's options before execution

Design Decisions

  • Config file at ~/.skills/config.json — simple, human-readable, easy to edit manually
  • Only boolean/string-array keys supported (global, yes, copy, json, agent)
  • CLI flags always override config — no surprises
  • No new dependencies

Adds a `skills config` command to persist CLI flags like `-g`, `-y`,
`--copy`, `--json`, and `--agent` across invocations.

Config is stored in `~/.skills/config.json` and automatically merged
as defaults for add, remove, list, check, and sync commands. Explicit
CLI flags always override config defaults.

Usage:
  skills config set global true    # always install globally
  skills config set yes true       # skip prompts by default
  skills config set agent claude-code cursor
  skills config set json true      # default JSON output
  skills config unset global       # remove a default
  skills config list               # show current config
  skills config path               # show config file location

Closes vercel-labs#678
@DaVinci42
Copy link

Thanks!

Current impl stores config in ~/.skills/config.json which works, but a more idiomatic approach per platform would be:

  • macOS/Linux: Follow the XDG base directory spec use, $XDG_CONFIG_HOME/skills/config.json , falling back to ~/.config/skills/config.json. This keeps $HOME clean.

  • Windows: The conventional location is %APPDATA%\skills\config.json (i.e. C:\Users<user>\AppData\Roaming\skills\config.json ), which is where user-scoped app config lives by OS convention.

Some libraries like env-paths handles all three platforms automatically and is already popular in the node ecosystem, might be worth the one-liner dependency to get this right without reinventing it.

The skills install paths themselves are already a bit of a wild west ( ~/.skills/ , ~/.agents/ , per-agent dirs, etc.). But the CLI binary's own config is a clean slate, and it's worth getting the convention right from the start.

Follow platform conventions for config file location:
- Linux: $XDG_CONFIG_HOME/skills/config.json (fallback ~/.config/skills/)
- macOS: ~/Library/Application Support/skills/config.json
- Windows: %APPDATA%\skills\config.json

Keeps $HOME clean per XDG base directory spec on Linux.
Dependency-free using process.platform detection.

Co-authored-by: DaVinci42
@elliotllliu
Copy link
Contributor Author

Good point! Updated in 504a0e3 to use platform-idiomatic paths:

  • Linux: $XDG_CONFIG_HOME/skills/config.json (fallback ~/.config/skills/config.json)
  • macOS: ~/Library/Application Support/skills/config.json
  • Windows: %APPDATA%\skills\config.json

Kept it dependency-free using process.platform detection — no need for env-paths since the logic is straightforward for three platforms.

Thanks for the suggestion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Persist CLI Config Flags (-y, -g, --agent, --copy, --json)

2 participants