4.2 KiB
4.2 KiB
| name | description | argument-hint | allowed-tools | model |
|---|---|---|---|---|
| config-audit:discover | Phase 1 - Initialize session, auto-detect scope, and discover config files | [current|repo|home|full] [--delta] | Read, Write, Edit, Glob, Grep, Agent, AskUserQuestion, Bash | opus |
Config-Audit: Discover (Phase 1)
Initialize a new audit session and discover all Claude Code configuration files.
Usage
/config-audit discover # Auto-detect scope
/config-audit discover current # Force current directory scope
/config-audit discover repo # Force git repository scope
/config-audit discover home # Force home/global scope
/config-audit discover full # Force full machine scope
/config-audit discover --delta # Incremental re-scan (changed files only)
Implementation
Step 1: Initialize session and greet
Generate session ID (YYYYMMDD_HHmmss), create directories:
mkdir -p ~/.claude/config-audit/sessions/{session-id}/findings 2>/dev/null
Step 2: Determine scope
If the user provided a scope argument, use it. Otherwise, auto-detect:
- Run
git rev-parse --show-toplevel 2>/dev/null - If inside a git repo → repo scope
- If pwd is
$HOME→ home scope - Otherwise → current directory scope
Tell the user:
## Configuration Discovery
**Scope:** {Repository|Home|Current directory|Full machine} — `{path}`
Finding all Claude Code configuration files (CLAUDE.md, settings, hooks, rules, MCP servers)...
Step 3: Resolve paths
| Scope | What gets scanned |
|---|---|
current |
Current directory + parent CLAUDE.md files up to root + ~/.claude/ |
repo |
Git repo root + ~/.claude/ |
home |
~/.claude/ only |
full |
~/.claude/ (depth 10), managed paths, all dev dirs under $HOME |
Step 4: Delta mode (if --delta)
If --delta flag:
- Find previous baseline from
~/.claude/config-audit/sessions/*/discovery.json - If no previous: "No previous scan found. Running full discovery instead."
- Compare file mtimes/sizes to classify as changed/new/deleted/unchanged
- Only scan changed + new files
Step 5: Run discovery
Run the scan orchestrator silently to discover and scan files:
node ${CLAUDE_PLUGIN_ROOT}/scanners/scan-orchestrator.mjs <target-path> --output-file ~/.claude/config-audit/sessions/{session-id}/findings/scan-results.json [--full-machine] [--global] 2>/dev/null; echo $?
Check exit code: 0/1/2 → normal. 3 → "Discovery encountered an error. Try a narrower scope."
Step 6: Save scope and state
Write scope.yaml and state.yaml to session directory. Update state with current_phase: "discover", next_phase: "analyze".
Step 7: Present summary
Read the scan results file to count files and findings:
Full scan:
### Discovery Complete
**{scope_type}** scope — found {total_files} configuration files:
| Type | Count |
|------|-------|
| CLAUDE.md | {n} |
| Settings | {n} |
| MCP configs | {n} |
| Rules | {n} |
| Hooks | {n} |
| Other | {n} |
Initial scan found {finding_count} items to review.
**Next:** Run `/config-audit analyze` to generate your analysis report.
Delta scan:
### Delta Discovery Complete
Compared against baseline from {previous-session-id}:
| Status | Files |
|--------|-------|
| Changed | {n} |
| New | {n} |
| Deleted | {n} |
| Unchanged | {n} |
Only {changed+new} file(s) scanned (vs {total} full scan).
**Next:** Run `/config-audit analyze` to generate your analysis report.
Config File Patterns
| Pattern | Description |
|---|---|
**/CLAUDE.md |
Project instructions |
**/CLAUDE.local.md |
Local overrides |
**/.claude/settings.json |
Project settings |
**/.mcp.json |
MCP servers |
**/.claude/rules/*.md |
Modular rules |
For global: ~/.claude/CLAUDE.md, ~/.claude/settings.json, ~/.claude.json, ~/.claude/agents/*.md
Error Handling
- If scanner fails, report to user in plain language and suggest narrower scope
- If path doesn't exist, tell user and suggest alternatives
- If git command fails for
reposcope, silently fall back tocurrent - If no config files found, explain: "No Claude Code configuration files found. Start with
/config-audit feature-gapto see what's recommended."