feat: add Claude Code Plugin (Phase 2 — plugin-modernization)#16
feat: add Claude Code Plugin (Phase 2 — plugin-modernization)#16
Conversation
Comprehensive design for phased migration from shell-script-based architecture to native Claude Code Plugin. Covers 4 phases: - Phase 1: Bug fixes (manifest commit, search index CI/CD) - Phase 2: Plugin addition (dual installation path) - Phase 3: Migration nudges for existing users - Phase 4: Pure plugin (shell script removal) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Phase 1 (fix/phase1-bug-fixes): Bug fixes for manifest commit bug, search index generation, issue #15, and hardcoded doc counts. Phase 2 (feat/plugin-modernization): Native Claude Code plugin with /docs command, auto-discoverable Skill, and SessionStart hook. Both plans follow TDD with bite-sized tasks and exact file paths. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Registers the plugin directory at ./plugin for Claude Code's plugin marketplace system.
Defines the claude-docs plugin identity: name, version, description, and component locations for Claude Code's plugin system.
AI-powered documentation lookup using Claude's native Read/Grep/Glob tools. Zero shell or Python dependencies — Claude reads the docs directly from ~/.claude-code-docs/docs/.
The update-docs workflow regenerates paths_manifest.json every 3 hours but only staged docs/ for commit. The manifest at the repo root was never committed, causing it to be stale since Dec 2025. Fix: add paths_manifest.json to the git add command. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude automatically discovers and reads relevant documentation when users ask about Claude Code features, API usage, Agent SDK, etc. Uses native Read/Grep/Glob tools — zero dependencies.
On each session start, the hook: 1. Clones ~/.claude-code-docs/ if it doesn't exist (first run) 2. Runs git pull if it does exist (subsequent runs) 3. Reports doc count via SessionStart additionalContext Uses CLAUDE_PLUGIN_ROOT for portable script paths. Timeout of 15s ensures session start isn't blocked by network issues.
Plugin install is now the primary method. Script install (curl | bash) remains as legacy for environments without plugin support. Both methods use ~/.claude-code-docs/ for documentation storage.
|
hello world test |
|
Deleting test - please ignore |
PR Review: feat: add Claude Code Plugin (Phase 2)Great overall direction. The two-layer separation (plugin logic vs. doc data) is well-conceived, and the phased migration approach is the right call for 338+ active users. Here is detailed feedback: What is Good
Bugs1. JSON injection risk in sync-docs.sh output_context() The msg argument is interpolated directly into a JSON heredoc. Current call sites use hardcoded strings so nothing breaks today. But if msg ever contains a double-quote or newline (e.g., from a dynamic git log entry in a future version), the output will be malformed JSON. Low severity now, worth hardening before Phase 3. 2. Source URL mapping in SKILL.md is incorrect for Agent SDK SKILL.md states that files starting with en__ point to platform.claude.com. But Agent SDK files are stored as docs__en__agent-sdk__overview.md (with a docs__ prefix, confirmed by paths_manifest.json). The docs__ prefix is shared between Claude Code CLI docs AND Agent SDK docs, so filename prefix alone does not distinguish them. Claude will generate incorrect source URLs for Agent SDK topics. 3. TOPIC variable not substituted in commands/docs.md The instruction to glob with dollar-sign-TOPIC as a variable will not work because TOPIC is not a Claude Code substitution variable - only ARGUMENTS is. This should be rephrased as natural language: find files whose names contain the topic keyword. 4. Uninstall command references the wrong path for plugin users In commands/docs.md, the uninstall instruction references rm ~/.claude/commands/docs.md. Plugin users do not have this file - that is the legacy install artifact. The uninstall instruction should only reference rm -rf ~/.claude-code-docs plus a note to use the native plugin uninstall mechanism. Issues5. CLAUDE_PLUGIN_ROOT - is this env var guaranteed by the plugin runtime? hooks.json references this env var for the sync-docs.sh path. This variable does not appear in Claude Code publicly documented hooks spec. If it is not set by the plugin runtime, the hook silently fails on every session start. Worth verifying against the actual spec before merge. 6. manifest-reference.md file pattern table is inaccurate The table maps core_documentation to en__docs__build-with-claude__star.md, but those paths in paths_manifest.json produce files named docs__en__build-with-claude__star.md (with docs__ prefix, not en__). Agent SDK has the same discrepancy. Since this reference file is read by the Skill during searches, incorrect patterns will cause Claude to miss documentation. 7. git pull --dry-run does not check remote state In commands/docs.md for the freshness check, git pull --dry-run replays the local merge step only - it does not fetch from the remote or report pending remote changes. It will always say Already up to date regardless of actual remote state. The correct approach is git fetch followed by git log HEAD..origin/main --oneline. 8. Missing set -u in sync-docs.sh Every other shell script in this repo uses set -euo pipefail. Skipping -e for a SessionStart hook is intentional and correct - network failures should not crash the session. But adding set -u alone would catch typos silently expanding to empty strings. Minor Notes9. Plan files in docs/plans/ Three detailed AI-generated planning documents are committed into the live docs tree. Consider moving to docs/internal/ or GitHub wiki. 10. CLAUDE.md still references v0.5.0 Expected for phased migration, but a short note acknowledging the plugin path (v0.6.0) would help new contributors understand current architecture state. 11. No plugin structure validation in tests The new integration test validates CI/CD staging. Lightweight test additions could validate plugin artifacts exist and have valid JSON, and that sync-docs.sh is executable. SummaryThree bugs need attention before merge:
The JSON injection in output_context() is low-risk today but worth noting for Phase 3. The CI/CD fix for paths_manifest.json staging is a standalone valuable change that should ship regardless of the plugin work. |
|
Closing — will reopen after Phase 1 merges with clean commit messages. |
Summary
New Files
.claude-plugin/marketplace.json— marketplace registrationplugin/.claude-plugin/plugin.json— plugin metadataplugin/commands/docs.md— /docs slash command (plugin version)plugin/skills/claude-docs/SKILL.md— auto-discoverable documentation Skillplugin/skills/claude-docs/manifest-reference.md— category referenceplugin/hooks/hooks.json— SessionStart hook configplugin/hooks/sync-docs.sh— git clone/pull scriptModified Files
README.md— plugin install as recommended method, script install as legacyTest plan