Skip to content

Commit a76a221

Browse files
TechNickAINick Sullivanclaude
authored
✨ Add /ai-coding-config doctor diagnostic subcommand (#56)
* ✨ Add /ai-coding-config doctor diagnostic subcommand Extends /ai-coding-config with a doctor mode that runs a battery of health checks and reports as a ✅/⚠️/❌ checklist: - Plugin install state (marketplace registered, cache present, enabled) - Symlink integrity (.claude/commands → plugins/core/*, rules/ → .cursor/rules/) - Hook script health (executable, valid shebang, registered in settings) - Settings JSON validity - Marketplace JSON consistency (version parity across all three locations) - Version drift (local command file vs source repo) - Skill frontmatter (name/description/triggers present, next-skill targets exist) Context-aware: detects source-repo vs user-project and skips inapplicable checks. Auto-fixes hook permissions only (with confirmation). All other issues report with suggested fix commands. Fixes #53 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * 🐛 Fix five multi-review issues in ai-coding-config doctor - Source repo not found is informational (ℹ️), not a warning — normal for plugin-only users - Remove wrong user-project skill glob path (plugin cache uses flat .md, not SKILL.md dirs) - Fix summary count: 1 warning → 2 warnings in example output - Put failures first in summary line (❌ before ⚠️ before ✅) - Add all-green closing line to output-format guidance Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * 🐛 Address Claude bot review on PR #56 - Fix auto-fix example to use todo-persist.sh (matches output-format example) - Replace relative ls -la bash examples with $(pwd)-anchored absolute paths and Glob/Read tool instructions, matching file's own best practices - Clarify next-skill resolution: directory name first (fast path), fall back to scanning name fields, also checks .claude/commands/ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * 🐛 Fix hook checks for user-project context and missing settings fallback - Hook script file checks now scoped to source-repo only; user-project context checks hooks registration in settings instead of script files - auto-fix chmod also scoped to source-repo only context - Settings check now reads .claude/settings.json if present, falls back to ~/.claude/settings.json for projects using only global settings Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * 🐛 Address latest Claude bot review on PR #56 - Add sync comment noting Plugin Install State mirrors <marketplace-doctor> - Add explicit file-not-found case for known_marketplaces.json - Add stability: experimental rule to Skill Frontmatter checks (was in example but not in spec) - Add Mode Routing section for unrecognized-argument fallback (enter setup mode, mention available subcommands) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Nick Sullivan <nick@technick.ai> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 1c81e67 commit a76a221

1 file changed

Lines changed: 203 additions & 2 deletions

File tree

plugins/core/commands/ai-coding-config.md

Lines changed: 203 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
# prettier-ignore
33
description: "Set up or update AI coding configurations - interactive setup for Claude Code, Cursor, and other AI coding tools"
4-
argument-hint: "[update]"
5-
version: 4.1.1
4+
argument-hint: "[update|doctor]"
5+
version: 4.2.0
66
---
77

88
# AI Coding Configuration
@@ -14,6 +14,15 @@ tools. The marketplace lives at `https://github.com/TechNickAI/ai-coding-config`
1414

1515
- `/ai-coding-config` - Interactive setup for current project
1616
- `/ai-coding-config update` - Update plugins and configs to latest versions
17+
- `/ai-coding-config doctor` - Diagnose plugin health, hook state, and config drift
18+
19+
## Mode Routing
20+
21+
- No argument → setup mode
22+
- `update` → update mode
23+
- `doctor` → doctor mode
24+
- Unrecognized argument (typo, unknown subcommand) → setup mode; mention available
25+
subcommands (`update`, `doctor`) at the start of output
1726

1827
## Interaction Guidelines
1928

@@ -524,6 +533,198 @@ If nothing changed (already up to date, no reset needed), skip the restart messa
524533

525534
---
526535

536+
<doctor-mode>
537+
538+
<objective>
539+
Run a diagnostic battery and report as a ✅ / ⚠️ / ❌ checklist. Group by category.
540+
End with a suggested-fixes section. Read-only except for hook permission repair (safe,
541+
reversible, no content change). Print each category header as you complete that group of
542+
checks so the user sees progress — don't collect everything silently before reporting.
543+
</objective>
544+
545+
<context-detection>
546+
Determine environment before running checks:
547+
548+
- **Source repo**: `plugins/core/` directory exists at cwd. Run all checks including
549+
symlink and plugin JSON consistency checks.
550+
- **User project**: `plugins/core/` absent. Skip source-repo checks; focus on plugin
551+
install state, settings, and hooks.
552+
553+
Report which context was detected at the top of output.
554+
</context-detection>
555+
556+
<checks>
557+
558+
### Plugin Install State
559+
560+
These checks mirror the ones in `<marketplace-doctor>` (update-mode). If either section
561+
is updated (e.g., a new settings key), keep both in sync.
562+
563+
Read `~/.claude/plugins/known_marketplaces.json` with the Read tool:
564+
- ✅ ai-coding-config marketplace entry present
565+
- ❌ File not found → marketplace never initialized; suggest `/plugin marketplace add https://github.com/TechNickAI/ai-coding-config`
566+
- ❌ File exists but ai-coding-config entry missing → suggest `/plugin marketplace add https://github.com/TechNickAI/ai-coding-config`
567+
568+
Check `~/.claude/plugins/cache/ai-coding-config/` for plugin content using Glob:
569+
- ✅ Cache directory exists with agents, commands, and skills subdirectories
570+
- ❌ Cache missing or empty → suggest `/plugin install ai-coding-config`
571+
572+
Read `~/.claude/settings.json` and check for plugin enablement:
573+
- ✅ ai-coding-config appears in plugins/enabled list
574+
- ⚠️ Not listed → plugin may be disabled; run `/plugin` to check status
575+
576+
### Symlinks (source repo only)
577+
578+
For each directory: `.claude/commands`, `.claude/agents`, `.claude/skills`:
579+
580+
Use Bash with absolute paths anchored to `$(pwd)`:
581+
582+
```bash
583+
ls -la "$(pwd)/.claude/commands" "$(pwd)/.claude/agents" "$(pwd)/.claude/skills"
584+
```
585+
586+
- ✅ Each is a symlink pointing to the corresponding `plugins/core/` subdirectory
587+
- ❌ Missing, not a symlink, or wrong target → note the broken symlink
588+
589+
Check `rules/``.cursor/rules/`:
590+
591+
```bash
592+
ls -la "$(pwd)/rules"
593+
```
594+
595+
-`rules` is a symlink to `.cursor/rules`
596+
- ❌ Missing or wrong → `ln -s .cursor/rules rules`
597+
598+
### Hook Scripts
599+
600+
**Source repo:** Read `plugins/core/hooks/hooks.json` with the Read tool to get
601+
declared hooks. Use Glob to list `plugins/core/hooks/*.sh`, then check each file:
602+
603+
- ✅ File exists, executable (`-x`), and first line is `#!/bin/bash`
604+
- ⚠️ Exists but not executable → offer to auto-fix: `chmod +x <path>`
605+
- ❌ File missing → note as broken
606+
607+
**User project:** Hook script files are managed by the plugin cache — skip the script
608+
file checks. Instead, verify hooks are registered in settings (see below).
609+
610+
Check that hooks are registered in project or global settings. Read `.claude/settings.json`
611+
if it exists; otherwise fall back to `~/.claude/settings.json`:
612+
613+
- ✅ Settings file parses as valid JSON and contains hook entries
614+
- ⚠️ Valid JSON but no hooks registered → hooks won't fire; suggest running `/ai-coding-config update`
615+
- ❌ Invalid JSON → note the parse error
616+
- ℹ️ No local `.claude/settings.json` and global settings has no hooks → hooks rely on plugin marketplace loading
617+
618+
### Marketplace JSON Consistency (source repo only)
619+
620+
Read both `.claude-plugin/marketplace.json` and `plugins/core/.claude-plugin/plugin.json`:
621+
- ✅ Both parse as valid JSON
622+
-`metadata.version` == `plugins[0].version` == `plugin.json version`
623+
- ⚠️ Version mismatch → "Bump all three per `.claude-plugin/CLAUDE.md`"
624+
625+
### Version Drift
626+
627+
Compare installed command version vs source repo version. Read the `version` field from
628+
the YAML frontmatter of:
629+
630+
1. This command file (currently executing)
631+
2. `~/.ai_coding_config/plugins/core/commands/ai-coding-config.md` (source, if it exists)
632+
633+
- ✅ Versions match
634+
- ⚠️ Source is newer → suggest `/ai-coding-config update`
635+
- ℹ️ Source repo not found at `~/.ai_coding_config` — normal for plugin-only users (no action needed)
636+
637+
### Skill Frontmatter
638+
639+
Use Glob to list `plugins/core/skills/*/SKILL.md` (source repo only — the plugin cache
640+
uses flat `.md` files without subdirectories, so this check applies only in the source
641+
repo context).
642+
643+
For each SKILL.md, read and verify:
644+
- ✅ File has `---` YAML frontmatter block
645+
-`name`, `description`, and `triggers` fields present
646+
- ⚠️ Missing `triggers` → skill won't auto-activate on natural language
647+
- If `next-skill` declared: check by directory name first (fast path — the directory
648+
name should match the skill name); if not found, fall back to scanning `name` fields
649+
in each SKILL.md. Also check `.claude/commands/` for commands. ✅ target found,
650+
⚠️ target not found anywhere
651+
- If `stability: experimental` declared: ℹ️ note as informational (expected for new or
652+
actively-changing skills — not a problem, just surfaced for awareness)
653+
654+
Report a single summary line per skill (not per field) to keep output scannable.
655+
656+
</checks>
657+
658+
<auto-fix>
659+
Hook permissions are the only thing doctor auto-fixes (with user confirmation), and
660+
only in source-repo context where the script files are present:
661+
662+
"⚠️ todo-persist.sh is not executable. Fix now? [y/N]"
663+
664+
If yes: `chmod +x plugins/core/hooks/todo-persist.sh`
665+
666+
For all other issues, report and direct to the appropriate fix command. Don't modify
667+
JSON files, settings, or symlinks without explicit user instruction.
668+
</auto-fix>
669+
670+
<output-format>
671+
Print category headers as the checks complete. Example final output:
672+
673+
```
674+
## ai-coding-config doctor
675+
676+
Context: source repo (plugins/core/ detected)
677+
678+
### Plugin Install State
679+
✅ Marketplace registered (ai-coding-config v9.21.0)
680+
✅ Plugin cache present
681+
✅ Plugin enabled in settings
682+
683+
### Symlinks
684+
✅ .claude/commands → plugins/core/commands
685+
✅ .claude/agents → plugins/core/agents
686+
✅ .claude/skills → plugins/core/skills
687+
❌ rules/ symlink missing
688+
689+
### Hook Scripts
690+
✅ verify-deliverables.sh — executable, valid shebang
691+
⚠️ todo-persist.sh — exists but not executable
692+
693+
### Marketplace JSON Consistency
694+
✅ .claude-plugin/marketplace.json valid JSON
695+
✅ plugins/core/.claude-plugin/plugin.json valid JSON
696+
✅ Versions consistent (9.21.0)
697+
698+
### Version Drift
699+
✅ Command file up to date (v4.2.0)
700+
701+
### Skill Frontmatter
702+
✅ brainstorming — name, description, triggers, next-skill: brainstorm-synthesis (found)
703+
✅ systematic-debugging — name, description, triggers, next-skill: verify-fix (found)
704+
⚠️ mcp-debug — triggers field present, stability: experimental
705+
706+
---
707+
## Summary
708+
1 failure ❌ 2 warnings ⚠️ 11 passed ✅
709+
710+
## Suggested Fixes
711+
❌ rules/ symlink missing:
712+
ln -s .cursor/rules rules
713+
714+
⚠️ todo-persist.sh not executable:
715+
chmod +x plugins/core/hooks/todo-persist.sh
716+
(or confirm above to auto-fix)
717+
```
718+
719+
All-green output ends with: "All checks passed — your setup is healthy."
720+
721+
Keep the summary tight. Users should be able to skim it in 10 seconds.
722+
</output-format>
723+
724+
</doctor-mode>
725+
726+
---
727+
527728
<execution-philosophy>
528729
Work conversationally, not robotically. Focus on outcomes. Determine best approach for each situation. Show file paths when copying. Let users make all choices. Verify everything works before finishing.
529730

0 commit comments

Comments
 (0)