cli-configuration

Manage CLI application configuration with layered precedence and XDG directories.

8|2|Updated Oct 17, 2025
One-click install
npx skills add https://github.com/geoffjay/claude-plugins --skill cli-configuration
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cli-configuration
Source: https://github.com/geoffjay/claude-plugins/tree/main/plugins/rust-cli-developer/skills/cli-configuration
Command: npx skills add https://github.com/geoffjay/claude-plugins --skill cli-configuration

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Patterns for managing configuration in command-line applications.

Core Features & Use Cases

  • Configuration Precedence: 7-layer precedence including defaults, system, user, project, env, and CLI overrides.
  • Config File Formats: TOML, YAML, JSON examples and code.
  • XDG Base Directory Support: Standard directories for config, data, cache, and state.

Quick Start

Use the cli-configuration skill to load a configuration with environment-first overrides and a CLI-specified config file.

Frequently Asked Questions about cli-configuration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I manage configuration precedence in CLI applications?

Configuration precedence establishes a layered hierarchy from lowest to highest priority: defaults, system config, user config, project config, environment variables, and CLI arguments. This ensures CLI overrides always win, environment variables override files, and project settings take precedence over system-wide defaults.

What's the best way to load TOML, YAML, and JSON config files in a CLI?

Parse multi-format configuration files by detecting format from file extension, then deserializing into a unified structure. Support TOML for simplicity, YAML for readability, and JSON for strict validation, merging all sources into a single resolved configuration object.

How do I use XDG directories for cross-platform CLI configuration?

XDG Base Directory Specification defines standard paths for config ($XDG_CONFIG_HOME), data ($XDG_DATA_HOME), cache ($XDG_CACHE_HOME), and state ($XDG_STATE_HOME). Use these platform-agnostic directories to store and retrieve CLI configuration files consistently across Linux, macOS, and other Unix-like systems.

Can environment variables override CLI configuration files?

Yes. Environment variables occupy a higher precedence layer than config files but lower than explicit CLI arguments. This allows deployment-time overrides without modifying files, while preserving CLI flags as the ultimate override for one-off runs.

What happens when configuration sources conflict?

The deterministic precedence pipeline resolves conflicts by applying sources in strict order: later layers completely override earlier ones for matching keys. No merging occurs across precedence levels; the highest-priority source wins for each configuration key.

Do I need separate config handling for different CLI tools?

No. A unified configuration management pattern handles all CLI applications consistently: define defaults in code, layer user and project configs via standard directories, inject environment variables, and accept CLI arguments—all following the same precedence rules.