# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Project Overview
Envoke is a CLI tool that resolves environment variables from a declarative YAML configuration file (`envoke.yaml`). It supports multiple value sources (literal, command execution, shell scripts, Jinja2 templates with variable interpolation), topologically sorts variables to resolve dependencies, and outputs shell-safe `VAR='value'` lines.
## Build & Development Commands
This project uses `mise` as a task runner. Install mise first, then tools via `mise install`.
| Build (release) | `mise run build` |
| Run tests | `mise run test` |
| Format code | `mise run fmt` |
| Format check | `mise run fmt:check` |
| Lint | `mise run clippy` |
| All CI checks | `mise run ci` |
| Install locally | `mise run install` |
Run a single test: `cargo nextest run -E 'test(test_name)'`
Formatting uses nightly features (`rustfmt.toml` has `style_edition = "2024"`). Use `mise run fmt:nightly` / `mise run fmt:check:nightly` when stable rustfmt doesn't support the options.
## Architecture
The codebase is a single Rust binary with three modules:
- **`main.rs`** -- CLI (clap), reads YAML config, orchestrates resolution, formats shell-escaped output. Supports `--output` file writing (with `@generated` header), `--prepend-export`, and `--schema` (JSON Schema output).
- **`config.rs`** -- Data model: `Config` (top-level), `Variable` (per-env sources + optional default/description), `Source` (one-of: literal/cmd/sh/template/skip), `SourceKind` (validated variant). Derives `JsonSchema` via `schemars`.
- **`resolve.rs`** -- Core logic (~700 lines). `resolve_all()` picks per-environment sources (with default fallback), topologically sorts via Kahn's algorithm, resolves values in dependency order. Template rendering uses `minijinja` (supports `urlencode` filter). Contains the test suite (~25 tests).
- **`error.rs`** -- `ResolveError` with structured `ResolveErrorKind` variants (7 types including cycle detection with chain).
## Code Style
- Clippy pedantic lints are enabled as warnings (`[lints.clippy] pedantic = "warn"`)
- Rustfmt: `imports_granularity = "Item"`, `group_imports = "StdExternalCrate"`, Unix newlines
- Rust edition 2024