From 9fcde0f6012ec379f16deb6b92b91953700ff028 Mon Sep 17 00:00:00 2001 From: Minsu Lee Date: Thu, 16 Oct 2025 22:44:10 +0900 Subject: [PATCH 1/2] feat: add Claude Code plugin configuration Add Claude Code plugin support with automatic Context7 integration: - Plugin manifest (.claude-plugin/plugin.json) with MCP server config - SessionStart hook to auto-load Context7 usage instructions - Context file with automatic tool usage guidelines - Updated README with Claude Code plugin installation The plugin automatically instructs Claude to use Context7 MCP tools for code generation, setup, and API documentation without explicit user prompts. --- .claude-plugin/plugin.json | 35 +++++++++++++++++++++++++++++++++++ README.md | 18 ++++++++++++++++++ hooks/CONTEXT7.md | 16 ++++++++++++++++ hooks/context.sh | 18 ++++++++++++++++++ hooks/hooks.json | 17 +++++++++++++++++ 5 files changed, 104 insertions(+) create mode 100644 .claude-plugin/plugin.json create mode 100644 hooks/CONTEXT7.md create mode 100755 hooks/context.sh create mode 100644 hooks/hooks.json diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 00000000..2f7486d7 --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,35 @@ +{ + "name": "context7", + "version": "1.0.0", + "description": "Up-to-date documentation and code examples for any library or framework using Context7 MCP server", + "author": { + "name": "Upstash", + "url": "https://github.com/upstash" + }, + "homepage": "https://context7.com", + "repository": "https://github.com/upstash/context7", + "license": "MIT", + "keywords": [ + "documentation", + "code-examples", + "mcp", + "context7", + "vibe-coding", + "library-docs" + ], + "hooks": "./hooks/hooks.json", + "mcpServers": { + "context7": { + "command": "npx", + "args": [ + "-y", + "@upstash/context7-mcp", + "--api-key", + "${CONTEXT7_API_KEY:-}" + ], + "env": { + "CONTEXT7_API_KEY": "${CONTEXT7_API_KEY:-}" + } + } + } +} diff --git a/README.md b/README.md index 39743865..d9496783 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,24 @@ Pasting the following configuration into your Cursor `~/.cursor/mcp.json` file i Run this command. See [Claude Code MCP docs](https://docs.anthropic.com/en/docs/claude-code/mcp) for more info. +#### Claude Code Plugin + +Install as a Claude Code plugin with automatic Context7 integration: + +```sh +claude +/plugin marketplace add pleaseai/claude-code-plugins +/plugin install context7@pleaseai +``` + +This automatically loads Context7 usage instructions on every session start, so Claude will use Context7 MCP tools without you having to ask explicitly. + +Optionally set your API key for higher rate limits: + +```sh +export CONTEXT7_API_KEY="your-api-key" +``` + #### Claude Code Remote Server Connection ```sh diff --git a/hooks/CONTEXT7.md b/hooks/CONTEXT7.md new file mode 100644 index 00000000..14f22582 --- /dev/null +++ b/hooks/CONTEXT7.md @@ -0,0 +1,16 @@ +# Context7 Usage Instructions + +Always use Context7 when I need code generation, setup or configuration steps, or library/API documentation. This means you should automatically use the Context7 MCP tools to resolve library id and get library docs without me having to explicitly ask. + +## When to Use Context7 + +- **Code Generation**: When writing code that uses external libraries or frameworks +- **Setup & Configuration**: When setting up tools, libraries, or frameworks +- **API Documentation**: When you need current API documentation for any library +- **Best Practices**: When you need up-to-date examples and patterns + +## How to Use + +1. Use `resolve-library-id` to find the correct library identifier +2. Use `get-library-docs` to fetch current documentation +3. Apply the documentation context to provide accurate, up-to-date code and guidance diff --git a/hooks/context.sh b/hooks/context.sh new file mode 100755 index 00000000..9924b5bf --- /dev/null +++ b/hooks/context.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Read the Context7 usage instructions +CONTEXT_FILE="${CLAUDE_PLUGIN_ROOT}/hooks/CONTEXT7.md" + +if [ -f "$CONTEXT_FILE" ]; then + # Read the context file content + CONTEXT_CONTENT=$(cat "$CONTEXT_FILE") + + # Output as JSON with additionalContext + jq -n --arg context "$CONTEXT_CONTENT" '{ + "hookSpecificOutput": { + "hookEventName": "SessionStart", + "additionalContext": $context + } + }' +fi diff --git a/hooks/hooks.json b/hooks/hooks.json new file mode 100644 index 00000000..4536ac7d --- /dev/null +++ b/hooks/hooks.json @@ -0,0 +1,17 @@ +{ + "description": "Load Context7 usage instructions at session start", + "hooks": { + "SessionStart": [ + { + "matcher": "startup", + "hooks": [ + { + "type": "command", + "command": "${CLAUDE_PLUGIN_ROOT}/hooks/context.sh", + "timeout": 10 + } + ] + } + ] + } +} From 13f4296f342e177325d007cdce18ad51c2e05062 Mon Sep 17 00:00:00 2001 From: Minsu Lee Date: Fri, 17 Oct 2025 06:09:57 +0900 Subject: [PATCH 2/2] refactor: migrate from SessionStart hook to Skill system Replace SessionStart hook with Claude Code skill for more intelligent and token-efficient Context7 integration. Changes: - Add skills/context7/SKILL.md with intelligent activation patterns - Remove hooks/ directory (hooks.json, context.sh, CONTEXT7.md) - Remove hooks reference from plugin.json - Update README.md with skill-based installation guide Benefits: - Claude automatically activates skill only when needed - Reduces token usage (no constant context loading) - Clearer trigger patterns (library, framework, API docs) - Simpler maintenance (single markdown file vs shell script) The skill triggers automatically when: - Writing code with external libraries - Needing library documentation or API references - Setting up or configuring frameworks - Requesting code examples with specific packages --- .claude-plugin/plugin.json | 1 - README.md | 10 ++++++-- hooks/CONTEXT7.md | 16 ------------- hooks/context.sh | 18 --------------- hooks/hooks.json | 17 -------------- skills/context7/SKILL.md | 47 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 55 insertions(+), 54 deletions(-) delete mode 100644 hooks/CONTEXT7.md delete mode 100755 hooks/context.sh delete mode 100644 hooks/hooks.json create mode 100644 skills/context7/SKILL.md diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index 2f7486d7..2d72a86d 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -17,7 +17,6 @@ "vibe-coding", "library-docs" ], - "hooks": "./hooks/hooks.json", "mcpServers": { "context7": { "command": "npx", diff --git a/README.md b/README.md index d9496783..604159a1 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ Run this command. See [Claude Code MCP docs](https://docs.anthropic.com/en/docs/ #### Claude Code Plugin -Install as a Claude Code plugin with automatic Context7 integration: +Install as a Claude Code plugin with intelligent Context7 integration: ```sh claude @@ -126,7 +126,13 @@ claude /plugin install context7@pleaseai ``` -This automatically loads Context7 usage instructions on every session start, so Claude will use Context7 MCP tools without you having to ask explicitly. +This provides a skill that Claude automatically activates when needed. Claude will intelligently use Context7 MCP tools when working with external libraries, frameworks, or when you need up-to-date documentation - without requiring explicit activation. + +The skill triggers automatically when you: +- Write code using external libraries +- Need library documentation or API references +- Set up or configure frameworks +- Request code examples with specific packages Optionally set your API key for higher rate limits: diff --git a/hooks/CONTEXT7.md b/hooks/CONTEXT7.md deleted file mode 100644 index 14f22582..00000000 --- a/hooks/CONTEXT7.md +++ /dev/null @@ -1,16 +0,0 @@ -# Context7 Usage Instructions - -Always use Context7 when I need code generation, setup or configuration steps, or library/API documentation. This means you should automatically use the Context7 MCP tools to resolve library id and get library docs without me having to explicitly ask. - -## When to Use Context7 - -- **Code Generation**: When writing code that uses external libraries or frameworks -- **Setup & Configuration**: When setting up tools, libraries, or frameworks -- **API Documentation**: When you need current API documentation for any library -- **Best Practices**: When you need up-to-date examples and patterns - -## How to Use - -1. Use `resolve-library-id` to find the correct library identifier -2. Use `get-library-docs` to fetch current documentation -3. Apply the documentation context to provide accurate, up-to-date code and guidance diff --git a/hooks/context.sh b/hooks/context.sh deleted file mode 100755 index 9924b5bf..00000000 --- a/hooks/context.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -# Read the Context7 usage instructions -CONTEXT_FILE="${CLAUDE_PLUGIN_ROOT}/hooks/CONTEXT7.md" - -if [ -f "$CONTEXT_FILE" ]; then - # Read the context file content - CONTEXT_CONTENT=$(cat "$CONTEXT_FILE") - - # Output as JSON with additionalContext - jq -n --arg context "$CONTEXT_CONTENT" '{ - "hookSpecificOutput": { - "hookEventName": "SessionStart", - "additionalContext": $context - } - }' -fi diff --git a/hooks/hooks.json b/hooks/hooks.json deleted file mode 100644 index 4536ac7d..00000000 --- a/hooks/hooks.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "description": "Load Context7 usage instructions at session start", - "hooks": { - "SessionStart": [ - { - "matcher": "startup", - "hooks": [ - { - "type": "command", - "command": "${CLAUDE_PLUGIN_ROOT}/hooks/context.sh", - "timeout": 10 - } - ] - } - ] - } -} diff --git a/skills/context7/SKILL.md b/skills/context7/SKILL.md new file mode 100644 index 00000000..1bf8b8bd --- /dev/null +++ b/skills/context7/SKILL.md @@ -0,0 +1,47 @@ +--- +name: Library Documentation Lookup +description: Fetch up-to-date documentation and code examples for any library or framework using Context7. Use when writing code with external libraries, setting up tools, configuring frameworks, or needing current API documentation. Triggers on mentions of library names, npm packages, framework setup, API docs, or code generation requests. +allowed-tools: mcp__plugin_dev-tools_context7__resolve-library-id, mcp__plugin_dev-tools_context7__get-library-docs +--- + +# Context7 - Library Documentation + +Always use Context7 MCP tools automatically when generating code, performing setup, or needing library documentation. **Do not wait for explicit user requests** - proactively fetch documentation when working with external libraries. + +## When to Use Context7 + +Use Context7 automatically in these scenarios: + +- **Code Generation**: Writing code that uses external libraries or frameworks +- **Setup & Configuration**: Setting up tools, libraries, or frameworks +- **API Documentation**: Needing current API documentation for any library +- **Best Practices**: Finding up-to-date examples and patterns + +## How to Use + +Follow this two-step process: + +### 1. Resolve Library ID +``` +Use mcp__plugin_dev-tools_context7__resolve-library-id +- Pass the library/package name +- Returns Context7-compatible library ID +``` + +### 2. Fetch Documentation +``` +Use mcp__plugin_dev-tools_context7__get-library-docs +- Pass the library ID from step 1 +- Optionally specify a topic to focus on +- Returns current documentation and examples +``` + +### 3. Apply Documentation +Use the fetched documentation to provide accurate, up-to-date code and guidance. + +## Important Notes + +- Context7 works without an API key (with rate limits) +- Set `CONTEXT7_API_KEY` environment variable for higher rate limits +- Always fetch documentation before generating code with external libraries +- Prefer Context7 over relying on training data for library-specific code \ No newline at end of file