phantom-secrets
CLAUDE.md20 starsChanged 8 days agoMITView on GitHub
If cargo is not on your PATH (a fresh rustup install puts it in ~/.cargo/bin), run export PATH="$HOME/.cargo/bin:$PATH" first. Most changes here come from coding agents. Read AGENTS.md for the operating rules, then follow Contribute with an agent from fork to merged pull request. In short: - While iterating, scripts/fast-check.sh main runs format, Clippy, and tests for only the crates your branch touches plus their dependents. It narrows only when every changed file is Rust source under a crate's src/;…
- Reads credentials
In this repository6 other files it gives its agents.
- AGENTS.mdAGENTS.md
- docs/agents.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- docs/llms-full.txtllms.txt
- docs/llms.txtllms.txt
- llms.txtllms.txt
The file
We split this CLAUDE.md into the rules it gives an agent
7 rules. About 0 are common, 3 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 23
If cargo is not on your PATH (a fresh rustup install puts it in ~/.cargo/bin), run export PATH="$HOME/.cargo/bin:$PATH" first.
- Distinctive: line 36
Before opening the pull request, run the full test, format check, and Clippy gate above.
- Distinctive: line 41
After editing docs, run the drift checks:
- Distinctive: line 58
Before you push, run the two pre-push checks.
- Very specific: line 69
Add a fragment to changelog.d/ instead of editing CHANGELOG.md, and follow the hot-file rule: a new doc does not also edit docs/README.md.
- Very specific: line 109
All code must pass cargo clippy --workspace --all-targets --locked -- -D warnings and cargo fmt --all -- --check
- Very specific: line 115
Read dotenv files through phantom_core::managed_dotenv::parse_regular_dotenv, which opens without following a final symlink and checks the …
≈ “Common” is an estimate: at least 1 in 5 of the 28,633 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Phantom: Development Guide
Quick Reference
# Build
~/.cargo/bin/cargo build
# Test
~/.cargo/bin/cargo test --workspace --all-targets --locked --no-fail-fast
# Lint (must pass with zero warnings)
~/.cargo/bin/cargo clippy --workspace --all-targets --locked -- -D warnings
# Format in place, then check it the way CI does
~/.cargo/bin/cargo fmt --all
~/.cargo/bin/cargo fmt --all -- --check
# Run CLI
~/.cargo/bin/cargo run -p phantom-secrets --bin phantom -- <command>If cargo is not on your PATH (a fresh rustup install puts it in ~/.cargo/bin), run export PATH="$HOME/.cargo/bin:$PATH" first.
Contributing as an agent
Most changes here come from coding agents. Read AGENTS.md for the operating rules, then follow Contribute with an agent from fork to merged pull request. In short:
- While iterating,
scripts/fast-check.sh mainruns format, Clippy, and tests for only the crates your branch touches plus their dependents. It narrows only when every changed file is Rust source under a crate'ssrc/; a doc, script, manifest, ortests/change checks the whole workspace. - Before opening the pull request, run the full test, format check, and Clippy gate above. Pull request CI does not run the Rust test suite or the docs drift checks, so your local run is the evidence reviewers see; record the exact commands in the pull request template.
After editing docs, run the drift checks:
node --test scripts/release/readme-mcp-catalog.test.mjs node --test scripts/docs-distribution.test.mjs node --test scripts/hot-file-rule.test.mjs ~/.cargo/bin/cargo test --locked -p phantom-secrets --test docs_command_flags_testAlso run every suite that reads the file you edited, including those in
apps/web/tests/: list them withgit grep -l -F <file-name> -- '*.test.*'and run each withnode --test <file>. A web suite that loads a package needs(cd apps/web && npm ci --no-audit)first. That search misses two checks not named*.test.*: after editingdocs/agents.md, runbash scripts/test-docs-agents.sh; after editing a file with a<!-- fresh:beginmarker, runnode scripts/freshness/check.mjs.Before you push, run the two pre-push checks. Neither needs a build, and pull request CI does not validate fragments:
node scripts/changelog-fold.mjs --check # changelog.d/ fragment format git diff main...HEAD | perl .github/tests/secret-shape/scrub.pl --check --allow-fixturesThe second is the local form of the
Secret-shape scanthatCI Gaterequires; diff againstupstream/mainif your localmainis stale.- Add a fragment to
changelog.d/instead of editingCHANGELOG.md, and follow the hot-file rule: a new doc does not also editdocs/README.md. CI Gateis the only required check; a passing pull request merges through the merge queue, which reruns it on the queued merge commit.
Architecture
Modular Rust workspace with a shipped secret-protection product and separate fail-closed governed-execution foundations:
- phantom-core: Config (.phantom.toml), .env parsing/rewriting, phantom token generation (256-bit CSPRNG,
phm_prefix), error types - phantom-vault:
VaultBackendtrait with OS keychain (macOS Keychain, Linux Secret Service, Windows Credential Manager) and encrypted file fallback. Argon2id parameters hardened to OWASP balanced (m=64 MiB, t=3, p=1) with legacy-default fallback for older vaults - phantom-proxy: HTTP reverse proxy on 127.0.0.1. It authenticates and matches exact routes, discards client control of the route auth header, injects only the route-owned vault value there, and forwards client bodies byte-for-byte under a hard size cap. Client headers/bodies never resolve
phm_tokens. Useshyperfor server andreqwestfor outbound HTTPS; response streaming/SSE is preserved through scrubbing. - phantom-cli:
clap-based CLI for init, proxy execution, diagnostics, sync, teams, audit, validation, provider design foundations, and trusted-terminal workspace setup. Live provider issuance/rotation is hard-denied before credential/network access in current releases. Usephantom --helpas the canonical command inventory. Plaintext JSON export is disabled; reveal requires an attached terminal and exact typed confirmation. - phantom-mcp: MCP server for Claude Code, Cursor, Windsurf, Codex, and Gemini CLI. Uses
rmcp3.9 SDK and stdio transport. Exposes core vault/diagnostic/cloud/team tools plus advanced audit, validation, rotation, expiry, leak-incident, and compliance workflows. The exact catalog is declared incrates/phantom-mcp/src/server.rs;mcp-registry/server.jsonmust match the runtimetools/listexactly (CI runsnode scripts/release/mcp-stdio-smoke.mjs target/debug/phantom-mcp 54; after a reviewed schema change, regenerate withnode scripts/release/mcp-stdio-smoke.mjs target/debug/phantom-mcp 54 mcp-registry/server.json --write-registry). User-fixable states (not initialized, locked vault, wrong passphrase, bad config) return-32600with a next step (tools/helpers.rs::state_err);-32603is for server faults. - governed-execution foundations:
phantom-workspaceprovides the active value-blind Unix setup transaction.phantom-authority,phantom-locus-contract,phantom-broker,phantom-runtime,phantom-session, andphantom-evidenceremain fail closed for production execution.
For value-blind diagnostics, use phantom_status and phantom_why;
phantom_list_secrets reports names and locked-vault state without exposing values.
How the proxy works
The proxy is a reverse proxy with URL rewriting, NOT a forward/CONNECT proxy. This avoids MITM/CA certificate issues:
phantom execsetsOPENAI_BASE_URL=http://127.0.0.1:PORT/openai(and similar for other services)- API client code sends HTTP to localhost proxy instead of real HTTPS endpoint
- Proxy authenticates and matches an exact route, then injects the route-owned vault value only into its fixed auth header; client headers/bodies remain unresolved
- Proxy forwards modified request over TLS to real endpoint (e.g.,
api.openai.com)
Secret detection
dotenv.rs::looks_like_secret() uses heuristics to distinguish secrets from config:
- Key patterns:
*_KEY,*_SECRET*,*_TOKEN,*_PASSWORD,DATABASE_URL, etc. - Value patterns:
sk-*,ghp_*, connection strings with@, high-entropy long strings - Non-secrets left untouched:
NODE_ENV,PORT,DEBUG, etc.
Conventions
- All code must pass
cargo clippy --workspace --all-targets --locked -- -D warningsandcargo fmt --all -- --check - Unit tests go in
#[cfg(test)] mod testswithin source files; CLI integration tests live incrates/phantom-cli/tests/ - Integration tests for proxy use
test_server.rs(mock HTTP server that records requests) - Error handling:
thiserrorfor library crates,anyhowfor CLI - CLI output uses
coloredcrate; prefix lines with->,ok,!,warn, etc. - Secrets must be
zeroized from memory after use - Read dotenv files through
phantom_core::managed_dotenv::parse_regular_dotenv, which opens without following a final symlink and checks the opened handle;DotenvFile::parse_filefollows a symlink, so non-test code does not use it - An answer built from the vault inventory must not read an empty OS keychain as "no secrets" when a locked encrypted-file vault exists: use
util::inventory_guard/util::require_complete_inventoryin the CLI andrequire_readable_inventoryin MCP; CLI refusals start withutil::VAULT_LOCKED("Vault locked: ...") - Proxy binds to 127.0.0.1 ONLY; never expose to network
- Audit log is opt-in:
PHANTOM_AUDIT=1writes JSONL events for vault store/retrieve/delete to~/.phantom/audit.log. Schema records the secret name only; never the value. Each entry carries an HMAC-SHA256 over the previous entry's hash (chain rooted at a zero-hash). New audit hook points should callphantom_core::audit::log(op, name). Usephantom audit verifyto check chain integrity. - Importers live in
phantom-core/src/importers/. Each format (doppler, infisical, dotenvx, 1password, env) implements a parser that returns aSecretMap(BTreeMap<String, Zeroizing<String>>). The CLI dispatcher isphantom_core::importers::import_from(source, path).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

