feat: initial open marketplace with llm-security, config-audit, ultraplan-local
This commit is contained in:
commit
f93d6abdae
380 changed files with 65935 additions and 0 deletions
74
plugins/config-audit/commands/analyze.md
Normal file
74
plugins/config-audit/commands/analyze.md
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
---
|
||||
name: config-audit:analyze
|
||||
description: Phase 2 - Generate analysis report with hierarchy map and issue detection
|
||||
allowed-tools: Read, Write, Edit, Glob, Grep, Agent
|
||||
model: opus
|
||||
---
|
||||
|
||||
# Config-Audit: Analysis (Phase 2)
|
||||
|
||||
Generate comprehensive analysis report from discovery findings.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Must have completed Phase 1 (discovery)
|
||||
- Findings must exist in `~/.claude/config-audit/sessions/{session-id}/findings/`
|
||||
|
||||
## Implementation
|
||||
|
||||
### Step 1: Verify session state
|
||||
|
||||
Read `~/.claude/config-audit/sessions/{session-id}/state.yaml` and verify discovery phase completed. If not, tell the user: "Discovery hasn't been run yet. Start with `/config-audit discover` or just run `/config-audit` for a full audit."
|
||||
|
||||
### Step 2: Tell the user what's happening
|
||||
|
||||
```
|
||||
## Analyzing Configuration
|
||||
|
||||
Reading your scan findings and generating a detailed analysis report...
|
||||
This includes hierarchy mapping, conflict detection, and prioritized recommendations.
|
||||
```
|
||||
|
||||
### Step 3: Spawn analyzer agent
|
||||
|
||||
Tell the user: **"Generating analysis (this takes about 30 seconds)..."**
|
||||
|
||||
```
|
||||
Agent(subagent_type: "config-audit:analyzer-agent")
|
||||
model: sonnet
|
||||
prompt: |
|
||||
Analyze all findings in: ~/.claude/config-audit/sessions/{session-id}/findings/
|
||||
Generate comprehensive report covering:
|
||||
1. Executive summary with key metrics
|
||||
2. Hierarchy map visualization
|
||||
3. Conflict detection across config layers
|
||||
4. CLAUDE.md quality assessment
|
||||
5. Security issues (secrets, permissions)
|
||||
6. Top 10 prioritized recommendations
|
||||
Output to: ~/.claude/config-audit/sessions/{session-id}/analysis-report.md
|
||||
```
|
||||
|
||||
### Step 4: Present summary
|
||||
|
||||
After the agent completes, read the generated report and show a brief summary:
|
||||
|
||||
```markdown
|
||||
### Analysis Complete
|
||||
|
||||
Report generated with:
|
||||
- {N} conflicts detected
|
||||
- {N} optimization opportunities
|
||||
- {N} security notes
|
||||
- Top recommendation: {first recommendation}
|
||||
|
||||
Full report: `~/.claude/config-audit/sessions/{session-id}/analysis-report.md`
|
||||
|
||||
### What's next
|
||||
|
||||
- **`/config-audit plan`** — Turn findings into a prioritized action plan
|
||||
- **`/config-audit fix`** — Auto-fix deterministic issues right away
|
||||
```
|
||||
|
||||
### Step 5: Update state
|
||||
|
||||
Update `state.yaml` with `current_phase: "analyze"`, `next_phase: "plan"`.
|
||||
95
plugins/config-audit/commands/cleanup.md
Normal file
95
plugins/config-audit/commands/cleanup.md
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
---
|
||||
name: config-audit:cleanup
|
||||
description: Clean up old config-audit sessions to reclaim disk space
|
||||
allowed-tools: Read, Write, Glob, Bash, AskUserQuestion
|
||||
model: sonnet
|
||||
---
|
||||
|
||||
# Config-Audit: Session Cleanup
|
||||
|
||||
Manage and clean up accumulated config-audit sessions in `~/.claude/config-audit/sessions/`.
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
/config-audit cleanup
|
||||
```
|
||||
|
||||
## Implementation Steps
|
||||
|
||||
1. **List all sessions**:
|
||||
- Glob `~/.claude/config-audit/sessions/*/state.yaml`
|
||||
- For each session, read state.yaml and extract:
|
||||
- Session ID
|
||||
- Created timestamp
|
||||
- Current phase
|
||||
- Whether session is active (has `next_phase` and `current_phase` is not `verify` or `complete`)
|
||||
|
||||
2. **Calculate disk usage**:
|
||||
- Use `du -sh ~/.claude/config-audit/sessions/{session-id}/` for each session
|
||||
- Calculate total usage
|
||||
|
||||
3. **Display session table**:
|
||||
```
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
Config-Audit Sessions
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
| # | Session ID | Age | Phase | Status | Size |
|
||||
|---|------------|-----|-------|--------|------|
|
||||
| 1 | 20260127_102527 | 15d | implement | active | 12K |
|
||||
| 2 | quick-20260126 | 16d | analyze | complete | 8K |
|
||||
| 3 | 20260120_091500 | 22d | analyze | complete | 6K |
|
||||
|
||||
Total: 3 sessions, 26K disk usage
|
||||
```
|
||||
|
||||
4. **Ask cleanup action**:
|
||||
```
|
||||
AskUserQuestion:
|
||||
question: "Which sessions should I clean up?"
|
||||
header: "Cleanup"
|
||||
options:
|
||||
- label: "Completed sessions only (Recommended)"
|
||||
description: "Delete sessions where phase is verify/complete. Keeps active sessions safe."
|
||||
- label: "Older than 14 days"
|
||||
description: "Delete all sessions older than 14 days, regardless of status."
|
||||
- label: "All except current"
|
||||
description: "Delete everything except the most recent active session."
|
||||
- label: "Cancel"
|
||||
description: "Don't delete anything."
|
||||
```
|
||||
|
||||
5. **Safety guards**:
|
||||
- NEVER delete sessions where `current_phase` is not `verify` or `complete` AND `next_phase` exists, unless user explicitly chose age-based or all-except-current
|
||||
- Warn before deleting active sessions: "Session {id} is still active (phase: {phase}). Delete anyway?"
|
||||
|
||||
6. **Execute cleanup**:
|
||||
- For each session to delete: `rm -rf ~/.claude/config-audit/sessions/{session-id}/`
|
||||
- Track deleted count and freed space
|
||||
|
||||
7. **Output summary**:
|
||||
```
|
||||
✓ Cleanup complete
|
||||
|
||||
Deleted: 2 sessions
|
||||
Freed: 14K disk space
|
||||
Remaining: 1 session (active)
|
||||
```
|
||||
|
||||
## Session Status Detection
|
||||
|
||||
A session is considered **active** if ALL of these are true:
|
||||
- `current_phase` is not `verify` and not `complete`
|
||||
- `next_phase` exists and is not empty
|
||||
|
||||
A session is considered **complete** if ANY of these are true:
|
||||
- `current_phase` is `verify` or `complete`
|
||||
- `next_phase` is empty or null
|
||||
|
||||
## Error Handling
|
||||
|
||||
- **Legacy path:** Also check `~/.config-audit/sessions/` for sessions created before v2.2.0. If found, include them in the session list and note: "Found {n} session(s) at legacy path (~/.config-audit/). These will be cleaned up normally."
|
||||
- If `~/.claude/config-audit/sessions/` doesn't exist (and no legacy sessions): "No sessions found. Nothing to clean up."
|
||||
- If no sessions match criteria: "No sessions match the selected criteria."
|
||||
- If deletion fails: Log error, continue with other sessions
|
||||
202
plugins/config-audit/commands/config-audit.md
Normal file
202
plugins/config-audit/commands/config-audit.md
Normal file
|
|
@ -0,0 +1,202 @@
|
|||
---
|
||||
name: config-audit
|
||||
description: Claude Code Configuration Intelligence - audit, analyze, and optimize your configuration
|
||||
argument-hint: "[posture|feature-gap|fix|rollback|plan|implement|help|discover|analyze|interview|drift|plugin-health|status|cleanup]"
|
||||
allowed-tools: Read, Write, Glob, Grep, Bash, Agent, AskUserQuestion
|
||||
model: opus
|
||||
---
|
||||
|
||||
# Config-Audit: Claude Code Configuration Intelligence
|
||||
|
||||
Analyze, report on, and optimize your Claude Code configuration.
|
||||
|
||||
## Router Logic
|
||||
|
||||
If a subcommand is provided, route to it:
|
||||
- `posture` → `/config-audit:posture`
|
||||
- `feature-gap` → `/config-audit:feature-gap`
|
||||
- `fix` → `/config-audit:fix`
|
||||
- `rollback` → `/config-audit:rollback`
|
||||
- `plan` → `/config-audit:plan`
|
||||
- `implement` → `/config-audit:implement`
|
||||
- `help` → `/config-audit:help`
|
||||
- `discover` → `/config-audit:discover`
|
||||
- `analyze` → `/config-audit:analyze`
|
||||
- `interview` → `/config-audit:interview`
|
||||
- `drift` → `/config-audit:drift`
|
||||
- `plugin-health` → `/config-audit:plugin-health`
|
||||
- `status` → `/config-audit:status`
|
||||
- `cleanup` → `/config-audit:cleanup`
|
||||
|
||||
If a scope override is provided (`current`, `repo`, `home`, `full`), use it as the scope type (see Scope Resolution below).
|
||||
|
||||
If no subcommand and no scope override: **run the default audit** (see below).
|
||||
|
||||
## UX Rules (MANDATORY — apply to every step)
|
||||
|
||||
1. **Narrate before acting.** Before each step, tell the user what you're about to do and why, in plain language.
|
||||
2. **Never show raw output.** All scanner Bash commands MUST use `--output-file <path>` AND `2>/dev/null`. The user should NEVER see JSON, stderr progress lines, or exit codes.
|
||||
3. **Handle exit codes silently.** Append `; echo $?` to scanner commands. Exit codes 0/1/2 are all expected (PASS/WARNING/FAIL). Only exit code 3 is a real error — tell user: "Scanner encountered an unexpected error. Try `/config-audit posture` for a quick check instead."
|
||||
4. **Explain, don't dump.** When presenting findings, add plain-language context. "Grade B" alone means nothing — say "Grade B — your CLAUDE.md files are well-structured with minor improvements possible."
|
||||
5. **Separate signal from noise.** If findings exist in `tests/fixtures/` or `examples/` directories, count them separately and exclude from the main count: "Found 37 findings (66 additional in test fixtures, excluded)."
|
||||
6. **Context-sensitive next steps.** Don't just list commands — explain what each does and why the user might want it based on their specific results.
|
||||
|
||||
## Default Audit (no arguments)
|
||||
|
||||
### Step 1: Auto-detect scope and greet the user
|
||||
|
||||
If the user provided a scope override (`/config-audit full`, `/config-audit repo`, etc.), use that.
|
||||
|
||||
Otherwise, auto-detect:
|
||||
1. Run `git rev-parse --show-toplevel 2>/dev/null` via Bash
|
||||
2. If it succeeds and pwd is inside the repo → **repo** scope (use the git root path)
|
||||
3. If pwd is `$HOME` → **home** scope
|
||||
4. Otherwise → **current** directory scope
|
||||
|
||||
Show the user what's happening:
|
||||
|
||||
```
|
||||
## Config-Audit
|
||||
|
||||
Analyzing your Claude Code configuration...
|
||||
|
||||
**Scope:** {Repository|Home directory|Current directory} — `{path}`
|
||||
**What this checks:** CLAUDE.md quality, settings validation, hook safety, rules correctness, MCP server config, import chains, conflicts, and feature coverage.
|
||||
```
|
||||
|
||||
### Step 2: Initialize session
|
||||
|
||||
1. Generate session ID: `YYYYMMDD_HHmmss` format
|
||||
2. Create session directory and findings subdirectory:
|
||||
|
||||
```bash
|
||||
mkdir -p ~/.claude/config-audit/sessions/{session-id}/findings
|
||||
```
|
||||
|
||||
This is a silent infrastructure step — do NOT show output to the user.
|
||||
|
||||
### Step 3: Run scanners and posture assessment
|
||||
|
||||
Tell the user: **"Running 8 configuration scanners..."**
|
||||
|
||||
Run both scanners and posture in a single Bash command:
|
||||
|
||||
```bash
|
||||
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; node ${CLAUDE_PLUGIN_ROOT}/scanners/posture.mjs <target-path> --json --output-file ~/.claude/config-audit/sessions/{session-id}/posture.json [--full-machine] [--global] 2>/dev/null; echo $?
|
||||
```
|
||||
|
||||
Use `--full-machine` for `full` scope, `--global` for `home` scope. For `repo` and `current`, pass the resolved path directly.
|
||||
|
||||
Check the echoed exit code:
|
||||
- `0`, `1`, or `2` → continue normally
|
||||
- `3` → tell user: "Scanner encountered an unexpected error. Try `/config-audit posture` for a quick check instead." and stop.
|
||||
|
||||
### Step 4: Analyze results
|
||||
|
||||
Tell the user: **"Scanners complete. Preparing your results..."**
|
||||
|
||||
Read BOTH output files using the Read tool:
|
||||
- `~/.claude/config-audit/sessions/{session-id}/findings/scan-results.json`
|
||||
- `~/.claude/config-audit/sessions/{session-id}/posture.json`
|
||||
|
||||
Extract these metrics from the JSON:
|
||||
|
||||
**From posture.json:**
|
||||
- `overallGrade` — the health grade (A-F)
|
||||
- `opportunityCount` — number of unused features detected
|
||||
- `areas[]` — per-area grades and finding counts (use only quality areas, exclude Feature Coverage)
|
||||
|
||||
**From scan-results.json:**
|
||||
- `aggregate.total_findings` — total findings (test fixture findings are already excluded automatically)
|
||||
- `fixture_findings` array (if present) — count of findings excluded from test/example directories
|
||||
- Count findings by severity from `aggregate.counts` (critical, high, medium, low, info)
|
||||
- Count findings where `autoFixable: true`
|
||||
- Note total `files_scanned` across scanners
|
||||
|
||||
### Step 5: Update state
|
||||
|
||||
Write session state (silent — no user output):
|
||||
|
||||
```yaml
|
||||
session_id: "{session-id}"
|
||||
current_phase: "analyze"
|
||||
completed_phases: ["discover", "analyze"]
|
||||
next_phase: "plan"
|
||||
updated_at: "{ISO timestamp}"
|
||||
scope_type: "{repo|home|current|full}"
|
||||
target_path: "{resolved path}"
|
||||
```
|
||||
|
||||
Write to: `~/.claude/config-audit/sessions/{session-id}/state.yaml`
|
||||
|
||||
### Step 6: Display results
|
||||
|
||||
Present results using this template. Replace all placeholders with actual values. **Adapt the summary sentence based on grade.**
|
||||
|
||||
```markdown
|
||||
### Results
|
||||
|
||||
**Health: {overallGrade}** | {qualityAreaCount} areas scanned
|
||||
|
||||
{grade-based summary — pick ONE:}
|
||||
- Grade A: "Excellent — your configuration is correct and well-maintained."
|
||||
- Grade B: "Strong — your configuration is solid with minor improvements available."
|
||||
- Grade C: "Decent — your configuration works but has some issues worth addressing."
|
||||
- Grade D: "Needs work — several configuration issues could affect your Claude Code experience."
|
||||
- Grade F: "Significant issues found — addressing these will meaningfully improve your workflow."
|
||||
|
||||
Scanned {files_scanned} files | {real_finding_count} findings ({severity_breakdown})
|
||||
{If test_fixture_count > 0: "({test_fixture_count} additional findings in test fixtures were excluded.)"}
|
||||
{If fixable_count > 0: "{fixable_count} of these can be auto-fixed."}
|
||||
|
||||
### Area Breakdown
|
||||
|
||||
| Area | Grade | Findings | |
|
||||
|------|-------|----------|-|
|
||||
| CLAUDE.md | {grade} | {count} | {one-phrase status} |
|
||||
| Settings | {grade} | {count} | {status} |
|
||||
| Hooks | {grade} | {count} | {status} |
|
||||
| Rules | {grade} | {count} | {status} |
|
||||
| MCP Servers | {grade} | {count} | {status} |
|
||||
| Imports | {grade} | {count} | {status} |
|
||||
| Conflicts | {grade} | {count} | {status} |
|
||||
|
||||
{For the status column, use plain language like: "Well structured", "2 minor issues", "Missing trust levels", "No issues", etc.}
|
||||
|
||||
{If opportunityCount > 0:}
|
||||
{opportunityCount} feature opportunities available — run `/config-audit feature-gap` for context-aware recommendations.
|
||||
|
||||
### What you can do next
|
||||
|
||||
{Include only relevant options based on findings. Explain each one:}
|
||||
|
||||
{If fixable_count > 0:}
|
||||
- **`/config-audit fix`** — Automatically fix {fixable_count} issues. Creates a backup first so you can roll back with one command.
|
||||
|
||||
{If real findings > fixable_count:}
|
||||
- **`/config-audit plan`** — Get a prioritized action plan for the {remaining} issues that need manual attention.
|
||||
|
||||
{If grade is C or better:}
|
||||
- **`/config-audit feature-gap`** — See which features could help your project, and implement the ones you want on the spot.
|
||||
|
||||
{If grade is D or F:}
|
||||
- **`/config-audit fix`** should be your first step — it handles the most impactful issues automatically.
|
||||
|
||||
Session saved to: `~/.claude/config-audit/sessions/{session-id}/`
|
||||
```
|
||||
|
||||
## Scope Resolution
|
||||
|
||||
| Scope | What gets scanned |
|
||||
|-------|-------------------|
|
||||
| `current` | Current directory + parent CLAUDE.md files up to root + `~/.claude/` |
|
||||
| `repo` | Git repository root + `~/.claude/` |
|
||||
| `home` | `~/.claude/` global configuration only |
|
||||
| `full` | Everything: `~/.claude/`, managed paths, all dev dirs under $HOME |
|
||||
|
||||
## Error Handling
|
||||
|
||||
- If scanner fails (exit 3), tell the user in plain language and suggest `/config-audit posture` as fallback
|
||||
- If path doesn't exist, tell the user: "That path doesn't exist. Run `/config-audit` without arguments to auto-detect."
|
||||
- If git command fails for auto-detect, silently fall back to `current` scope
|
||||
- If no CLAUDE.md found anywhere, explain: "No CLAUDE.md found. This is the main configuration file for Claude Code — creating one is the single highest-impact thing you can do. Run `/config-audit feature-gap` to see what's recommended."
|
||||
141
plugins/config-audit/commands/discover.md
Normal file
141
plugins/config-audit/commands/discover.md
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
---
|
||||
name: config-audit:discover
|
||||
description: Phase 1 - Initialize session, auto-detect scope, and discover config files
|
||||
argument-hint: "[current|repo|home|full] [--delta]"
|
||||
allowed-tools: Read, Write, Edit, Glob, Grep, Agent, AskUserQuestion, Bash
|
||||
model: 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:
|
||||
|
||||
```bash
|
||||
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:
|
||||
1. Run `git rev-parse --show-toplevel 2>/dev/null`
|
||||
2. If inside a git repo → **repo** scope
|
||||
3. If pwd is `$HOME` → **home** scope
|
||||
4. 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:
|
||||
1. Find previous baseline from `~/.claude/config-audit/sessions/*/discovery.json`
|
||||
2. If no previous: "No previous scan found. Running full discovery instead."
|
||||
3. Compare file mtimes/sizes to classify as changed/new/deleted/unchanged
|
||||
4. Only scan changed + new files
|
||||
|
||||
### Step 5: Run discovery
|
||||
|
||||
Run the scan orchestrator silently to discover and scan files:
|
||||
|
||||
```bash
|
||||
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:**
|
||||
```markdown
|
||||
### 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:**
|
||||
```markdown
|
||||
### 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 `repo` scope, silently fall back to `current`
|
||||
- If no config files found, explain: "No Claude Code configuration files found. Start with `/config-audit feature-gap` to see what's recommended."
|
||||
98
plugins/config-audit/commands/drift.md
Normal file
98
plugins/config-audit/commands/drift.md
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
---
|
||||
name: config-audit:drift
|
||||
description: Compare current configuration against a saved baseline — shows new, resolved, and changed findings
|
||||
argument-hint: "[path] [--baseline name] [--save]"
|
||||
allowed-tools: Read, Write, Glob, Grep, Bash
|
||||
model: sonnet
|
||||
---
|
||||
|
||||
# Config-Audit: Drift Detection
|
||||
|
||||
Compare current configuration against a saved baseline to see what changed.
|
||||
|
||||
## Arguments
|
||||
|
||||
- `$ARGUMENTS` may contain:
|
||||
- A target path (default: current working directory)
|
||||
- `--save`: Save current state as baseline
|
||||
- `--baseline <name>`: Compare against a specific named baseline (default: "default")
|
||||
|
||||
## Implementation
|
||||
|
||||
### Save a baseline
|
||||
|
||||
If `--save` is present:
|
||||
|
||||
Tell the user: **"Saving current configuration as baseline..."**
|
||||
|
||||
```bash
|
||||
node ${CLAUDE_PLUGIN_ROOT}/scanners/drift-cli.mjs <path> --save --name <baseline-name> 2>/dev/null
|
||||
```
|
||||
|
||||
Read stdout for confirmation. Tell the user:
|
||||
|
||||
```markdown
|
||||
### Baseline Saved
|
||||
|
||||
Captured current state as baseline "{name}".
|
||||
Run `/config-audit drift` anytime to see what changed since this point.
|
||||
```
|
||||
|
||||
### Compare against baseline
|
||||
|
||||
Without `--save`:
|
||||
|
||||
Tell the user: **"Comparing current configuration against baseline..."**
|
||||
|
||||
```bash
|
||||
node ${CLAUDE_PLUGIN_ROOT}/scanners/drift-cli.mjs <path> --baseline <name> 2>/dev/null
|
||||
```
|
||||
|
||||
Read stdout. If baseline not found, tell the user:
|
||||
|
||||
```
|
||||
No baseline found. Save one first with:
|
||||
/config-audit drift --save
|
||||
```
|
||||
|
||||
Otherwise, parse and present the drift report:
|
||||
|
||||
```markdown
|
||||
### Configuration Drift
|
||||
|
||||
**Trend:** {Improving|Degrading|Stable}
|
||||
**Score:** {before} → {after} ({+/-delta} points)
|
||||
|
||||
{If new findings:}
|
||||
#### New Issues ({count})
|
||||
| ID | Severity | Description |
|
||||
|----|----------|-------------|
|
||||
| ... | ... | ... |
|
||||
|
||||
{If resolved findings:}
|
||||
#### Resolved ({count})
|
||||
| ID | Description |
|
||||
|----|-------------|
|
||||
| ... | ... |
|
||||
|
||||
{If area changes:}
|
||||
#### Area Changes
|
||||
| Area | Before | After | Change |
|
||||
|------|--------|-------|--------|
|
||||
| ... | ... | ... | ... |
|
||||
```
|
||||
|
||||
### List baselines
|
||||
|
||||
If `$ARGUMENTS` contains `--list`:
|
||||
|
||||
```bash
|
||||
node ${CLAUDE_PLUGIN_ROOT}/scanners/drift-cli.mjs --list 2>/dev/null
|
||||
```
|
||||
|
||||
### What's next
|
||||
|
||||
After viewing drift:
|
||||
- `/config-audit fix` — Auto-fix new findings
|
||||
- `/config-audit posture` — Full posture assessment
|
||||
- `/config-audit drift --save` — Update the baseline to current state
|
||||
185
plugins/config-audit/commands/feature-gap.md
Normal file
185
plugins/config-audit/commands/feature-gap.md
Normal file
|
|
@ -0,0 +1,185 @@
|
|||
---
|
||||
name: config-audit:feature-gap
|
||||
description: Context-aware feature recommendations — what could enhance your setup and why
|
||||
argument-hint: "[path]"
|
||||
allowed-tools: Read, Write, Edit, Glob, Grep, Bash, Agent, AskUserQuestion
|
||||
model: opus
|
||||
---
|
||||
|
||||
# Config-Audit: Feature Opportunities
|
||||
|
||||
Context-aware analysis of Claude Code features that could benefit your specific project — with the option to implement selected recommendations on the spot.
|
||||
|
||||
## What the user gets
|
||||
|
||||
- Project context detection (language, size, existing configuration)
|
||||
- Numbered recommendations grouped by impact (high / worth considering / explore)
|
||||
- Each recommendation backed by evidence (Anthropic docs, proven issues)
|
||||
- **Interactive selection: "Which would you like to implement?"**
|
||||
- Direct implementation with backup for selected items
|
||||
|
||||
## Implementation
|
||||
|
||||
### Step 1: Determine target and greet
|
||||
|
||||
Parse `$ARGUMENTS` for a path (default: current working directory).
|
||||
|
||||
Tell the user:
|
||||
|
||||
```
|
||||
## Feature Opportunities
|
||||
|
||||
Analyzing which Claude Code features could benefit your workflow...
|
||||
```
|
||||
|
||||
### Step 2: Create session and run posture
|
||||
|
||||
Generate session ID (`YYYYMMDD_HHmmss`) if no active session exists.
|
||||
|
||||
```bash
|
||||
mkdir -p ~/.claude/config-audit/sessions/{session-id}/findings 2>/dev/null
|
||||
node ${CLAUDE_PLUGIN_ROOT}/scanners/posture.mjs <target-path> --json --output-file ~/.claude/config-audit/sessions/{session-id}/posture.json 2>/dev/null; echo $?
|
||||
```
|
||||
|
||||
If exit code is non-zero: "Assessment couldn't run. Check that the path exists and contains configuration files."
|
||||
|
||||
### Step 3: Read posture data and detect project context
|
||||
|
||||
Read `~/.claude/config-audit/sessions/{session-id}/posture.json` using the Read tool.
|
||||
|
||||
Extract GAP findings from `scannerEnvelope.scanners` (find scanner with `scanner === 'GAP'`).
|
||||
|
||||
Detect project context:
|
||||
```bash
|
||||
test -f <target-path>/package.json && echo "has_package_json" || echo "no_package_json"
|
||||
ls <target-path>/*.py <target-path>/requirements.txt <target-path>/pyproject.toml 2>/dev/null | head -3
|
||||
```
|
||||
|
||||
### Step 4: Build numbered recommendations
|
||||
|
||||
Read `${CLAUDE_PLUGIN_ROOT}/knowledge/gap-closure-templates.md` for implementation templates.
|
||||
|
||||
Group GAP findings into three sections. Number them sequentially across sections:
|
||||
|
||||
```markdown
|
||||
### High Impact
|
||||
|
||||
These address correctness or safety — consider them seriously.
|
||||
|
||||
**1.** Add permissions.deny for sensitive paths
|
||||
→ Settings enforcement is stronger than CLAUDE.md instructions.
|
||||
→ Effort: Low (5 min)
|
||||
|
||||
**2.** Configure at least one hook for safety automation
|
||||
→ Hooks guarantee the action happens. CLAUDE.md instructions are advisory.
|
||||
→ Effort: Medium (15 min)
|
||||
|
||||
### Worth Considering
|
||||
|
||||
These improve workflow efficiency for projects like yours.
|
||||
|
||||
**3.** Split CLAUDE.md into focused modules with @imports
|
||||
→ Files over 200 lines degrade Claude's adherence to instructions.
|
||||
→ Effort: Low (10 min)
|
||||
|
||||
**4.** Add path-scoped rules for different file types
|
||||
→ Unscoped rules load every session regardless of relevance.
|
||||
→ Effort: Low (10 min)
|
||||
|
||||
### Explore When Ready
|
||||
|
||||
Nice-to-have. Skip if your current setup works well.
|
||||
|
||||
**5.** Custom keybindings (Shift+Enter for newline)
|
||||
→ Effort: Low (2 min)
|
||||
|
||||
**6.** Status line configuration
|
||||
→ Effort: Low (2 min)
|
||||
```
|
||||
|
||||
Each recommendation MUST have:
|
||||
- A number
|
||||
- A one-line description
|
||||
- A "Why" with evidence
|
||||
- An effort estimate from the templates
|
||||
|
||||
### Step 5: Ask what to implement
|
||||
|
||||
```
|
||||
AskUserQuestion:
|
||||
question: "Which would you like to implement? I'll create a backup first."
|
||||
options:
|
||||
- "All high impact (1-2)"
|
||||
- "Pick specific: e.g. 1,3,5"
|
||||
- "None — just wanted to see the recommendations"
|
||||
```
|
||||
|
||||
If "None": show the full report location and exit.
|
||||
|
||||
If the user picks numbers: parse the selection and proceed to Step 6.
|
||||
|
||||
### Step 6: Implement selected recommendations
|
||||
|
||||
For each selected recommendation:
|
||||
|
||||
1. **Create backup** of any files that will be modified:
|
||||
```bash
|
||||
node ${CLAUDE_PLUGIN_ROOT}/scanners/fix-cli.mjs <target-path> --json 2>/dev/null
|
||||
```
|
||||
Or create manual backup:
|
||||
```bash
|
||||
mkdir -p ~/.claude/config-audit/backups/$(date +%Y%m%d_%H%M%S)/files/ 2>/dev/null
|
||||
```
|
||||
Copy each file that will be touched.
|
||||
|
||||
2. **Apply the template** from gap-closure-templates.md. Use the Write or Edit tool to create or modify the relevant configuration file.
|
||||
|
||||
3. **Show progress** as each item is done:
|
||||
```
|
||||
Implementing 3 recommendations...
|
||||
|
||||
✓ 1. permissions.deny — added to .claude/settings.json
|
||||
✓ 3. Modular CLAUDE.md — created .claude/rules/testing.md, added @import
|
||||
✓ 5. Keybindings — created ~/.claude/keybindings.json
|
||||
```
|
||||
|
||||
4. **Verify** by re-running posture:
|
||||
```bash
|
||||
node ${CLAUDE_PLUGIN_ROOT}/scanners/posture.mjs <target-path> --json --output-file /tmp/config-audit-verify-$$.json 2>/dev/null
|
||||
```
|
||||
|
||||
### Step 7: Show results
|
||||
|
||||
```markdown
|
||||
### Done
|
||||
|
||||
**{N} recommendations implemented** | Backup created
|
||||
|
||||
{If health grade changed:}
|
||||
Health: {old_grade} → {new_grade} (+{delta} points)
|
||||
|
||||
{Show remaining opportunities if any:}
|
||||
{remaining} more opportunities available — run `/config-audit feature-gap` again anytime.
|
||||
|
||||
**Rollback:** If anything looks wrong, run `/config-audit rollback` to restore.
|
||||
```
|
||||
|
||||
## Implementation Guidelines
|
||||
|
||||
When implementing recommendations, be smart about context:
|
||||
|
||||
- **permissions.deny**: Look at the project for common sensitive paths (`.env`, `secrets/`, `.git/config`, `*.pem`). Don't just copy a template blindly — check what actually exists.
|
||||
- **hooks**: Start with a simple, useful hook. Don't scaffold 5 hooks at once.
|
||||
- **path-scoped rules**: Look at the project's file structure to determine meaningful scopes (e.g., `tests/**/*.ts` vs `src/**/*.ts`).
|
||||
- **CLAUDE.md modularization**: Only suggest splitting if the file is over 100 lines. Read it first to find natural section boundaries.
|
||||
- **MCP setup**: Only relevant if the user actually has external tools to connect. Ask before creating.
|
||||
- **Custom plugin**: Too complex for inline implementation — suggest `/config-audit plan` instead.
|
||||
|
||||
For items that genuinely need user input (e.g., "which MCP servers do you use?"), ask briefly during implementation rather than skipping them.
|
||||
|
||||
## Safety
|
||||
|
||||
- **Backup mandatory** — always create before modifying
|
||||
- **Show what's changing** — the user sees each change as it happens
|
||||
- **Rollback available** — `/config-audit rollback` at any time
|
||||
- **Non-destructive** — only create new files or add to existing; never delete content
|
||||
138
plugins/config-audit/commands/fix.md
Normal file
138
plugins/config-audit/commands/fix.md
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
---
|
||||
name: config-audit:fix
|
||||
description: Auto-fix deterministic configuration issues with backup and verification
|
||||
argument-hint: "[path] [--dry-run]"
|
||||
allowed-tools: Read, Write, Glob, Grep, Bash, AskUserQuestion
|
||||
model: sonnet
|
||||
---
|
||||
|
||||
# Config-Audit: Fix
|
||||
|
||||
Auto-fix deterministic configuration issues. Scans, plans fixes, backs up originals, applies changes, and verifies results.
|
||||
|
||||
## Arguments
|
||||
|
||||
- `$ARGUMENTS` may contain:
|
||||
- A target path (default: current working directory)
|
||||
- `--dry-run`: Show fix plan without applying
|
||||
|
||||
## Implementation
|
||||
|
||||
### Step 1: Greet and scan
|
||||
|
||||
Tell the user:
|
||||
|
||||
```
|
||||
## Config-Audit Fix
|
||||
|
||||
Scanning for auto-fixable issues...
|
||||
```
|
||||
|
||||
Run scanners silently:
|
||||
|
||||
```bash
|
||||
node ${CLAUDE_PLUGIN_ROOT}/scanners/scan-orchestrator.mjs <path> --output-file /tmp/config-audit-fix-scan-$$.json [--global] 2>/dev/null; echo $?
|
||||
```
|
||||
|
||||
Exit code 3 → tell user: "Scanner error. Try `/config-audit posture` to check your configuration."
|
||||
|
||||
### Step 2: Plan fixes
|
||||
|
||||
Run fix planner silently:
|
||||
|
||||
```bash
|
||||
node ${CLAUDE_PLUGIN_ROOT}/scanners/fix-cli.mjs <path> --json 2>/dev/null
|
||||
```
|
||||
|
||||
Read the JSON output. Categorize fixes into auto-fixable and manual.
|
||||
|
||||
### Step 3: Present fix plan
|
||||
|
||||
Show what will be fixed and what needs manual attention:
|
||||
|
||||
```markdown
|
||||
### Fix Plan
|
||||
|
||||
**Auto-fixable ({N} issues):**
|
||||
|
||||
| # | ID | Issue | File |
|
||||
|---|-----|-------|------|
|
||||
| 1 | CA-SET-003 | Add $schema to settings.json | .claude/settings.json |
|
||||
| 2 | ... | ... | ... |
|
||||
|
||||
**Manual ({M} issues — require human judgment):**
|
||||
|
||||
| # | ID | Issue | Recommendation |
|
||||
|---|-----|-------|----------------|
|
||||
| 1 | CA-CML-003 | CLAUDE.md exceeds 200 lines | Split content into @imports or .claude/rules/ |
|
||||
| ... | ... | ... | ... |
|
||||
```
|
||||
|
||||
### Step 4: Confirm with user
|
||||
|
||||
If not `--dry-run`, ask for confirmation:
|
||||
|
||||
```
|
||||
AskUserQuestion:
|
||||
question: "Apply {N} auto-fixes? A backup is created first — you can roll back anytime."
|
||||
options:
|
||||
- "Yes, apply fixes"
|
||||
- "Show dry-run only"
|
||||
- "Cancel"
|
||||
```
|
||||
|
||||
### Step 5: Apply fixes
|
||||
|
||||
If confirmed, apply:
|
||||
|
||||
```bash
|
||||
node ${CLAUDE_PLUGIN_ROOT}/scanners/fix-cli.mjs <path> --apply --json 2>/dev/null
|
||||
```
|
||||
|
||||
Read the JSON output to get applied/failed counts and backup location.
|
||||
|
||||
### Step 6: Show results
|
||||
|
||||
Run a quick posture check to measure improvement:
|
||||
|
||||
```bash
|
||||
node ${CLAUDE_PLUGIN_ROOT}/scanners/posture.mjs <path> --json --output-file /tmp/config-audit-fix-posture-$$.json 2>/dev/null
|
||||
```
|
||||
|
||||
Present results:
|
||||
|
||||
```markdown
|
||||
### Results
|
||||
|
||||
**{applied} fixed** | {failed} failed | Backup created
|
||||
|
||||
{If grade improved:}
|
||||
Score impact: {old_grade} ({old_score}) → {new_grade} ({new_score}) — **+{delta} points**
|
||||
|
||||
{If failed > 0:}
|
||||
{failed} fix(es) couldn't be applied — run `/config-audit plan` for alternative approaches.
|
||||
|
||||
**Rollback:** If anything looks wrong, run `/config-audit rollback {backup-id}` to restore.
|
||||
```
|
||||
|
||||
### Step 7: Manual findings
|
||||
|
||||
If manual findings exist:
|
||||
|
||||
```markdown
|
||||
### Needs manual attention
|
||||
|
||||
These {M} issues require human judgment:
|
||||
|
||||
1. **{title}** ({id}) — {recommendation}
|
||||
2. ...
|
||||
|
||||
Run `/config-audit plan` to get a step-by-step guide for addressing these.
|
||||
```
|
||||
|
||||
## Safety
|
||||
|
||||
- Backup is **mandatory** — every fix creates a backup first
|
||||
- Dry-run by default — user must confirm before changes
|
||||
- Verify after fix — re-scans to confirm findings resolved
|
||||
- Rollback always available — `/config-audit rollback <backup-id>`
|
||||
78
plugins/config-audit/commands/help.md
Normal file
78
plugins/config-audit/commands/help.md
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
---
|
||||
name: config-audit:help
|
||||
description: Show all available config-audit commands
|
||||
allowed-tools: Read
|
||||
model: sonnet
|
||||
---
|
||||
|
||||
# Config-Audit: Help
|
||||
|
||||
## Getting Started
|
||||
|
||||
Just run `/config-audit` — it auto-detects your project scope and runs a full audit. No setup needed.
|
||||
|
||||
## All Commands
|
||||
|
||||
### Core
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `/config-audit` | Full audit with auto-scope detection |
|
||||
| `/config-audit posture` | Quick scorecard with A-F grades per area |
|
||||
| `/config-audit feature-gap` | Deep analysis of features you're not using |
|
||||
| `/config-audit fix` | Auto-fix deterministic issues with backup |
|
||||
| `/config-audit rollback` | Restore configuration from a backup |
|
||||
|
||||
### Planning & Implementation
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `/config-audit plan` | Generate prioritized action plan from audit findings |
|
||||
| `/config-audit implement` | Execute action plan with automatic backup + verification |
|
||||
| `/config-audit interview` | Set preferences to customize the action plan _(optional)_ |
|
||||
|
||||
### Monitoring
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `/config-audit drift` | Compare current config against a saved baseline |
|
||||
| `/config-audit plugin-health` | Audit plugin structure and frontmatter quality |
|
||||
|
||||
### Utility
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `/config-audit status` | Show current session state and progress |
|
||||
| `/config-audit cleanup` | Clean up old session directories |
|
||||
|
||||
### Advanced (workflow phases)
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `/config-audit discover` | Run only the discovery phase (find config files) |
|
||||
| `/config-audit analyze` | Run only the analysis phase (generate report) |
|
||||
|
||||
## Scope Override
|
||||
|
||||
By default, `/config-audit` auto-detects scope from your current directory:
|
||||
- Inside a git repo → scans the repo
|
||||
- In `$HOME` → scans global config only
|
||||
- Elsewhere → scans current directory
|
||||
|
||||
Override with: `/config-audit current`, `/config-audit repo`, `/config-audit home`, `/config-audit full`
|
||||
|
||||
## Typical Workflows
|
||||
|
||||
**First time?** Just run `/config-audit`.
|
||||
|
||||
**Want to fix things?** Run `/config-audit` then `/config-audit fix`.
|
||||
|
||||
**Full optimization:**
|
||||
1. `/config-audit` — see what you have
|
||||
2. `/config-audit plan` — create action plan
|
||||
3. `/config-audit implement` — execute with backups
|
||||
|
||||
**Track changes over time:**
|
||||
1. `/config-audit drift --save` — save baseline
|
||||
2. _(make changes)_
|
||||
3. `/config-audit drift` — see what changed
|
||||
132
plugins/config-audit/commands/implement.md
Normal file
132
plugins/config-audit/commands/implement.md
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
---
|
||||
name: config-audit:implement
|
||||
description: Phase 5 - Execute action plan with backups and verification
|
||||
allowed-tools: Read, Write, Edit, Bash, Agent, AskUserQuestion
|
||||
model: opus
|
||||
---
|
||||
|
||||
# Config-Audit: Implementation (Phase 5)
|
||||
|
||||
Execute the action plan with full backup, verification, and rollback support.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Must have completed Phase 4 (plan)
|
||||
- Action plan at `~/.claude/config-audit/sessions/{session-id}/action-plan.md`
|
||||
|
||||
## Implementation
|
||||
|
||||
### Step 1: Load and verify
|
||||
|
||||
Find the most recent session with a plan. If none: "No action plan found. Run `/config-audit plan` first."
|
||||
|
||||
Read the action plan and count actions. Tell the user:
|
||||
|
||||
```
|
||||
## Implementing Action Plan
|
||||
|
||||
Found {N} actions to execute across {M} files.
|
||||
A backup will be created before any changes are made.
|
||||
```
|
||||
|
||||
### Step 2: Get user approval
|
||||
|
||||
```
|
||||
AskUserQuestion:
|
||||
question: "Ready to implement {N} actions? Backup created automatically — you can roll back with one command."
|
||||
options:
|
||||
- "Yes, proceed"
|
||||
- "Review plan first" (then show the plan file path)
|
||||
- "Cancel"
|
||||
```
|
||||
|
||||
### Step 3: Create backup
|
||||
|
||||
Create backup silently:
|
||||
|
||||
```bash
|
||||
mkdir -p ~/.claude/config-audit/backups/$(date +%Y%m%d_%H%M%S)/files/ 2>/dev/null
|
||||
```
|
||||
|
||||
Copy each file to be modified. Generate `manifest.yaml` with checksums.
|
||||
|
||||
Tell the user: **"Backup created. Implementing actions..."**
|
||||
|
||||
### Step 4: Execute actions
|
||||
|
||||
Group actions by dependencies. For each group, spawn implementer agents (batch of 3):
|
||||
|
||||
```
|
||||
Agent(subagent_type: "config-audit:implementer-agent")
|
||||
model: sonnet
|
||||
prompt: |
|
||||
Execute action: {action-id}
|
||||
File: {file-path}, Type: {create|modify|delete}
|
||||
Details: {changes}
|
||||
Verify backup exists, make change, validate syntax.
|
||||
Append result to: ~/.claude/config-audit/sessions/{session-id}/implementation-log.md
|
||||
```
|
||||
|
||||
Show progress between groups:
|
||||
|
||||
```
|
||||
Action 1/N: {title} — done
|
||||
Action 2/N: {title} — done
|
||||
...
|
||||
```
|
||||
|
||||
### Step 5: Verify results
|
||||
|
||||
Spawn verifier agent:
|
||||
|
||||
```
|
||||
Agent(subagent_type: "config-audit:verifier-agent")
|
||||
model: sonnet (note: using sonnet, not haiku)
|
||||
prompt: |
|
||||
Verify all changes from implementation:
|
||||
1. Modified files exist and are syntactically valid
|
||||
2. New files created correctly
|
||||
3. No new conflicts introduced
|
||||
Report to: ~/.claude/config-audit/sessions/{session-id}/implementation-log.md
|
||||
```
|
||||
|
||||
If verifier finds issues: one retry with implementer agent. If still failing: report and suggest rollback.
|
||||
|
||||
### Step 6: Present results
|
||||
|
||||
```markdown
|
||||
### Implementation Complete
|
||||
|
||||
**{succeeded} succeeded** | {failed} failed | {skipped} skipped
|
||||
|
||||
{If score improved, run quick posture and show:}
|
||||
Score impact: {old_grade} → {new_grade} (+{delta} points)
|
||||
|
||||
{If failed > 0:}
|
||||
{failed} action(s) couldn't be completed — see log for details.
|
||||
|
||||
**Backup location:** `~/.claude/config-audit/backups/{timestamp}/`
|
||||
**Rollback:** `/config-audit rollback {timestamp}`
|
||||
**Full log:** `~/.claude/config-audit/sessions/{session-id}/implementation-log.md`
|
||||
```
|
||||
|
||||
### Step 7: Update state
|
||||
|
||||
Update `state.yaml` with `current_phase: "implement"`, `next_phase: null`.
|
||||
|
||||
## Rollback
|
||||
|
||||
If the user requests rollback at any point:
|
||||
1. Read `manifest.yaml` from backup
|
||||
2. Restore each file and verify checksums
|
||||
3. Delete newly created files
|
||||
4. Update state to `rolled_back`
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Error | What happens |
|
||||
|-------|-------------|
|
||||
| Permission denied | Skip action, log it, continue with others |
|
||||
| File not found | Skip action, log it, continue |
|
||||
| Invalid syntax after edit | Rollback that single file, log, continue |
|
||||
| Critical failure | Offer full rollback |
|
||||
64
plugins/config-audit/commands/interview.md
Normal file
64
plugins/config-audit/commands/interview.md
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
---
|
||||
name: config-audit:interview
|
||||
description: Phase 3 - Interactive interview to gather user preferences
|
||||
allowed-tools: Read, Write, Edit, AskUserQuestion
|
||||
model: sonnet
|
||||
---
|
||||
|
||||
# Config-Audit: Interview (Phase 3)
|
||||
|
||||
Gather user preferences to inform the action plan.
|
||||
|
||||
## IMPORTANT: Inline Execution Only
|
||||
|
||||
This command runs AskUserQuestion **directly in the main context** — NOT via a Task subagent.
|
||||
AskUserQuestion requires synchronous terminal interaction and does not work when delegated to a Task subagent.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Must have completed Phase 2 (analysis)
|
||||
- Read analysis from `~/.claude/config-audit/sessions/{session-id}/analysis-report.md`
|
||||
|
||||
## Implementation Steps
|
||||
|
||||
1. **Load session state**: Verify analysis phase completed, read analysis report for context
|
||||
2. **Conduct interview inline**: Use AskUserQuestion tool directly (NOT via Task). Adapt questions based on analysis findings.
|
||||
3. **Save interview results**: Write to `~/.claude/config-audit/sessions/{session-id}/interview.md`
|
||||
4. **Update state** (see state-management rule)
|
||||
5. **Output summary**
|
||||
|
||||
## Interview Questions
|
||||
|
||||
Ask these using AskUserQuestion (skip questions that don't apply based on analysis):
|
||||
|
||||
1. **Config Style** — Centralized vs Distributed vs Hybrid organization
|
||||
2. **Unused Hooks** — Wire up, review individually, delete, or leave (only if found)
|
||||
3. **Duplicate Permissions** — Remove from local, consolidate, or keep (only if found)
|
||||
4. **Modular Rules** — Use .claude/rules/ pattern? Yes/No
|
||||
5. **Path-Scoped Rules** — Which patterns (tests, src, config, docs) — only if Q4=Yes
|
||||
6. **Conflict Resolution** — Per-conflict: global vs project vs custom value (only if conflicts found)
|
||||
7. **Permission Audit** — Audit or keep (only if >30 patterns in settings.local.json)
|
||||
8. **Project Inheritance** — Per-project: inherit or isolate (only if multiple projects)
|
||||
|
||||
## Adaptive Questioning
|
||||
|
||||
Skip questions that don't apply:
|
||||
- No unused hooks question if all hooks are wired
|
||||
- No duplicates question if no duplicates found
|
||||
- No conflict questions if no conflicts detected
|
||||
- No path-scoping if user said no to modular rules
|
||||
- Fewer project questions if only one project
|
||||
- No permission audit if <30 patterns
|
||||
|
||||
## Skip Interview Option
|
||||
|
||||
If user runs `/config-audit plan` without interview:
|
||||
- Use sensible defaults (centralized, inherit, enable rules)
|
||||
- Flag decisions in plan as "assumed"
|
||||
|
||||
## Error Handling
|
||||
|
||||
- If user selects "Other" for any question, ask follow-up with AskUserQuestion
|
||||
- If interview is cancelled, save partial results
|
||||
- If no analysis report found, report error and exit
|
||||
- If AskUserQuestion fails, STOP — do not use alternative methods
|
||||
82
plugins/config-audit/commands/plan.md
Normal file
82
plugins/config-audit/commands/plan.md
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
---
|
||||
name: config-audit:plan
|
||||
description: Phase 4 - Generate prioritized action plan with risk assessment
|
||||
allowed-tools: Read, Write, Glob, Grep, Agent
|
||||
model: opus
|
||||
---
|
||||
|
||||
# Config-Audit: Plan Generation (Phase 4)
|
||||
|
||||
Generate a prioritized action plan based on analysis results.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Must have completed Phase 2 (analysis)
|
||||
- Phase 3 (interview) is optional — plan works with or without it
|
||||
|
||||
## Implementation
|
||||
|
||||
### Step 1: Verify session state
|
||||
|
||||
Find the most recent session with analysis completed. If none found: "No analysis results found. Run `/config-audit` first to scan your configuration."
|
||||
|
||||
### Step 2: Tell the user what's happening
|
||||
|
||||
```
|
||||
## Creating Action Plan
|
||||
|
||||
Building a prioritized plan based on your analysis results...
|
||||
Actions are ordered by impact, with risk assessment and dependency tracking.
|
||||
```
|
||||
|
||||
### Step 3: Spawn planner agent
|
||||
|
||||
Tell the user: **"Generating your action plan (this takes about 30 seconds)..."**
|
||||
|
||||
```
|
||||
Agent(subagent_type: "config-audit:planner-agent")
|
||||
model: opus
|
||||
prompt: |
|
||||
Generate action plan based on:
|
||||
- Analysis: ~/.claude/config-audit/sessions/{session-id}/analysis-report.md
|
||||
- Interview: ~/.claude/config-audit/sessions/{session-id}/interview.md (if exists)
|
||||
Create prioritized plan with:
|
||||
- Risk assessment per action (low/medium/high)
|
||||
- Rollback strategy
|
||||
- Dependency ordering
|
||||
- Effort estimates
|
||||
Output to: ~/.claude/config-audit/sessions/{session-id}/action-plan.md
|
||||
```
|
||||
|
||||
### Step 4: Present the plan summary
|
||||
|
||||
Read the generated plan and show a concise overview:
|
||||
|
||||
```markdown
|
||||
### Action Plan Ready
|
||||
|
||||
**{N} actions** organized by priority:
|
||||
|
||||
| # | Action | Risk | Effort |
|
||||
|---|--------|------|--------|
|
||||
| 1 | {title} | {low/med/high} | {quick/moderate/involved} |
|
||||
| 2 | ... | ... | ... |
|
||||
| ... | ... | ... | ... |
|
||||
|
||||
Full plan: `~/.claude/config-audit/sessions/{session-id}/action-plan.md`
|
||||
|
||||
You can edit the plan file to remove, reorder, or modify actions before implementing.
|
||||
|
||||
### What's next
|
||||
|
||||
- **`/config-audit implement`** — Execute the plan with automatic backup and verification
|
||||
- **`/config-audit interview`** — Set preferences first to customize the plan (optional)
|
||||
```
|
||||
|
||||
### Step 5: Update state
|
||||
|
||||
Update `state.yaml` with `current_phase: "plan"`, `next_phase: "implement"`.
|
||||
|
||||
## Plan Modification
|
||||
|
||||
Users can edit `action-plan.md` before implementation — remove unwanted actions, adjust priority, or add custom actions. The implementer parses the modified plan.
|
||||
74
plugins/config-audit/commands/plugin-health.md
Normal file
74
plugins/config-audit/commands/plugin-health.md
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
---
|
||||
name: config-audit:plugin-health
|
||||
description: Audit plugin configuration quality — validates structure, frontmatter, and cross-plugin coherence
|
||||
argument-hint: "[plugin-path]"
|
||||
allowed-tools: Read, Glob, Grep, Bash
|
||||
model: sonnet
|
||||
---
|
||||
|
||||
# Config-Audit: Plugin Health
|
||||
|
||||
Audit Claude Code plugin structure and quality — validates plugin.json, CLAUDE.md, command/agent frontmatter, and detects cross-plugin conflicts.
|
||||
|
||||
## Arguments
|
||||
|
||||
- `$ARGUMENTS` may contain a path to a specific plugin directory
|
||||
- If omitted: scans all plugins in the marketplace root
|
||||
|
||||
## Implementation
|
||||
|
||||
### Step 1: Discover plugins and greet
|
||||
|
||||
If a specific path is given, scan only that plugin. Otherwise, find all plugins using Glob for `**/.claude-plugin/plugin.json`.
|
||||
|
||||
Tell the user:
|
||||
|
||||
```
|
||||
## Plugin Health Check
|
||||
|
||||
Auditing {N} plugin(s) for structure, frontmatter quality, and cross-plugin conflicts...
|
||||
```
|
||||
|
||||
### Step 2: Run scanner
|
||||
|
||||
Run silently for each plugin:
|
||||
|
||||
```bash
|
||||
node ${CLAUDE_PLUGIN_ROOT}/scanners/plugin-health-scanner.mjs <path> 2>/dev/null
|
||||
```
|
||||
|
||||
Read stdout output (JSON). Parse findings.
|
||||
|
||||
### Step 3: Present results
|
||||
|
||||
```markdown
|
||||
### Plugin Health Report
|
||||
|
||||
| Plugin | Grade | Commands | Agents | Status |
|
||||
|--------|-------|----------|--------|--------|
|
||||
| {name} | {grade} ({score}) | {cmd_count} | {agent_count} | {Good/Issues found} |
|
||||
| ... | ... | ... | ... | ... |
|
||||
|
||||
{If cross-plugin issues:}
|
||||
#### Cross-Plugin Issues ({count})
|
||||
| Issue | Plugins | Recommendation |
|
||||
|-------|---------|----------------|
|
||||
| ... | ... | ... |
|
||||
|
||||
{If findings:}
|
||||
#### Findings by Plugin
|
||||
|
||||
**{plugin-name}** ({finding_count} findings):
|
||||
1. [{id}] {title} — {recommendation}
|
||||
2. ...
|
||||
```
|
||||
|
||||
### Step 4: Suggest next steps
|
||||
|
||||
```
|
||||
### What's next
|
||||
|
||||
- Fix structural issues based on recommendations above
|
||||
- `/config-audit posture` — Full configuration posture assessment
|
||||
- `/config-audit fix` — Auto-fix deterministic issues
|
||||
```
|
||||
120
plugins/config-audit/commands/posture.md
Normal file
120
plugins/config-audit/commands/posture.md
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
---
|
||||
name: config-audit:posture
|
||||
description: Quick configuration health assessment — scorecard with A-F grades
|
||||
argument-hint: "[path] [--drift] [--plugin-health]"
|
||||
allowed-tools: Read, Write, Glob, Grep, Bash
|
||||
model: sonnet
|
||||
---
|
||||
|
||||
# Config-Audit: Health Assessment
|
||||
|
||||
Quick, deterministic configuration health scorecard. No agents needed — runs all scanners + scoring in one pass.
|
||||
|
||||
## What the user gets
|
||||
|
||||
- Health grade (A-F) with plain-language explanation
|
||||
- Per-area breakdown for 7 quality areas with grades and actionable notes
|
||||
- Opportunity count — how many features could enhance their setup (not a grade)
|
||||
- Grade-appropriate next steps
|
||||
|
||||
## Implementation
|
||||
|
||||
### Step 1: Determine target
|
||||
|
||||
Parse `$ARGUMENTS` for a path (default: current working directory). Resolve relative paths.
|
||||
|
||||
Tell the user:
|
||||
|
||||
```
|
||||
## Configuration Health
|
||||
|
||||
Running quick assessment{if path != cwd: " on `{path}`"}...
|
||||
```
|
||||
|
||||
### Step 2: Run posture scanner
|
||||
|
||||
Run silently — all output goes to a file:
|
||||
|
||||
```bash
|
||||
node ${CLAUDE_PLUGIN_ROOT}/scanners/posture.mjs <target-path> --json --output-file /tmp/config-audit-posture-$$.json 2>/dev/null; echo $?
|
||||
```
|
||||
|
||||
If exit code is non-zero, tell the user: "Assessment couldn't complete. Check that the path exists and contains Claude Code configuration files."
|
||||
|
||||
### Step 3: Read and interpret results
|
||||
|
||||
Read the JSON output file using the Read tool. Extract:
|
||||
|
||||
- `overallGrade`, `opportunityCount`
|
||||
- `areas[]` — each with `name`, `grade`, `score`, `findingCount`
|
||||
|
||||
### Step 4: Present the scorecard
|
||||
|
||||
```markdown
|
||||
**Health: {overallGrade}** | {qualityAreaCount} areas scanned
|
||||
|
||||
{grade-based context — pick ONE:}
|
||||
- A: "Your configuration is correct and well-maintained."
|
||||
- B: "Solid configuration with minor improvements available."
|
||||
- C: "Working configuration with some issues worth addressing."
|
||||
- D: "Configuration needs attention in several areas."
|
||||
- F: "Significant issues found — addressing these will improve your experience."
|
||||
|
||||
### Area Scores
|
||||
|
||||
| Area | Grade | Score | Findings | |
|
||||
|------|-------|-------|----------|-|
|
||||
{for each area EXCEPT Feature Coverage:}
|
||||
| {name} | {grade} | {score}/100 | {findingCount} | {plain-language note: A="Excellent", B="Good", C="Needs work", D/F="Issues found"} |
|
||||
|
||||
{if opportunityCount > 0:}
|
||||
{opportunityCount} feature opportunities available — run `/config-audit feature-gap` for context-aware recommendations.
|
||||
|
||||
### What's next
|
||||
```
|
||||
|
||||
**Grade A or B:**
|
||||
```
|
||||
Your configuration health is strong. Re-run after major changes to catch regressions.
|
||||
For feature recommendations: `/config-audit feature-gap`
|
||||
```
|
||||
|
||||
**Grade C:**
|
||||
```
|
||||
Run `/config-audit fix` to auto-fix what's possible, then `/config-audit plan` for a prioritized improvement path.
|
||||
```
|
||||
|
||||
**Grade D or F:**
|
||||
```
|
||||
Start with `/config-audit fix` — it handles the most impactful issues automatically with backup and rollback.
|
||||
Then run `/config-audit plan` for a step-by-step path to a better configuration.
|
||||
```
|
||||
|
||||
### Step 5: Optional sections
|
||||
|
||||
**If `--drift` flag is present:**
|
||||
|
||||
Run drift comparison silently:
|
||||
```bash
|
||||
node ${CLAUDE_PLUGIN_ROOT}/scanners/drift-cli.mjs <target-path> 2>/dev/null
|
||||
```
|
||||
|
||||
Read stdout output and append a "Configuration Drift" section showing what changed since the last baseline.
|
||||
|
||||
**If `--plugin-health` flag is present:**
|
||||
|
||||
Run plugin health scanner silently:
|
||||
```bash
|
||||
node ${CLAUDE_PLUGIN_ROOT}/scanners/plugin-health-scanner.mjs <target-path> 2>/dev/null
|
||||
```
|
||||
|
||||
Read stdout output and append a "Plugin Health" section.
|
||||
|
||||
**If both flags:** Use `scanners/lib/report-generator.mjs` to produce a unified markdown report.
|
||||
|
||||
### Step 6: Save to session (if active)
|
||||
|
||||
If a config-audit session exists, save results:
|
||||
```bash
|
||||
node ${CLAUDE_PLUGIN_ROOT}/scanners/posture.mjs <target-path> --json --output-file ~/.claude/config-audit/sessions/<session-id>/posture.json 2>/dev/null
|
||||
```
|
||||
83
plugins/config-audit/commands/rollback.md
Normal file
83
plugins/config-audit/commands/rollback.md
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
---
|
||||
name: config-audit:rollback
|
||||
description: Restore configuration from backup — list available backups or rollback a specific one
|
||||
argument-hint: "[backup-id]"
|
||||
allowed-tools: Read, Write, Glob, Grep, Bash, AskUserQuestion
|
||||
model: sonnet
|
||||
---
|
||||
|
||||
# Config-Audit: Rollback
|
||||
|
||||
Restore configuration files from a previous backup. Without arguments, lists available backups. With a backup ID, restores files from that backup.
|
||||
|
||||
## Arguments
|
||||
|
||||
- `$ARGUMENTS` may contain a backup ID (format: `YYYYMMDD_HHMMSS`)
|
||||
|
||||
## Behavior
|
||||
|
||||
### List mode (no argument)
|
||||
|
||||
List available backups from `~/.claude/config-audit/backups/`:
|
||||
|
||||
```
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
Available Backups
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
1. 20260403_163045 — 3 files (settings.json, hooks.json, typescript.md)
|
||||
2. 20260403_141230 — 1 file (CLAUDE.md)
|
||||
3. 20260402_092015 — 5 files (full audit)
|
||||
|
||||
Usage: /config-audit rollback 20260403_163045
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
```
|
||||
|
||||
Read each backup's `manifest.yaml` to extract file list and timestamps.
|
||||
|
||||
### Restore mode (with backup ID)
|
||||
|
||||
1. Read manifest from `~/.claude/config-audit/backups/{backup-id}/manifest.yaml`
|
||||
2. Show files that will be restored — ask for confirmation:
|
||||
```
|
||||
AskUserQuestion:
|
||||
question: "Restore 3 files from backup 20260403_163045?"
|
||||
options:
|
||||
- "Yes, restore"
|
||||
- "Cancel"
|
||||
```
|
||||
3. For each file in manifest:
|
||||
a. Read backup file from `~/.claude/config-audit/backups/{backup-id}/files/{safeName}`
|
||||
b. Write to original path
|
||||
c. Verify checksum matches manifest
|
||||
4. Show result:
|
||||
```
|
||||
Restored 3 files from backup 20260403_163045
|
||||
- .claude/settings.json (checksum verified)
|
||||
- hooks/hooks.json (checksum verified)
|
||||
- .claude/rules/typescript.md (checksum verified)
|
||||
```
|
||||
|
||||
### Delete mode
|
||||
|
||||
If user says "delete" after listing, confirm and remove the backup directory.
|
||||
|
||||
## Implementation
|
||||
|
||||
Use the backup and rollback libraries directly:
|
||||
```javascript
|
||||
import { listBackups, restoreBackup, deleteBackup } from '../scanners/rollback-engine.mjs';
|
||||
import { parseManifest } from '../scanners/lib/backup.mjs';
|
||||
```
|
||||
|
||||
Or via Bash:
|
||||
```bash
|
||||
# List backups
|
||||
ls -1 ~/.claude/config-audit/backups/
|
||||
|
||||
# Read manifest
|
||||
cat ~/.claude/config-audit/backups/{id}/manifest.yaml
|
||||
|
||||
# Restore (copy back)
|
||||
cp ~/.claude/config-audit/backups/{id}/files/{safeName} {originalPath}
|
||||
```
|
||||
114
plugins/config-audit/commands/status.md
Normal file
114
plugins/config-audit/commands/status.md
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
---
|
||||
name: config-audit:status
|
||||
description: Show current session state and available actions
|
||||
allowed-tools: Read, Glob
|
||||
model: sonnet
|
||||
---
|
||||
|
||||
# Config-Audit: Status
|
||||
|
||||
Display current session state and guide next actions.
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
/config-audit status
|
||||
```
|
||||
|
||||
## Implementation
|
||||
|
||||
1. **Find active session**:
|
||||
```
|
||||
Glob: ~/.claude/config-audit/sessions/*/state.yaml
|
||||
Sort by modification time
|
||||
Use most recent
|
||||
```
|
||||
|
||||
2. **Read session state**:
|
||||
```yaml
|
||||
session_id: "20250126_143022"
|
||||
current_phase: "analyze"
|
||||
completed_phases: ["discover", "analyze"]
|
||||
next_phase: "interview"
|
||||
...
|
||||
```
|
||||
|
||||
3. **Display status**:
|
||||
```
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
Config-Audit Session Status
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
Session: 20250126_143022
|
||||
Started: 2025-01-26 14:30:22
|
||||
|
||||
PHASE PROGRESS
|
||||
──────────────
|
||||
✓ Phase 1: Discover - 15 files found (current directory)
|
||||
✓ Phase 2: Analyze - report generated
|
||||
○ Phase 3: Interview - not started (optional)
|
||||
○ Phase 4: Plan - not started
|
||||
○ Phase 5: Implement - not started
|
||||
|
||||
NEXT ACTION
|
||||
───────────
|
||||
Run: /config-audit interview
|
||||
Or: /config-audit plan (skip interview)
|
||||
|
||||
SESSION FILES
|
||||
─────────────
|
||||
Scope: ~/.claude/config-audit/sessions/20250126_143022/scope.yaml
|
||||
Findings: ~/.claude/config-audit/sessions/20250126_143022/findings/
|
||||
Report: ~/.claude/config-audit/sessions/20250126_143022/analysis-report.md
|
||||
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
```
|
||||
|
||||
4. **If no session found**:
|
||||
```
|
||||
No active config-audit session found.
|
||||
|
||||
Start a new audit with:
|
||||
/config-audit # Full audit with auto-scope
|
||||
/config-audit discover # Discovery phase only
|
||||
```
|
||||
|
||||
## Session Information
|
||||
|
||||
Display based on completed phases:
|
||||
|
||||
| Phase | Info to Display |
|
||||
|-------|-----------------|
|
||||
| scope | Scope type, paths to scan |
|
||||
| discover | Files found count, issues count |
|
||||
| analyze | Conflicts, duplicates, opportunities |
|
||||
| interview | Preferences summary |
|
||||
| plan | Actions count, risk level |
|
||||
| implement | Success/fail counts, backup location |
|
||||
|
||||
## List All Sessions
|
||||
|
||||
With `all` flag:
|
||||
```
|
||||
/config-audit status all
|
||||
```
|
||||
|
||||
Shows:
|
||||
```
|
||||
All config-audit sessions:
|
||||
|
||||
| Session | Phase | Created |
|
||||
|---------|-------|---------|
|
||||
| 20250126_143022 | analyze | 2025-01-26 14:30 |
|
||||
| 20250125_091500 | complete | 2025-01-25 09:15 |
|
||||
| 20250120_160000 | implement | 2025-01-20 16:00 |
|
||||
```
|
||||
|
||||
## Resume Session
|
||||
|
||||
If multiple sessions exist:
|
||||
```
|
||||
/config-audit resume {session-id}
|
||||
```
|
||||
|
||||
Sets that session as active and continues from last phase.
|
||||
Loading…
Add table
Add a link
Reference in a new issue