RepoPilotOpen in app →

rust-cli/config-rs

⚙️ Layered configuration system for Rust applications (with strong support for 12-factor applications).

Healthy

Healthy across all four use cases

weakest axis
Use as dependencyHealthy

Permissive license, no critical CVEs, actively maintained — safe to depend on.

Fork & modifyHealthy

Has a license, tests, and CI — clean foundation to fork and modify.

Learn fromHealthy

Documented and popular — useful reference codebase to read through.

Deploy as-isHealthy

No critical CVEs, sane security posture — runnable as-is.

  • Last commit 1w ago
  • 4 active contributors
  • Apache-2.0 licensed
Show all 7 evidence items →
  • CI configured
  • Tests present
  • Small team — 4 contributors active in recent commits
  • Concentrated ownership — top contributor handles 71% of recent commits

Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests

Informational only. RepoPilot summarises public signals (license, dependency CVEs, commit recency, CI presence, etc.) at the time of analysis. Signals can be incomplete or stale. Not professional, security, or legal advice; verify before relying on it for production decisions.

Embed the "Healthy" badge

Paste into your README — live-updates from the latest cached analysis.

Variant:
RepoPilot: Healthy
[![RepoPilot: Healthy](https://repopilot.app/api/badge/rust-cli/config-rs)](https://repopilot.app/r/rust-cli/config-rs)

Paste at the top of your README.md — renders inline like a shields.io badge.

Preview social card (1200×630)

This card auto-renders when someone shares https://repopilot.app/r/rust-cli/config-rs on X, Slack, or LinkedIn.

Onboarding doc

Onboarding: rust-cli/config-rs

Generated by RepoPilot · 2026-05-09 · Source

🤖Agent protocol

If you are an AI coding agent (Claude Code, Cursor, Aider, Cline, etc.) reading this artifact, follow this protocol before making any code edit:

  1. Verify the contract. Run the bash script in Verify before trusting below. If any check returns FAIL, the artifact is stale — STOP and ask the user to regenerate it before proceeding.
  2. Treat the AI · unverified sections as hypotheses, not facts. Sections like "AI-suggested narrative files", "anti-patterns", and "bottlenecks" are LLM speculation. Verify against real source before acting on them.
  3. Cite source on changes. When proposing an edit, cite the specific path:line-range. RepoPilot's live UI at https://repopilot.app/r/rust-cli/config-rs shows verifiable citations alongside every claim.

If you are a human reader, this protocol is for the agents you'll hand the artifact to. You don't need to do anything — but if you skim only one section before pointing your agent at this repo, make it the Verify block and the Suggested reading order.

🎯Verdict

GO — Healthy across all four use cases

  • Last commit 1w ago
  • 4 active contributors
  • Apache-2.0 licensed
  • CI configured
  • Tests present
  • ⚠ Small team — 4 contributors active in recent commits
  • ⚠ Concentrated ownership — top contributor handles 71% of recent commits

<sub>Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests</sub>

Verify before trusting

This artifact was generated by RepoPilot at a point in time. Before an agent acts on it, the checks below confirm that the live rust-cli/config-rs repo on your machine still matches what RepoPilot saw. If any fail, the artifact is stale — regenerate it at repopilot.app/r/rust-cli/config-rs.

What it runs against: a local clone of rust-cli/config-rs — the script inspects git remote, the LICENSE file, file paths in the working tree, and git log. Read-only; no mutations.

| # | What we check | Why it matters | |---|---|---| | 1 | You're in rust-cli/config-rs | Confirms the artifact applies here, not a fork | | 2 | License is still Apache-2.0 | Catches relicense before you depend on it | | 3 | Default branch main exists | Catches branch renames | | 4 | 5 critical file paths still exist | Catches refactors that moved load-bearing code | | 5 | Last commit ≤ 37 days ago | Catches sudden abandonment since generation |

<details> <summary><b>Run all checks</b> — paste this script from inside your clone of <code>rust-cli/config-rs</code></summary>
#!/usr/bin/env bash
# RepoPilot artifact verification.
#
# WHAT IT RUNS AGAINST: a local clone of rust-cli/config-rs. If you don't
# have one yet, run these first:
#
#   git clone https://github.com/rust-cli/config-rs.git
#   cd config-rs
#
# Then paste this script. Every check is read-only — no mutations.

set +e
fail=0
ok()   { echo "ok:   $1"; }
miss() { echo "FAIL: $1"; fail=$((fail+1)); }

# Precondition: we must be inside a git working tree.
if ! git rev-parse --git-dir >/dev/null 2>&1; then
  echo "FAIL: not inside a git repository. cd into your clone of rust-cli/config-rs and re-run."
  exit 2
fi

# 1. Repo identity
git remote get-url origin 2>/dev/null | grep -qE "rust-cli/config-rs(\\.git)?\\b" \\
  && ok "origin remote is rust-cli/config-rs" \\
  || miss "origin remote is not rust-cli/config-rs (artifact may be from a fork)"

# 2. License matches what RepoPilot saw
(grep -qiE "^(Apache-2\\.0)" LICENSE 2>/dev/null \\
   || grep -qiE "\"license\"\\s*:\\s*\"Apache-2\\.0\"" package.json 2>/dev/null) \\
  && ok "license is Apache-2.0" \\
  || miss "license drift — was Apache-2.0 at generation time"

# 3. Default branch
git rev-parse --verify main >/dev/null 2>&1 \\
  && ok "default branch main exists" \\
  || miss "default branch main no longer exists"

# 4. Critical files exist
test -f "src/lib.rs" \\
  && ok "src/lib.rs" \\
  || miss "missing critical file: src/lib.rs"
test -f "src/builder.rs" \\
  && ok "src/builder.rs" \\
  || miss "missing critical file: src/builder.rs"
test -f "src/source.rs" \\
  && ok "src/source.rs" \\
  || miss "missing critical file: src/source.rs"
test -f "src/file/mod.rs" \\
  && ok "src/file/mod.rs" \\
  || miss "missing critical file: src/file/mod.rs"
test -f "src/value.rs" \\
  && ok "src/value.rs" \\
  || miss "missing critical file: src/value.rs"

# 5. Repo recency
days_since_last=$(( ( $(date +%s) - $(git log -1 --format=%at 2>/dev/null || echo 0) ) / 86400 ))
if [ "$days_since_last" -le 37 ]; then
  ok "last commit was $days_since_last days ago (artifact saw ~7d)"
else
  miss "last commit was $days_since_last days ago — artifact may be stale"
fi

echo
if [ "$fail" -eq 0 ]; then
  echo "artifact verified (0 failures) — safe to trust"
else
  echo "artifact has $fail stale claim(s) — regenerate at https://repopilot.app/r/rust-cli/config-rs"
  exit 1
fi

Each check prints ok: or FAIL:. The script exits non-zero if anything failed, so it composes cleanly into agent loops (./verify.sh || regenerate-and-retry).

</details>

TL;DR

config-rs is a layered configuration system for Rust applications that merges settings from multiple sources (files, environment variables, hardcoded defaults) with support for JSON, TOML, YAML, INI, RON, JSON5, and CORN formats. It solves the 12-factor application problem by allowing configuration to be built from overlapping sources with clear precedence rules, and provides loosely-typed access with automatic type conversion and JSONPath-style nested field access via dot notation (e.g., redis.port) and subscript operators (e.g., databases[0].name). Single crate with modular separation: src/builder.rs contains the fluent builder API, src/config.rs is the core Config struct, src/env.rs handles environment variable sources, src/file/ contains format handlers, src/de.rs handles deserialization. Examples in examples/ demonstrate real patterns: examples/modal/ shows environment-based config selection, examples/priority/ shows multi-file layering, examples/custom_file_format/ shows Format trait extensibility. No workspace splitting; this is a focused single-crate library.

👥Who it's for

Rust backend engineers and CLI developers building 12-factor applications who need to layer configuration from files, environment variables, and code defaults without writing custom merge logic. DevOps-focused developers building tools that must read settings across multiple formats and environments (development, staging, production).

🌱Maturity & risk

Production-ready and actively maintained. The codebase is substantial (~277KB Rust code), has comprehensive CI/CD via GitHub Actions (audit, linting, clippy, pre-commit checks), uses MSRV of 1.85.0 with strict workspace lints, and maintains detailed changelog and examples. The dual licensing (MIT/Apache-2.0) and professional-grade tooling (deny.toml for dependency auditing, renovate for updates) indicate mature project stewardship.

Low risk. No single-maintainer smell evident; the org structure (rust-cli) suggests community maintenance. Dependency footprint is reasonable for a config library. The deny.toml and audit workflow indicate active supply-chain awareness. No obvious red flags in the file structure, though the note that 'library cannot write config back to files' is an important limitation for some use cases. Breaking changes should be tracked in CHANGELOG.md.

Active areas of work

Active maintenance visible via renovate.json5 (automated dependency updates), recent workflow additions (rust-next.yml for MSRV testing), and comprehensive pre-commit/spelling checks. The edition set to 2024 and MSRV pinning at 1.85.0 show commitment to staying current. No specific breaking PRs evident from the file list, suggesting stable API with gradual improvements.

🚀Get running

git clone https://github.com/rust-cli/config-rs.git
cd config-rs
cargo build
cargo test
cargo run --example simple

Daily commands: This is a library, not a server. To test it: cargo test. To run examples: cargo run --example simple or cargo run --example modal. To see all examples: ls examples/ and run cargo run --example <name>.

🗺️Map of the codebase

  • src/lib.rs — Library entry point and primary public API; defines the Config struct and top-level builder interface that all users interact with.
  • src/builder.rs — Implements the fluent ConfigBuilder API for layering and merging configuration sources; essential to understand the configuration assembly pattern.
  • src/source.rs — Core trait definition for configuration sources; required reading to implement custom sources or understand the plugin architecture.
  • src/file/mod.rs — File source abstraction and integration layer; bridges file formats with the configuration system and handles path resolution.
  • src/value.rs — Configuration value representation and type coercion; underpins the 'loosely typed' feature and all value access patterns.
  • src/env.rs — Environment variable source implementation; critical for 12-factor compliance and the primary mechanism for runtime overrides.
  • src/de.rs — Serde deserialization layer that bridges raw configuration values to strongly-typed Rust structs; essential for extracting typed config.

🛠️How to make changes

Add support for a new file format

  1. Create a new format module in src/file/format/ (e.g., src/file/format/yaml.rs) implementing the Format trait with decode() and encode() methods (src/file/format/yaml.rs)
  2. Register the new format in the FileFormat enum and match statement in src/file/format/mod.rs (src/file/format/mod.rs)
  3. Add format detection logic in src/format.rs by extending the file extension matching (src/format.rs)
  4. Create integration tests in tests/testsuite/file_<format>.rs following the pattern of file_json.rs (tests/testsuite/file_yaml.rs)

Implement a custom configuration source

  1. Create a new struct implementing the Source trait from src/source.rs with clone(), collect(), and uri() methods (src/source.rs)
  2. Add a builder method in src/builder.rs to accept your custom source in the ConfigBuilder fluent chain (src/builder.rs)
  3. Return a Map from your source's collect() method, typically built using src/map.rs utilities for nested structures (src/map.rs)
  4. Add examples in examples/async_source.rs style showing how users integrate your source (examples/async_source.rs)

Add type coercion for a new Rust type in loosely-typed access

  1. Extend the Value enum in src/value.rs if needed to represent the new type category (src/value.rs)
  2. Implement conversion logic in src/de.rs by extending the custom deserializer visitor pattern (src/de.rs)
  3. Add test cases in tests/testsuite/get.rs or create a new test file testing your type's conversion paths (tests/testsuite/get.rs)

🔧Why these technologies

  • Serde — Standard Rust serialization framework enabling zero-cost deserialization to strongly-typed structs and custom coercion logic.
  • Trait-based plugins (Source, Format) — Decouples configuration sources and file formats, allowing users to implement custom providers without forking the library.
  • Loosely-typed Value enum — Bridges the gap between heterogeneous config sources and strongly-typed application code; enables seamless type coercion.
  • JSONPath-like path access (redis.port, databases[0]) — Provides intuitive nested navigation without requiring intermediate struct definitions; critical for exploratory configuration access.
  • Async/await support (tokio, async-trait) — Enables non-blocking source collection (e.g., HTTP endpoints) while maintaining synchronous public API via bridge pattern.

⚖️Trade-offs already made

  • Loosely-typed values requiring runtime coercion vs. compile-time strongly-typed configuration

    • Why: Flexibility to access heterogeneous config sources without upfront struct definition; enables exploratory access patterns.
    • Consequence: Runtime type errors are possible; requires careful error handling in user code. Trade-off favors runtime flexibility over compile-time safety.
  • In-memory Map representation with merge semantics vs. lazy-evaluated layered access

    • Why: Simplifies the mental model and reduces repeated lookups; integrates naturally with serde deserialization.
    • Consequence: All sources are eagerly collected at build time. Unseen layers use more memory; watch/reload requires full rebuild.
  • File format auto-detection via extension vs. explicit format specification

    • Why: Reduces boilerplate for common cases; aligns with 12-factor convention of single config file per environment.
    • Consequence: Ambiguous or unusual file naming can cause parsing errors. Explicit format parameter available for edge cases.
  • Immutable Config post-build vs. mutable configuration at runtime

    • Why: Simplifies thread-safety guarantees and reasoning about configuration state across async tasks.
    • Consequence: Configuration changes require full rebuild via new ConfigBuilder. Watch-mode reloads entire config atomically.

🚫Non-goals (don't propose these)

  • Does not support writing configuration back to disk; library is read-only by design (as noted in README).
  • Does not handle secrets management or encryption; assumes secrets are injected via environment or external vaults.
  • Does not provide schema validation or JSON Schema support; relies on serde struct validation.
  • Does not guarantee configuration atomicity across multiple files; merge order is deterministic but not transactional.
  • Does not support real-time configuration hot-reload at millisecond granularity; file watching is polling-based.

🪤Traps & gotchas

No required environment variables or external services. One non-obvious behavior: the library reads AND MERGES files based on order added via builder, with later sources overwriting earlier ones — easy to get precedence wrong if you're thinking 'first value wins' instead of 'last value wins'. The JSONPath subscript operator (e.g., [0]) only works on arrays in the deserialized structure, not string keys. Feature flags are additive but not mutually exclusive — you can enable multiple formats in one build. Loose typing can hide errors; a config value that's a string in TOML but expected as i32 will convert silently if possible, which is powerful but can mask config mistakes.

🏗️Architecture

💡Concepts to learn

  • 12-Factor App Configuration — The entire design of config-rs (environment-driven, layered sources, no hardcoded secrets) is built around 12-factor principles; understanding this methodology is key to using the library effectively
  • Layered/Hierarchical Configuration — config-rs's core strength is merging multiple config sources with clear precedence (defaults → file → env → explicit); this pattern is non-obvious and needs mental clarity to avoid bugs
  • Loose Typing / Dynamic Type Conversion — The library allows reading the same config value as i32, String, or bool without explicit casting, which is powerful but requires understanding serde's type coercion rules and potential silent failures
  • JSONPath (Subset Implementation) — config-rs implements a subset of JSONPath for nested field access (dot notation and subscript operators); understanding this syntax is essential for accessing nested configs
  • Format Trait (Extensibility Pattern) — The Format trait is the extension point for custom serialization formats; implementing it requires understanding Rust trait objects and serde's deserialization pipeline
  • Builder Pattern — config-rs uses the builder pattern throughout ConfigBuilder to allow fluent, readable API chains (e.g., builder.add_source(...).add_source(...)...build()); this is idiomatic Rust config library design
  • Feature Flags / Conditional Compilation — config-rs uses Cargo features (json, toml, yaml, etc.) to conditionally include format handlers, reducing binary size; understanding feature combinations is important for library maintenance
  • mehcode/config-rs — This is the original predecessor repo from which rust-cli/config-rs was forked; understanding commit history there clarifies design decisions
  • serde-rs/serde — Core dependency that provides the deserialization framework; understanding serde's derive macros is essential for extending config-rs
  • toml-rs/toml — One of the primary optional format backends; needed if you're debugging TOML-specific config issues
  • clap-rs/clap — Companion library that often loads CLI args that overlay on top of config-rs settings in real applications
  • rust-cli/confy — Higher-level wrapper around config-rs that adds automatic serialization of typed Rust structs back to disk, solving the read-only limitation of config-rs

🪄PR ideas

To work on one of these in Claude Code or Cursor, paste: Implement the "<title>" PR idea from CLAUDE.md, working through the checklist as the task list.

Add comprehensive tests for path parser and JSONPath queries

The repo supports JSONPath-like queries (e.g., redis.port, databases[0].name) via src/path/parser.rs, but there are no visible test files for path parsing logic. This is a critical feature that deserves thorough unit test coverage to prevent regressions when parsing complex nested paths and subscript operators.

  • [ ] Create src/path/parser.rs tests covering: simple child access (e.g., 'redis.port')
  • [ ] Add tests for array subscript syntax (e.g., 'databases[0].name', 'servers[10]')
  • [ ] Add tests for nested subscripts (e.g., 'db[0].servers[1].host')
  • [ ] Add tests for edge cases: invalid syntax, out-of-bounds indices, malformed paths
  • [ ] Add integration tests in src/path/mod.rs tests module
  • [ ] Run tests and ensure clippy compliance per workspace lints

Add type conversion tests for loosely-typed configuration values

The repo advertises 'Loosely typed — Configuration values may be read in any supported type' but src/de.rs (deserialization logic) lacks dedicated test coverage. This is a core feature that needs tests verifying conversions between different types (string→int, int→bool, etc.) to document behavior and prevent breaking changes.

  • [ ] Create tests in src/de.rs covering: string-to-integer conversions, string-to-boolean parsing
  • [ ] Add tests for: float conversions, type coercion from different sources (env, files)
  • [ ] Add negative tests: invalid conversions that should fail with clear errors
  • [ ] Test conversions across all supported formats (JSON, TOML, YAML, INI, RON, JSON5, CORN)
  • [ ] Document expected coercion rules in tests via comments or docstrings
  • [ ] Verify error messages are informative when conversions fail

Add integration tests for environment variable source (src/env.rs) with realistic scenarios

The src/env.rs file handles environment variable parsing (critical for 12-factor app support), but existing examples/static_env.rs and examples/async_source.rs only show basic usage. Missing are integration tests covering: prefix handling, nested key flattening, collision resolution, and interaction with other sources in builder layering.

  • [ ] Create src/env.rs integration tests covering: reading simple env vars into config
  • [ ] Add tests for: prefixed env vars (e.g., APP_DATABASE_HOST), nested key flattening
  • [ ] Add tests for: env var override behavior when layered with file sources (per examples/modal)
  • [ ] Add tests for: case sensitivity, special characters in env var names
  • [ ] Test edge cases: missing env vars, empty values, conflicting keys across sources
  • [ ] Verify layering priority matches documented behavior in README (env overrides files)

🌿Good first issues

  • Add integration tests for each format (json, toml, yaml, ini, ron, json5, corn) that verify round-trip consistency in src/file/ — currently no dedicated format-specific test files in the repo structure
  • Expand the JSONPath subscript operator to support string keys (e.g., config['key-with-dash']) to handle TOML/YAML keys that don't work with dot notation — this would require changes to parsing logic in src/config.rs
  • Add a guide in CONTRIBUTING.md with concrete examples of how to implement the Format trait and add a feature gate, since only the examples/custom_file_format/ demo exists and docs are sparse

Top contributors

Click to expand
  • @epage — 71 commits
  • @renovate[bot] — 27 commits
  • @Copilot — 1 commits
  • [@Andy Khramtsov](https://github.com/Andy Khramtsov) — 1 commits

📝Recent commits

Click to expand
  • e7e72cc — chore(deps): Update pre-commit hook crate-ci/typos to v1.46.0 (#753) (epage)
  • 16a85fa — chore(deps): Update compatible (dev) (#752) (renovate[bot])
  • 53c9e30 — chore(deps): Update pre-commit hook crate-ci/typos to v1.46.0 (renovate[bot])
  • 7f4482c — chore(deps): Update Rust Stable to v1.95 (#750) (renovate[bot])
  • 33f0b36 — chore(deps): Update Rust crate yaml-rust2 to 0.11.0 (#749) (epage)
  • 8a96590 — chore(deps): Update Rust crate snapbox to v1.2.0 (#748) (renovate[bot])
  • 04b7699 — chore(deps): Update Rust crate yaml-rust2 to 0.11.0 (renovate[bot])
  • 7293108 — chore: Release config version 0.15.22 (epage)
  • 6b82b25 — docs: Update changelog (epage)
  • 2ae46e4 — chore: Update to Winnow 1.0.0 (#745) (epage)

🔒Security observations

The config-rs repository demonstrates generally good security practices with enabled linting, dependency auditing workflows, and a clear MSRV policy. However, there are notable concerns: (1) Cryptographic key files stored as examples establish poor patterns for library users, (2) Several important clippy security-adjacent lints are disabled, and (3) Safety linting could be stricter. The multi-format parsing capability introduces inherent complexity and attack surface. No evidence of hardcoded secrets, SQL injection risks, or XSS vulnerabilities was found. The codebase follows modern Rust safety practices but would benefit from stricter lint enforcement and removal of example key files.

  • Medium · Cryptographic Key Files in Repository — examples/custom_file_format/files/private.pem, examples/custom_file_format/files/public.pem. Private and public key files (private.pem and public.pem) are included in the examples directory. While these are example files, storing any cryptographic keys in version control is a security anti-pattern that could establish bad practices for users of this library. Fix: Remove key files from the repository and add *.pem to .gitignore. Generate fresh keys at runtime in examples or use placeholder comments instead. Document how users should generate their own keys.
  • Low · Overly Permissive Lint Configuration — .cargo/config.toml, Cargo.toml (workspace.lints.clippy). The workspace lints configuration uses several 'allow' directives that override important clippy warnings (e.g., 'collapsible_else_if', 'if_same_then_else', 'needless_continue', 'result_large_err'). While not a direct vulnerability, this reduces code quality oversight and could allow problematic patterns to slip through. Fix: Review and justify each 'allow' directive. Consider enabling 'collapsible_else_if' and 'result_large_err' as these can hide logic errors. Document reasoning for any intentional relaxations.
  • Low · Unsafe Operations Not Fully Enforced — Cargo.toml (workspace.lints.rust - unsafe_op_in_unsafe_fn). The workspace lint for 'unsafe_op_in_unsafe_fn' is set to 'warn' rather than 'deny'. This is a safety lint that should be strictly enforced in a configuration library to prevent unsafe code blocks from circumventing safety guarantees. Fix: Change 'unsafe_op_in_unsafe_fn' from 'warn' to 'deny' to enforce strict safety standards, or if warnings are acceptable, document why this leniency is intentional.
  • Low · Missing Security Audit Workflow Configuration — deny.toml, .github/workflows/audit.yml. While the repository includes a security audit workflow (.github/workflows/audit.yml), the deny.toml file configuration is not visible in the provided analysis. Ensure that security advisories are properly configured to catch vulnerable dependencies. Fix: Verify deny.toml is properly configured to check for vulnerable dependencies and unmaintained crates. Run 'cargo deny check' regularly and in CI/CD pipelines.
  • Low · Multiple Configuration File Format Support — src/file/format/ (all format parsers). The library supports parsing multiple configuration formats (JSON, YAML, TOML, INI, RON, JSON5, CORN). While this provides flexibility, each parser is a potential attack surface for injection vulnerabilities if user-supplied configuration content is processed without proper validation. Fix: Ensure all format parsers are up-to-date and from trusted sources. Implement strict validation of configuration values. Consider documenting configuration format security best practices for users loading untrusted config files.

LLM-derived; treat as a starting point, not a security audit.


Generated by RepoPilot. Verdict based on maintenance signals — see the live page for receipts. Re-run on a new commit to refresh.

Healthy signals · rust-cli/config-rs — RepoPilot