From e5cbabbd947c93dc4dbf553fbe086f723d3ef9d2 Mon Sep 17 00:00:00 2001 From: Zhongwei Li Date: Sat, 29 Nov 2025 18:14:51 +0800 Subject: [PATCH] Initial commit --- .claude-plugin/plugin.json | 14 + README.md | 3 + hooks/bun.lock | 58 ++ hooks/claude-code-prompt.ts | 130 ++++ hooks/hooks.json | 28 + hooks/package.json | 13 + hooks/sync-docs-on-skill-load.ts | 709 ++++++++++++++++++ plugin.lock.json | 97 +++ skills/claude-code-knowledge/SKILL.md | 159 ++++ skills/claude-code-knowledge/reference.md | 106 +++ skills/claude-code-knowledge/scripts/bun.lock | 24 + .../scripts/list_topics.ts | 41 + .../scripts/package.json | 9 + .../scripts/skill-creator/init_skill.ts | 301 ++++++++ .../scripts/skill-creator/package_skill.ts | 148 ++++ .../scripts/skill-creator/quick_validate.ts | 104 +++ skills/skill-rules.json | 68 ++ 17 files changed, 2012 insertions(+) create mode 100644 .claude-plugin/plugin.json create mode 100644 README.md create mode 100644 hooks/bun.lock create mode 100755 hooks/claude-code-prompt.ts create mode 100644 hooks/hooks.json create mode 100644 hooks/package.json create mode 100755 hooks/sync-docs-on-skill-load.ts create mode 100644 plugin.lock.json create mode 100644 skills/claude-code-knowledge/SKILL.md create mode 100644 skills/claude-code-knowledge/reference.md create mode 100644 skills/claude-code-knowledge/scripts/bun.lock create mode 100755 skills/claude-code-knowledge/scripts/list_topics.ts create mode 100644 skills/claude-code-knowledge/scripts/package.json create mode 100755 skills/claude-code-knowledge/scripts/skill-creator/init_skill.ts create mode 100755 skills/claude-code-knowledge/scripts/skill-creator/package_skill.ts create mode 100755 skills/claude-code-knowledge/scripts/skill-creator/quick_validate.ts create mode 100644 skills/skill-rules.json diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..f3108a5 --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,14 @@ +{ + "name": "claude-code-knowledge", + "description": "Official Claude Code documentation access. Provides instant reference to hooks, MCP, skills, slash commands, settings, CLI, and all Claude Code features with automatic sync from docs.anthropic.com.", + "version": "1.1.0", + "author": { + "name": "Community" + }, + "skills": [ + "./skills" + ], + "hooks": [ + "./hooks" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..11208e0 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# claude-code-knowledge + +Official Claude Code documentation access. Provides instant reference to hooks, MCP, skills, slash commands, settings, CLI, and all Claude Code features with automatic sync from docs.anthropic.com. diff --git a/hooks/bun.lock b/hooks/bun.lock new file mode 100644 index 0000000..b040845 --- /dev/null +++ b/hooks/bun.lock @@ -0,0 +1,58 @@ +{ + "lockfileVersion": 1, + "workspaces": { + "": { + "name": "claude-code-knowledge-hooks", + "dependencies": { + "fast-xml-parser": "^4.3.2", + }, + "devDependencies": { + "@anthropic-ai/claude-agent-sdk": "^0.1.37", + "@types/bun": "latest", + }, + }, + }, + "packages": { + "@anthropic-ai/claude-agent-sdk": ["@anthropic-ai/claude-agent-sdk@0.1.37", "", { "optionalDependencies": { "@img/sharp-darwin-arm64": "^0.33.5", "@img/sharp-darwin-x64": "^0.33.5", "@img/sharp-linux-arm": "^0.33.5", "@img/sharp-linux-arm64": "^0.33.5", "@img/sharp-linux-x64": "^0.33.5", "@img/sharp-win32-x64": "^0.33.5" }, "peerDependencies": { "zod": "^3.24.1" } }, "sha512-LMfqMIPLTz0vRhpcO7hpPJ5L6Bg24y5/PaqZvwAUNZ/GR3OAl7xmJR7IryIR6m8Pyd/6Hs2yBU8j86Os+wHFQQ=="], + + "@img/sharp-darwin-arm64": ["@img/sharp-darwin-arm64@0.33.5", "", { "optionalDependencies": { "@img/sharp-libvips-darwin-arm64": "1.0.4" }, "os": "darwin", "cpu": "arm64" }, "sha512-UT4p+iz/2H4twwAoLCqfA9UH5pI6DggwKEGuaPy7nCVQ8ZsiY5PIcrRvD1DzuY3qYL07NtIQcWnBSY/heikIFQ=="], + + "@img/sharp-darwin-x64": ["@img/sharp-darwin-x64@0.33.5", "", { "optionalDependencies": { "@img/sharp-libvips-darwin-x64": "1.0.4" }, "os": "darwin", "cpu": "x64" }, "sha512-fyHac4jIc1ANYGRDxtiqelIbdWkIuQaI84Mv45KvGRRxSAa7o7d1ZKAOBaYbnepLC1WqxfpimdeWfvqqSGwR2Q=="], + + "@img/sharp-libvips-darwin-arm64": ["@img/sharp-libvips-darwin-arm64@1.0.4", "", { "os": "darwin", "cpu": "arm64" }, "sha512-XblONe153h0O2zuFfTAbQYAX2JhYmDHeWikp1LM9Hul9gVPjFY427k6dFEcOL72O01QxQsWi761svJ/ev9xEDg=="], + + "@img/sharp-libvips-darwin-x64": ["@img/sharp-libvips-darwin-x64@1.0.4", "", { "os": "darwin", "cpu": "x64" }, "sha512-xnGR8YuZYfJGmWPvmlunFaWJsb9T/AO2ykoP3Fz/0X5XV2aoYBPkX6xqCQvUTKKiLddarLaxpzNe+b1hjeWHAQ=="], + + "@img/sharp-libvips-linux-arm": ["@img/sharp-libvips-linux-arm@1.0.5", "", { "os": "linux", "cpu": "arm" }, "sha512-gvcC4ACAOPRNATg/ov8/MnbxFDJqf/pDePbBnuBDcjsI8PssmjoKMAz4LtLaVi+OnSb5FK/yIOamqDwGmXW32g=="], + + "@img/sharp-libvips-linux-arm64": ["@img/sharp-libvips-linux-arm64@1.0.4", "", { "os": "linux", "cpu": "arm64" }, "sha512-9B+taZ8DlyyqzZQnoeIvDVR/2F4EbMepXMc/NdVbkzsJbzkUjhXv/70GQJ7tdLA4YJgNP25zukcxpX2/SueNrA=="], + + "@img/sharp-libvips-linux-x64": ["@img/sharp-libvips-linux-x64@1.0.4", "", { "os": "linux", "cpu": "x64" }, "sha512-MmWmQ3iPFZr0Iev+BAgVMb3ZyC4KeFc3jFxnNbEPas60e1cIfevbtuyf9nDGIzOaW9PdnDciJm+wFFaTlj5xYw=="], + + "@img/sharp-linux-arm": ["@img/sharp-linux-arm@0.33.5", "", { "optionalDependencies": { "@img/sharp-libvips-linux-arm": "1.0.5" }, "os": "linux", "cpu": "arm" }, "sha512-JTS1eldqZbJxjvKaAkxhZmBqPRGmxgu+qFKSInv8moZ2AmT5Yib3EQ1c6gp493HvrvV8QgdOXdyaIBrhvFhBMQ=="], + + "@img/sharp-linux-arm64": ["@img/sharp-linux-arm64@0.33.5", "", { "optionalDependencies": { "@img/sharp-libvips-linux-arm64": "1.0.4" }, "os": "linux", "cpu": "arm64" }, "sha512-JMVv+AMRyGOHtO1RFBiJy/MBsgz0x4AWrT6QoEVVTyh1E39TrCUpTRI7mx9VksGX4awWASxqCYLCV4wBZHAYxA=="], + + "@img/sharp-linux-x64": ["@img/sharp-linux-x64@0.33.5", "", { "optionalDependencies": { "@img/sharp-libvips-linux-x64": "1.0.4" }, "os": "linux", "cpu": "x64" }, "sha512-opC+Ok5pRNAzuvq1AG0ar+1owsu842/Ab+4qvU879ippJBHvyY5n2mxF1izXqkPYlGuP/M556uh53jRLJmzTWA=="], + + "@img/sharp-win32-x64": ["@img/sharp-win32-x64@0.33.5", "", { "os": "win32", "cpu": "x64" }, "sha512-MpY/o8/8kj+EcnxwvrP4aTJSWw/aZ7JIGR4aBeZkZw5B7/Jn+tY9/VNwtcoGmdT7GfggGIU4kygOMSbYnOrAbg=="], + + "@types/bun": ["@types/bun@1.3.2", "", { "dependencies": { "bun-types": "1.3.2" } }, "sha512-t15P7k5UIgHKkxwnMNkJbWlh/617rkDGEdSsDbu+qNHTaz9SKf7aC8fiIlUdD5RPpH6GEkP0cK7WlvmrEBRtWg=="], + + "@types/node": ["@types/node@24.10.1", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="], + + "@types/react": ["@types/react@19.2.4", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-tBFxBp9Nfyy5rsmefN+WXc1JeW/j2BpBHFdLZbEVfs9wn3E3NRFxwV0pJg8M1qQAexFpvz73hJXFofV0ZAu92A=="], + + "bun-types": ["bun-types@1.3.2", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-i/Gln4tbzKNuxP70OWhJRZz1MRfvqExowP7U6JKoI8cntFrtxg7RJK3jvz7wQW54UuvNC8tbKHHri5fy74FVqg=="], + + "csstype": ["csstype@3.1.3", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="], + + "fast-xml-parser": ["fast-xml-parser@4.5.3", "", { "dependencies": { "strnum": "^1.1.1" }, "bin": { "fxparser": "src/cli/cli.js" } }, "sha512-RKihhV+SHsIUGXObeVy9AXiBbFwkVk7Syp8XgwN5U3JV416+Gwp/GO9i0JYKmikykgz/UHRrrV4ROuZEo/T0ig=="], + + "strnum": ["strnum@1.1.2", "", {}, "sha512-vrN+B7DBIoTTZjnPNewwhx6cBA/H+IS7rfW68n7XxC1y7uoiGQBxaKzqucGUgavX15dJgiGztLJ8vxuEzwqBdA=="], + + "undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="], + + "zod": ["zod@3.25.76", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="], + } +} diff --git a/hooks/claude-code-prompt.ts b/hooks/claude-code-prompt.ts new file mode 100755 index 0000000..4b64063 --- /dev/null +++ b/hooks/claude-code-prompt.ts @@ -0,0 +1,130 @@ +#!/usr/bin/env bun +import { readFileSync } from 'node:fs'; +import type { SyncHookJSONOutput, UserPromptSubmitHookInput } from '@anthropic-ai/claude-agent-sdk'; +import { readSessionCache, writeSessionCache } from '../../../utils/session-cache'; + +interface SessionCache { + knowledge_suggested: boolean; + first_triggered: string; + match_reason: string; +} + +async function main() { + try { + // Read input from stdin + const input = readFileSync(0, 'utf-8'); + const data: UserPromptSubmitHookInput = JSON.parse(input); + const prompt = data.prompt.toLowerCase(); + + // Check for Claude Code related keywords (case insensitive) + const claudeCodeKeywords = ['claude code', 'claudecode', 'claude-code']; + + // Check for standalone "claude" but be more selective to avoid false positives + const standaloneClaudePatterns = [ + /\bclaude\b(?!\s+sonnet|\s+opus|\s+haiku)/i, // "claude" not followed by model names + /how\s+(?:do|does|can)\s+claude/i, // "how do/does/can claude..." + /can\s+claude/i, // "can claude..." + /does\s+claude/i, // "does claude..." + /is\s+claude/i, // "is claude..." + /tell\s+claude/i, // "tell claude..." + /ask\s+claude/i, // "ask claude..." + ]; + + // Additional Claude Code related patterns + const claudeCodePatterns = [ + /\bhook/i, + /\bmcp\s+server/i, + /\bskill/i, + /slash\s+command/i, + /claude.*setting/i, + /claude.*config/i, + /claude.*feature/i, + /claude.*capability/i, + /how\s+(?:do|does)\s+(?:i|claude).*(hook|mcp|skill|command)/i, + ]; + + let isMatch = false; + let matchReason = ''; + + // Check for exact keyword matches + for (const keyword of claudeCodeKeywords) { + if (prompt.includes(keyword)) { + isMatch = true; + matchReason = `Detected "${keyword}"`; + break; + } + } + + // Check for standalone Claude mentions + if (!isMatch) { + for (const pattern of standaloneClaudePatterns) { + if (pattern.test(prompt)) { + isMatch = true; + matchReason = 'Detected Claude Code question'; + break; + } + } + } + + // Check for Claude Code feature patterns + if (!isMatch) { + for (const pattern of claudeCodePatterns) { + if (pattern.test(prompt)) { + isMatch = true; + matchReason = 'Detected Claude Code feature mention'; + break; + } + } + } + + // Generate context injection if match found + if (isMatch) { + // Check session cache - only suggest once per session + const cache = readSessionCache( + 'claude-code-knowledge', + data.cwd, + data.session_id + ); + + // If already suggested this session, exit silently + if (cache?.knowledge_suggested) { + process.exit(0); + } + + // Use JSON output method for explicit control + let context = '\n'; + context += `Detected Claude Code question: ${matchReason}\n\n`; + context += 'ESSENTIAL SKILL:\n'; + context += ' → claude-code-knowledge:claude-code-knowledge\n'; + context += ''; + + // Return JSON with hookSpecificOutput for UserPromptSubmit + const output: SyncHookJSONOutput = { + hookSpecificOutput: { + hookEventName: 'UserPromptSubmit', + additionalContext: context, + }, + }; + + console.log(JSON.stringify(output)); + + // Mark as suggested in session cache + writeSessionCache('claude-code-knowledge', data.cwd, data.session_id, { + knowledge_suggested: true, + first_triggered: new Date().toISOString(), + match_reason: matchReason, + }); + } + + // Exit 0 = success, additionalContext is added to context + process.exit(0); + } catch (err) { + console.error('Error in claude-code-prompt hook:', err); + process.exit(1); + } +} + +main().catch((err) => { + console.error('Uncaught error:', err); + process.exit(1); +}); diff --git a/hooks/hooks.json b/hooks/hooks.json new file mode 100644 index 0000000..1529789 --- /dev/null +++ b/hooks/hooks.json @@ -0,0 +1,28 @@ +{ + "description": "Auto-suggests skill and syncs docs transparently when skill loads", + "hooks": { + "UserPromptSubmit": [ + { + "hooks": [ + { + "type": "command", + "command": "${CLAUDE_PLUGIN_ROOT}/hooks/claude-code-prompt.ts", + "timeout": 30 + } + ] + } + ], + "PreToolUse": [ + { + "matcher": "Skill", + "hooks": [ + { + "type": "command", + "command": "${CLAUDE_PLUGIN_ROOT}/hooks/sync-docs-on-skill-load.ts", + "timeout": 30 + } + ] + } + ] + } +} diff --git a/hooks/package.json b/hooks/package.json new file mode 100644 index 0000000..d267ba5 --- /dev/null +++ b/hooks/package.json @@ -0,0 +1,13 @@ +{ + "name": "claude-code-knowledge-hooks", + "version": "1.0.0", + "private": true, + "type": "module", + "dependencies": { + "fast-xml-parser": "^4.3.2" + }, + "devDependencies": { + "@anthropic-ai/claude-agent-sdk": "^0.1.37", + "@types/bun": "latest" + } +} diff --git a/hooks/sync-docs-on-skill-load.ts b/hooks/sync-docs-on-skill-load.ts new file mode 100755 index 0000000..fb9309f --- /dev/null +++ b/hooks/sync-docs-on-skill-load.ts @@ -0,0 +1,709 @@ +#!/usr/bin/env bun +/** + * PreToolUse Hook: Auto-sync claude-code-knowledge documentation when skill loads + * + * This hook combines all documentation fetching and syncing logic in one place. + * It runs transparently before the Skill tool executes, checking if docs need + * updating and fetching from docs.anthropic.com if necessary. + * + * Features: + * - Smart caching (3-hour threshold) + * - Automatic sitemap discovery + * - Retry logic with exponential backoff + * - Silent failures (never blocks skill loading) + * - Complete manifest tracking + */ + +import { createHash } from 'node:crypto'; +import { existsSync } from 'node:fs'; +import { mkdir, readFile, writeFile } from 'node:fs/promises'; +import { dirname, join } from 'node:path'; +import type { PreToolUseHookInput } from '@anthropic-ai/claude-agent-sdk'; +import { XMLParser } from 'fast-xml-parser'; + +// ============================================================================ +// Constants +// ============================================================================ + +const SITEMAP_URLS = [ + 'https://docs.anthropic.com/sitemap.xml', + 'https://docs.claude.com/sitemap.xml', +]; + +const MANIFEST_FILE = 'docs_manifest.json'; + +const HEADERS = { + 'User-Agent': 'Claude-Code-Knowledge-Skill/1.0', + 'Cache-Control': 'no-cache, no-store, must-revalidate', + Pragma: 'no-cache', + Expires: '0', +}; + +const MAX_RETRIES = 3; +const RETRY_DELAY = 2000; // ms +const MAX_RETRY_DELAY = 30000; // ms +const MAX_CONCURRENT_FETCHES = 10; // parallel fetch limit + +// ============================================================================ +// Types +// ============================================================================ + +interface ManifestFile { + original_url?: string; + original_md_url?: string; + original_raw_url?: string; + hash: string; + last_updated: string; + source?: string; +} + +interface Manifest { + files: Record; + last_updated?: string; + source?: string; + skill?: string; + fetch_metadata?: { + last_fetch_completed: string; + fetch_duration_seconds: number; + total_pages_discovered: number; + pages_fetched_successfully: number; + pages_failed: number; + failed_pages: string[]; + sitemap_url: string; + base_url: string; + total_files: number; + }; +} + +interface SitemapUrlEntry { + loc?: string; + [key: string]: unknown; +} + +interface FetchResult { + success: boolean; + filename?: string; + pagePath?: string; + manifestEntry?: ManifestFile; +} + +// ============================================================================ +// Path Resolution +// ============================================================================ + +const SCRIPT_DIR = dirname(new URL(import.meta.url).pathname); +const PLUGIN_ROOT = join(SCRIPT_DIR, '..'); +const DOCS_DIR = join(PLUGIN_ROOT, 'skills/claude-code-knowledge/docs'); +const MANIFEST_PATH = join(DOCS_DIR, MANIFEST_FILE); + +// ============================================================================ +// Hook Input Handling +// ============================================================================ + +async function readHookInput(): Promise { + try { + const input = await Bun.stdin.text(); + return JSON.parse(input); + } catch { + return null; + } +} + +function shouldSync(hookInput: PreToolUseHookInput | null): boolean { + if (!hookInput) return false; + if (hookInput.tool_name !== 'Skill') return false; + + const toolInput = hookInput.tool_input as Record; + const skillName = (toolInput.skill as string) || ''; + return ( + skillName === 'claude-code-knowledge' || + skillName === 'claude-code-knowledge:claude-code-knowledge' + ); +} + +// ============================================================================ +// Sync Need Detection +// ============================================================================ + +async function checkIfSyncNeeded(): Promise { + if (!existsSync(MANIFEST_PATH)) { + return true; // First time, need to fetch + } + + try { + const manifestContent = await readFile(MANIFEST_PATH, 'utf-8'); + const manifest = JSON.parse(manifestContent); + const lastUpdate = manifest.last_updated || 'unknown'; + + if (lastUpdate === 'unknown') return true; + + const lastUpdateDate = new Date(lastUpdate.slice(0, 19)); + const currentDate = new Date(); + const hoursSinceUpdate = Math.floor( + (currentDate.getTime() - lastUpdateDate.getTime()) / (1000 * 60 * 60) + ); + + return hoursSinceUpdate >= 3; + } catch { + return true; // Error reading manifest, re-fetch + } +} + +// ============================================================================ +// Manifest Management +// ============================================================================ + +async function loadManifest(): Promise { + if (existsSync(MANIFEST_PATH)) { + try { + const content = await readFile(MANIFEST_PATH, 'utf-8'); + const manifest = JSON.parse(content); + if (!manifest.files) manifest.files = {}; + return manifest; + } catch { + // Ignore error, return empty manifest + } + } + return { files: {}, last_updated: undefined }; +} + +async function saveManifest(manifest: Manifest): Promise { + manifest.last_updated = new Date().toISOString(); + manifest.source = 'https://docs.anthropic.com/en/docs/claude-code/'; + manifest.skill = 'claude-code-knowledge'; + await writeFile(MANIFEST_PATH, JSON.stringify(manifest, null, 2)); +} + +// ============================================================================ +// Utility Functions +// ============================================================================ + +const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); + +function urlToSafeFilename(urlPath: string): string { + const prefixes = ['/en/docs/claude-code/', '/docs/claude-code/', '/claude-code/']; + + let path = urlPath; + for (const prefix of prefixes) { + if (urlPath.includes(prefix)) { + path = urlPath.split(prefix).pop() || urlPath; + break; + } + } + + if (path === urlPath && urlPath.includes('claude-code/')) { + path = urlPath.split('claude-code/').pop() || urlPath; + } + + if (!path.includes('/')) { + return path.endsWith('.md') ? path : `${path}.md`; + } + + let safeName = path.replace(/\//g, '__'); + if (!safeName.endsWith('.md')) { + safeName += '.md'; + } + + return safeName; +} + +function contentHasChanged(content: string, oldHash: string): boolean { + const newHash = createHash('sha256').update(content, 'utf-8').digest('hex'); + return newHash !== oldHash; +} + +// ============================================================================ +// Sitemap and Page Discovery +// ============================================================================ + +async function discoverSitemapAndBaseUrl(): Promise<{ sitemapUrl: string; baseUrl: string }> { + for (const sitemapUrl of SITEMAP_URLS) { + try { + const response = await fetch(sitemapUrl, { headers: HEADERS }); + + if (response.status === 200) { + const content = await response.text(); + const parser = new XMLParser(); + const result = parser.parse(content); + + let firstUrl: string | null = null; + if (result.urlset?.url) { + const urls = Array.isArray(result.urlset.url) ? result.urlset.url : [result.urlset.url]; + if (urls[0]?.loc) { + firstUrl = urls[0].loc; + } + } + + if (firstUrl) { + const url = new URL(firstUrl); + const baseUrl = `${url.protocol}//${url.hostname}`; + return { sitemapUrl, baseUrl }; + } + } + } catch {} + } + + throw new Error('Could not find a valid sitemap'); +} + +function getFallbackPages(): string[] { + return [ + '/en/docs/claude-code/overview', + '/en/docs/claude-code/quickstart', + '/en/docs/claude-code/setup', + '/en/docs/claude-code/cli-reference', + '/en/docs/claude-code/common-workflows', + '/en/docs/claude-code/interactive-mode', + '/en/docs/claude-code/settings', + '/en/docs/claude-code/model-config', + '/en/docs/claude-code/network-config', + '/en/docs/claude-code/terminal-config', + '/en/docs/claude-code/output-styles', + '/en/docs/claude-code/statusline', + '/en/docs/claude-code/hooks', + '/en/docs/claude-code/hooks-guide', + '/en/docs/claude-code/mcp', + '/en/docs/claude-code/skills', + '/en/docs/claude-code/slash-commands', + '/en/docs/claude-code/plugins', + '/en/docs/claude-code/plugins-reference', + '/en/docs/claude-code/plugin-marketplaces', + '/en/docs/claude-code/sub-agents', + '/en/docs/claude-code/memory', + '/en/docs/claude-code/checkpointing', + '/en/docs/claude-code/analytics', + '/en/docs/claude-code/monitoring-usage', + '/en/docs/claude-code/costs', + '/en/docs/claude-code/github-actions', + '/en/docs/claude-code/gitlab-ci-cd', + '/en/docs/claude-code/vs-code', + '/en/docs/claude-code/jetbrains', + '/en/docs/claude-code/devcontainer', + '/en/docs/claude-code/claude-code-on-the-web', + '/en/docs/claude-code/third-party-integrations', + '/en/docs/claude-code/amazon-bedrock', + '/en/docs/claude-code/google-vertex-ai', + '/en/docs/claude-code/llm-gateway', + '/en/docs/claude-code/iam', + '/en/docs/claude-code/security', + '/en/docs/claude-code/sandboxing', + '/en/docs/claude-code/data-usage', + '/en/docs/claude-code/legal-and-compliance', + '/en/docs/claude-code/headless', + '/en/docs/claude-code/troubleshooting', + '/en/docs/claude-code/sdk/migration-guide', + ]; +} + +async function discoverClaudeCodePages(sitemapUrl: string): Promise { + try { + const response = await fetch(sitemapUrl, { headers: HEADERS }); + if (!response.ok) throw new Error(`HTTP ${response.status}`); + + const content = await response.text(); + const parser = new XMLParser(); + const result = parser.parse(content); + + let urls: string[] = []; + if (result.urlset?.url) { + const urlEntries = Array.isArray(result.urlset.url) ? result.urlset.url : [result.urlset.url]; + urls = urlEntries + .map((entry: SitemapUrlEntry) => entry.loc) + .filter((loc: unknown): loc is string => typeof loc === 'string'); + } + + const claudeCodePages: string[] = []; + const englishPatterns = ['/en/docs/claude-code/']; + + for (const url of urls) { + if (englishPatterns.some((pattern) => url.includes(pattern))) { + const urlObj = new URL(url); + let path = urlObj.pathname; + + if (path.endsWith('.html')) { + path = path.slice(0, -5); + } else if (path.endsWith('/')) { + path = path.slice(0, -1); + } + + const skipPatterns = ['/tool-use/', '/examples/', '/legacy/', '/api/', '/reference/']; + if (!skipPatterns.some((skip) => path.includes(skip))) { + claudeCodePages.push(path); + } + } + } + + const uniquePages = [...new Set(claudeCodePages)].sort(); + + if (uniquePages.length === 0) { + return getFallbackPages(); + } + + return uniquePages; + } catch { + return getFallbackPages(); + } +} + +// ============================================================================ +// Content Fetching +// ============================================================================ + +function validateMarkdownContent(content: string, _filename: string): void { + if (!content || content.startsWith(' ']; + + const indicatorCount = lines.slice(0, 50).reduce((count, line) => { + return ( + count + + markdownIndicators.filter( + (indicator) => line.trim().startsWith(indicator) || line.includes(indicator) + ).length + ); + }, 0); + + if (indicatorCount < 3) { + throw new Error(`Content doesn't appear to be markdown (${indicatorCount} indicators found)`); + } +} + +async function fetchMarkdownContent( + path: string, + baseUrl: string +): Promise<{ filename: string; content: string }> { + const markdownUrl = `${baseUrl}${path}.md`; + const filename = urlToSafeFilename(path); + + for (let attempt = 0; attempt < MAX_RETRIES; attempt++) { + try { + const response = await fetch(markdownUrl, { + headers: HEADERS, + redirect: 'follow', + }); + + if (response.status === 429) { + const retryAfter = Number.parseInt(response.headers.get('Retry-After') || '60', 10); + await sleep(retryAfter * 1000); + continue; + } + + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + + const content = await response.text(); + validateMarkdownContent(content, filename); + + return { filename, content }; + } catch (e) { + if (attempt < MAX_RETRIES - 1) { + const delay = Math.min(RETRY_DELAY * 2 ** attempt, MAX_RETRY_DELAY); + const jitteredDelay = delay * (0.5 + Math.random() * 0.5); + await sleep(jitteredDelay); + } else { + throw new Error(`Failed to fetch ${filename} after ${MAX_RETRIES} attempts: ${e}`); + } + } + } + + throw new Error(`Failed to fetch ${path}`); +} + +async function fetchChangelog(): Promise<{ filename: string; content: string }> { + const changelogUrl = 'https://raw.githubusercontent.com/anthropics/claude-code/main/CHANGELOG.md'; + const filename = 'changelog.md'; + + for (let attempt = 0; attempt < MAX_RETRIES; attempt++) { + try { + const response = await fetch(changelogUrl, { + headers: HEADERS, + redirect: 'follow', + }); + + if (response.status === 429) { + const retryAfter = Number.parseInt(response.headers.get('Retry-After') || '60', 10); + await sleep(retryAfter * 1000); + continue; + } + + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + + const content = await response.text(); + + const header = `# Claude Code Changelog + +> **Source**: https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md +> +> This is the official Claude Code release changelog from the Claude Code repository. + +--- + +`; + const fullContent = header + content; + + if (fullContent.trim().length < 100) { + throw new Error(`Changelog content too short (${fullContent.length} bytes)`); + } + + return { filename, content: fullContent }; + } catch (e) { + if (attempt < MAX_RETRIES - 1) { + const delay = Math.min(RETRY_DELAY * 2 ** attempt, MAX_RETRY_DELAY); + const jitteredDelay = delay * (0.5 + Math.random() * 0.5); + await sleep(jitteredDelay); + } else { + throw new Error(`Failed to fetch changelog after ${MAX_RETRIES} attempts: ${e}`); + } + } + } + + throw new Error('Failed to fetch changelog'); +} + +async function saveMarkdownFile(filename: string, content: string): Promise { + const filePath = join(DOCS_DIR, filename); + await writeFile(filePath, content, 'utf-8'); + const contentHash = createHash('sha256').update(content, 'utf-8').digest('hex'); + return contentHash; +} + +// ============================================================================ +// Parallel Fetch Helpers +// ============================================================================ + +async function fetchAndSavePage( + pagePath: string, + baseUrl: string, + manifest: Manifest +): Promise { + try { + const { filename, content } = await fetchMarkdownContent(pagePath, baseUrl); + + const oldHash = manifest.files[filename]?.hash || ''; + const oldEntry = manifest.files[filename] || {}; + const filePath = join(DOCS_DIR, filename); + const fileExists = existsSync(filePath); + + let contentHash: string; + let lastUpdated: string; + + if (!fileExists || contentHasChanged(content, oldHash)) { + contentHash = await saveMarkdownFile(filename, content); + lastUpdated = new Date().toISOString(); + } else { + contentHash = oldHash; + lastUpdated = oldEntry.last_updated || new Date().toISOString(); + } + + return { + success: true, + filename, + pagePath, + manifestEntry: { + original_url: `${baseUrl}${pagePath}`, + original_md_url: `${baseUrl}${pagePath}.md`, + hash: contentHash, + last_updated: lastUpdated, + }, + }; + } catch (e) { + return { success: false, pagePath }; + } +} + +async function fetchAndSaveChangelog(manifest: Manifest): Promise { + try { + const { filename, content } = await fetchChangelog(); + + const oldHash = manifest.files[filename]?.hash || ''; + const oldEntry = manifest.files[filename] || {}; + const filePath = join(DOCS_DIR, filename); + const fileExists = existsSync(filePath); + + let contentHash: string; + let lastUpdated: string; + + if (!fileExists || contentHasChanged(content, oldHash)) { + contentHash = await saveMarkdownFile(filename, content); + lastUpdated = new Date().toISOString(); + } else { + contentHash = oldHash; + lastUpdated = oldEntry.last_updated || new Date().toISOString(); + } + + return { + success: true, + filename, + pagePath: 'changelog', + manifestEntry: { + original_url: 'https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md', + original_raw_url: + 'https://raw.githubusercontent.com/anthropics/claude-code/main/CHANGELOG.md', + hash: contentHash, + last_updated: lastUpdated, + source: 'claude-code-repository', + }, + }; + } catch (e) { + return { success: false, pagePath: 'changelog' }; + } +} + +async function fetchAllPagesInParallel( + documentationPages: string[], + baseUrl: string, + manifest: Manifest +): Promise { + // Create all fetch tasks (documentation pages + changelog) + const pageTasks = documentationPages.map( + (pagePath) => () => fetchAndSavePage(pagePath, baseUrl, manifest) + ); + const allTasks = [...pageTasks, () => fetchAndSaveChangelog(manifest)]; + + const results: FetchResult[] = []; + + // Process in batches to limit concurrency + for (let i = 0; i < allTasks.length; i += MAX_CONCURRENT_FETCHES) { + const batch = allTasks.slice(i, i + MAX_CONCURRENT_FETCHES); + const batchResults = await Promise.allSettled(batch.map((task) => task())); + + for (const result of batchResults) { + if (result.status === 'fulfilled') { + results.push(result.value); + } else { + results.push({ success: false, pagePath: 'unknown' }); + } + } + + // Small delay between batches to be respectful to the server + if (i + MAX_CONCURRENT_FETCHES < allTasks.length) { + await sleep(500); + } + } + + return results; +} + +// ============================================================================ +// Main Fetch Logic +// ============================================================================ + +async function runFetch(): Promise { + const startTime = Date.now(); + + // Create docs directory if needed + if (!existsSync(DOCS_DIR)) { + await mkdir(DOCS_DIR, { recursive: true }); + } + + // Load existing manifest + const manifest = await loadManifest(); + + // Statistics + let successful = 0; + let failed = 0; + const failedPages: string[] = []; + const newManifest: Manifest = { files: {} }; + + // Discover sitemap and base URL + let sitemapUrl: string; + let baseUrl: string; + + try { + const result = await discoverSitemapAndBaseUrl(); + sitemapUrl = result.sitemapUrl; + baseUrl = result.baseUrl; + } catch (e) { + throw new Error(`Failed to discover sitemap: ${e}`); + } + + // Discover documentation pages + const documentationPages = await discoverClaudeCodePages(sitemapUrl); + + if (documentationPages.length === 0) { + throw new Error('No documentation pages discovered!'); + } + + // Fetch all pages in parallel (including changelog) + const results = await fetchAllPagesInParallel(documentationPages, baseUrl, manifest); + + // Process results + for (const result of results) { + if (result.success && result.filename && result.manifestEntry) { + newManifest.files[result.filename] = result.manifestEntry; + successful++; + } else { + failed++; + failedPages.push(result.pagePath || 'unknown'); + } + } + + // Add metadata + const duration = (Date.now() - startTime) / 1000; + newManifest.fetch_metadata = { + last_fetch_completed: new Date().toISOString(), + fetch_duration_seconds: duration, + total_pages_discovered: documentationPages.length, + pages_fetched_successfully: successful, + pages_failed: failed, + failed_pages: failedPages, + sitemap_url: sitemapUrl, + base_url: baseUrl, + total_files: successful, + }; + + // Save manifest + await saveManifest(newManifest); + + // If no pages were fetched successfully, throw error + if (successful === 0) { + throw new Error('No pages were fetched successfully!'); + } +} + +// ============================================================================ +// Main Hook Logic +// ============================================================================ + +async function main() { + // Read hook input + const hookInput = await readHookInput(); + + // Check if we should sync + if (!shouldSync(hookInput)) { + process.exit(0); + } + + // Check if sync is needed + const syncNeeded = await checkIfSyncNeeded(); + + if (!syncNeeded) { + process.exit(0); + } + + // Run fetch (blocks, but with timeout handled by hook system) + try { + await runFetch(); + } catch { + // Silent failure - don't block skill loading + } + + // Always exit 0 (non-blocking, silent) + process.exit(0); +} + +// Run main function +main().catch(() => { + // Silent failure - always exit 0 + process.exit(0); +}); diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..9a38230 --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,97 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:codethread/claude-code-plugins:plugins/claude-code-knowledge", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "9d44da8fd1c59341bf0a013743c18d36baf62495", + "treeHash": "3d4905cec3d21efd16179965766b3a5a00d3bbdc69968651d1780b47c2ab2bb4", + "generatedAt": "2025-11-28T10:15:43.972452Z", + "toolVersion": "publish_plugins.py@0.2.0" + }, + "origin": { + "remote": "git@github.com:zhongweili/42plugin-data.git", + "branch": "master", + "commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390", + "repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data" + }, + "manifest": { + "name": "claude-code-knowledge", + "description": "Official Claude Code documentation access. Provides instant reference to hooks, MCP, skills, slash commands, settings, CLI, and all Claude Code features with automatic sync from docs.anthropic.com.", + "version": "1.1.0" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "e3a377169f2f11587eb24e6d3958d28ad476ae8a9cf07bfd71f3efdc6b40de83" + }, + { + "path": "hooks/bun.lock", + "sha256": "6a06daa9a6cb6459c090dff7cc3cea8a616d53da1ce4463c93d2e065ba7f7e97" + }, + { + "path": "hooks/package.json", + "sha256": "65424ed8eaa0784e28b2bd942ef316aff70868a98f8f50a855a7bbb3463097d1" + }, + { + "path": "hooks/hooks.json", + "sha256": "cab9c11020736e1bcb5124bc6a5bed498d52e58e0ffd4b941fd789755b5c575c" + }, + { + "path": "hooks/claude-code-prompt.ts", + "sha256": "98166ae9d3271b360ddd57a32c9e27a92ed9d2e9dbab24e8afe8713436cd4b1b" + }, + { + "path": "hooks/sync-docs-on-skill-load.ts", + "sha256": "d43b8e1c7c1e6083c8d3918cd5e7e668427ed84e431f3a3a0b1ce5107ab37019" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "9922b3df34d7c890b729bfddc7d12d0a0f971e6260d052653bd54830797a2772" + }, + { + "path": "skills/skill-rules.json", + "sha256": "db2983137e1ae17bb0d82702d64089c32cde1246ffc19a66e4805607bb068f76" + }, + { + "path": "skills/claude-code-knowledge/reference.md", + "sha256": "256a915cbb7e44271945f96175f90079c5fe6c9472b48eb5ec1e4e67bdde3251" + }, + { + "path": "skills/claude-code-knowledge/SKILL.md", + "sha256": "a071457facaecad875c670572e3ef7fe2333656865fafd2d46ec73aff5a7f565" + }, + { + "path": "skills/claude-code-knowledge/scripts/bun.lock", + "sha256": "700d9904d64d985eddce76e6b2153b79017379f99464e489de1ae2cb482ecd4c" + }, + { + "path": "skills/claude-code-knowledge/scripts/package.json", + "sha256": "1502d33a4e7ec17f374d70838228e469ad3362611224a4217c405d1658b104ac" + }, + { + "path": "skills/claude-code-knowledge/scripts/list_topics.ts", + "sha256": "53b3b5cb6491b6fa40addf838e171115da080b07afc47af33e332b40609c2589" + }, + { + "path": "skills/claude-code-knowledge/scripts/skill-creator/package_skill.ts", + "sha256": "cea3be755aa32ee12d31993ae024d864aefd6e872952df7b315f0029118da1d5" + }, + { + "path": "skills/claude-code-knowledge/scripts/skill-creator/quick_validate.ts", + "sha256": "759efed00f9f57cfa2dc3b273c9def4282a579bd585bcad6c48e45126eee3d7d" + }, + { + "path": "skills/claude-code-knowledge/scripts/skill-creator/init_skill.ts", + "sha256": "9996026199e8d362ab0b8e736e38ef2526652e7cb918ae615fddba3e2617f5eb" + } + ], + "dirSha256": "3d4905cec3d21efd16179965766b3a5a00d3bbdc69968651d1780b47c2ab2bb4" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file diff --git a/skills/claude-code-knowledge/SKILL.md b/skills/claude-code-knowledge/SKILL.md new file mode 100644 index 0000000..6cf5fd7 --- /dev/null +++ b/skills/claude-code-knowledge/SKILL.md @@ -0,0 +1,159 @@ +--- +name: claude-code-knowledge +description: Access official Claude Code documentation including comprehensive guides on hooks, MCP servers, agent skills, slash commands, settings, CLI reference, security, memory, plugins, and troubleshooting. Use when the user asks about Claude Code features, configuration, capabilities, or best practices. ALWAYS use this skill instead of guessing about Claude Code functionality - it contains the authoritative documentation from docs.anthropic.com with automatic updates. Also includes comprehensive skill creation guide with helper scripts when users want to create new skills. +allowed-tools: Read, Grep, Glob, Bash, Bash(bun:*) +--- + +# Claude Code Knowledge + +**Version: 1.1.0** (Updated 2025-11-13) + +Access to official Claude Code documentation, automatically synced from docs.anthropic.com. + +## When to Use This Skill + +**CRITICAL**: Use this skill whenever: + +- User asks about Claude Code features, configuration, or capabilities +- User mentions: hooks, MCP, skills, slash commands, settings, security, memory, plugins +- User wants to create a new skill or update an existing skill +- You need to verify how something works in Claude Code +- You're unsure about Claude Code functionality (NEVER guess - check the docs!) +- User asks "how do I..." questions related to Claude Code +- You need to explain Claude Code concepts or best practices + +## Quick Reference + +### Check Available Documentation + +```bash +bun scripts/list_topics.ts +``` + +Or read the complete list from [reference.md](reference.md). + +### Read Specific Documentation + +Documentation files are in the `docs/` directory: + +```bash +# Read a specific doc +cat docs/hooks.md +cat docs/mcp.md +cat docs/skills.md +``` + +### Search Across All Documentation + +Use Grep to search for specific topics: + +```bash +# Search for a specific term +grep -r "environment variable" docs/ + +# Case-insensitive search +grep -ri "subagent" docs/ + +# Search with context +grep -r -A 3 -B 3 "allowed-tools" docs/ +``` + +## Common Documentation Topics + +The most frequently referenced documentation includes: + +- **hooks.md** - Hooks system for customizing Claude Code behavior +- **hooks-guide.md** - Detailed guide for creating hooks +- **mcp.md** - Model Context Protocol servers integration +- **skills.md** - Agent Skills creation and management +- **skill-creation-guide.md** - Comprehensive guide for creating effective skills with helper scripts +- **slash-commands.md** - Custom slash commands +- **settings.md** - Configuration settings reference +- **cli-reference.md** - Command-line interface reference +- **memory.md** - Memory and context management +- **plugins.md** - Plugin development and usage + +For the complete list, see [reference.md](reference.md). + +## Workflow + +1. **Find the topic** you need: + + ```bash + bun scripts/list_topics.ts + # Or read reference.md + ``` + +2. **Read the documentation**: + + ```bash + cat docs/.md + ``` + +3. **Search if needed**: + ```bash + grep -ri "search term" docs/ + ``` + +## Documentation Format + +Each documentation file includes: + +- Comprehensive guides and tutorials +- Code examples +- Best practices +- Common patterns and workflows +- Troubleshooting tips + +## Important Notes + +- Documentation is synced from docs.anthropic.com +- Local cache ensures fast access +- Always prefer checking docs over guessing +- When answering user questions, cite specific documentation +- Include file references like `docs/hooks.md:123` when possible + +## Writing effective agents + +When writing agent files, subagents don't distinguish between claude code invoking them and the user. From their perspective, all prompts come from "the user." + +## Examples + +### User asks: "How do I create a hook?" + +1. Read hooks documentation: `cat docs/hooks.md` and `cat docs/hooks-guide.md` +2. Provide answer based on the official documentation +3. Cite the source: "According to docs/hooks.md..." + +### User asks: "What MCP servers are available?" + +1. Read: `cat docs/mcp.md` +2. Search for examples: `grep -ri "mcp server" docs/` +3. Provide comprehensive answer with citations + +### User asks: "How do I configure settings?" + +1. Read: `cat docs/settings.md` +2. Reference specific configuration options +3. Cite: "From docs/settings.md..." + +### User asks: "How do I create a skill?" + +1. Read: `cat docs/skill-creation-guide.md` +2. For initialization: Use `bun scripts/skill-creator/init_skill.ts` +3. For validation: Use `bun scripts/skill-creator/quick_validate.ts` +4. For packaging: Use `bun scripts/skill-creator/package_skill.ts` +5. Provide comprehensive guidance based on the documentation + +## Troubleshooting + +If you can't find a topic: + +1. Check if the topic exists: `bun scripts/list_topics.ts` +2. Search across all docs: `grep -ri "topic" docs/` + +## Additional Resources + +- Official documentation: https://docs.anthropic.com/en/docs/claude-code/ +- Claude Code changelog: docs/changelog.md +- Complete topic list: [reference.md](reference.md) diff --git a/skills/claude-code-knowledge/reference.md b/skills/claude-code-knowledge/reference.md new file mode 100644 index 0000000..393351b --- /dev/null +++ b/skills/claude-code-knowledge/reference.md @@ -0,0 +1,106 @@ +# Claude Code Documentation Reference + +This file lists all available Claude Code documentation topics. Each topic is available as a markdown file in the `docs/` directory. + +## Available Documentation Topics + +### Core Features + +- **overview.md** - Claude Code overview and introduction +- **quickstart.md** - Quick start guide for Claude Code +- **setup.md** - Initial setup and configuration +- **cli-reference.md** - Complete command-line interface reference +- **common-workflows.md** - Common workflows and usage patterns +- **interactive-mode.md** - Interactive mode usage and features + +### Configuration & Settings + +- **settings.md** - Configuration settings reference +- **model-config.md** - Model configuration and selection +- **network-config.md** - Network and proxy configuration +- **terminal-config.md** - Terminal configuration options +- **output-styles.md** - Customizing output appearance +- **statusline.md** - Status line configuration + +### Extensibility + +- **hooks.md** - Hooks system overview +- **hooks-guide.md** - Detailed guide for creating hooks +- **mcp.md** - Model Context Protocol (MCP) servers +- **skills.md** - Agent Skills creation and management +- **slash-commands.md** - Custom slash commands +- **plugins.md** - Plugin development and usage +- **plugins-reference.md** - Plugin API reference +- **plugin-marketplaces.md** - Plugin marketplace information + +### Advanced Features + +- **sub-agents.md** - Sub-agents and delegation +- **memory.md** - Memory and context management +- **checkpointing.md** - Checkpointing and session management +- **analytics.md** - Analytics and telemetry +- **monitoring-usage.md** - Usage monitoring and cost tracking +- **costs.md** - Cost management and optimization + +### Integrations + +- **github-actions.md** - GitHub Actions integration +- **gitlab-ci-cd.md** - GitLab CI/CD integration +- **vs-code.md** - VS Code integration +- **jetbrains.md** - JetBrains IDE integration +- **devcontainer.md** - Dev Container support +- **claude-code-on-the-web.md** - Web-based Claude Code +- **third-party-integrations.md** - Third-party tool integrations + +### Cloud Platforms + +- **amazon-bedrock.md** - Amazon Bedrock integration +- **google-vertex-ai.md** - Google Vertex AI integration +- **llm-gateway.md** - LLM Gateway configuration +- **iam.md** - Identity and Access Management + +### Security & Compliance + +- **security.md** - Security features and best practices +- **sandboxing.md** - Sandboxing and isolation +- **data-usage.md** - Data usage and privacy +- **legal-and-compliance.md** - Legal and compliance information + +### Operations + +- **headless.md** - Running Claude Code in headless mode +- **troubleshooting.md** - Troubleshooting common issues +- **sdk__migration-guide.md** - SDK migration guide +- **changelog.md** - Claude Code release notes and version history + +## Usage + +To read any documentation topic: + +```bash +cat docs/.md +``` + +To search across all documentation: + +```bash +grep -ri "search term" docs/ +``` + +To list all topics: + +```bash +bash scripts/list_topics.sh +``` + +## Documentation Source + +All documentation is synced from the official Claude Code documentation at: +- https://docs.anthropic.com/en/docs/claude-code/ (via code.claude.com) + +The changelog is fetched directly from: +- https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md + +## Last Updated + +Check the `docs/docs_manifest.json` file for the last update timestamp and per-file update information. diff --git a/skills/claude-code-knowledge/scripts/bun.lock b/skills/claude-code-knowledge/scripts/bun.lock new file mode 100644 index 0000000..08f7f82 --- /dev/null +++ b/skills/claude-code-knowledge/scripts/bun.lock @@ -0,0 +1,24 @@ +{ + "lockfileVersion": 1, + "workspaces": { + "": { + "name": "claude-code-knowledge-scripts", + "devDependencies": { + "@types/bun": "latest", + }, + }, + }, + "packages": { + "@types/bun": ["@types/bun@1.3.2", "", { "dependencies": { "bun-types": "1.3.2" } }, "sha512-t15P7k5UIgHKkxwnMNkJbWlh/617rkDGEdSsDbu+qNHTaz9SKf7aC8fiIlUdD5RPpH6GEkP0cK7WlvmrEBRtWg=="], + + "@types/node": ["@types/node@24.10.1", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="], + + "@types/react": ["@types/react@19.2.4", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-tBFxBp9Nfyy5rsmefN+WXc1JeW/j2BpBHFdLZbEVfs9wn3E3NRFxwV0pJg8M1qQAexFpvz73hJXFofV0ZAu92A=="], + + "bun-types": ["bun-types@1.3.2", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-i/Gln4tbzKNuxP70OWhJRZz1MRfvqExowP7U6JKoI8cntFrtxg7RJK3jvz7wQW54UuvNC8tbKHHri5fy74FVqg=="], + + "csstype": ["csstype@3.1.3", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="], + + "undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="], + } +} diff --git a/skills/claude-code-knowledge/scripts/list_topics.ts b/skills/claude-code-knowledge/scripts/list_topics.ts new file mode 100755 index 0000000..3f76795 --- /dev/null +++ b/skills/claude-code-knowledge/scripts/list_topics.ts @@ -0,0 +1,41 @@ +#!/usr/bin/env bun +/** + * List available documentation topics + * This script lists all .md files in the docs directory + */ + +import { existsSync, readdirSync } from 'node:fs'; +import { basename, dirname, join } from 'node:path'; + +const SCRIPT_DIR = dirname(new URL(import.meta.url).pathname); +const DOCS_DIR = join(SCRIPT_DIR, '../docs'); + +if (!existsSync(DOCS_DIR)) { + console.error(`Error: Documentation directory not found at ${DOCS_DIR}`); + console.error('Run sync_docs.ts first to fetch documentation.'); + process.exit(1); +} + +console.log('Available Claude Code documentation topics:'); +console.log(''); + +try { + // List all .md files, remove extension, sort + const files = readdirSync(DOCS_DIR) + .filter((file) => file.endsWith('.md')) + .map((file) => basename(file, '.md')) + .sort(); + + for (const topic of files) { + console.log(` • ${topic}`); + } + + console.log(''); + console.log(`Total: ${files.length} topics`); + console.log(''); + console.log('Usage: cat docs/.md'); + console.log('Example: cat docs/hooks.md'); +} catch (e) { + console.error(`Error reading docs directory: ${e}`); + process.exit(1); +} diff --git a/skills/claude-code-knowledge/scripts/package.json b/skills/claude-code-knowledge/scripts/package.json new file mode 100644 index 0000000..7a900a3 --- /dev/null +++ b/skills/claude-code-knowledge/scripts/package.json @@ -0,0 +1,9 @@ +{ + "name": "claude-code-knowledge-scripts", + "version": "1.0.0", + "private": true, + "type": "module", + "devDependencies": { + "@types/bun": "latest" + } +} diff --git a/skills/claude-code-knowledge/scripts/skill-creator/init_skill.ts b/skills/claude-code-knowledge/scripts/skill-creator/init_skill.ts new file mode 100755 index 0000000..9c2141c --- /dev/null +++ b/skills/claude-code-knowledge/scripts/skill-creator/init_skill.ts @@ -0,0 +1,301 @@ +#!/usr/bin/env bun +/** + * Skill Initializer - Creates a new skill from template + * + * Usage: + * init_skill.ts --path + * + * Examples: + * init_skill.ts my-new-skill --path skills/public + * init_skill.ts my-api-helper --path skills/private + * init_skill.ts custom-skill --path /custom/location + */ + +import { existsSync } from 'node:fs'; +import { chmod, mkdir, writeFile } from 'node:fs/promises'; +import { join } from 'node:path'; + +const SKILL_TEMPLATE = (skillName: string, skillTitle: string) => `--- +name: ${skillName} +description: [TODO: Complete and informative explanation of what the skill does and when to use it. Include WHEN to use this skill - specific scenarios, file types, or tasks that trigger it.] +--- + +# ${skillTitle} + +## Overview + +[TODO: 1-2 sentences explaining what this skill enables] + +## Structuring This Skill + +[TODO: Choose the structure that best fits this skill's purpose. Common patterns: + +**1. Workflow-Based** (best for sequential processes) +- Works well when there are clear step-by-step procedures +- Example: DOCX skill with "Workflow Decision Tree" → "Reading" → "Creating" → "Editing" +- Structure: ## Overview → ## Workflow Decision Tree → ## Step 1 → ## Step 2... + +**2. Task-Based** (best for tool collections) +- Works well when the skill offers different operations/capabilities +- Example: PDF skill with "Quick Start" → "Merge PDFs" → "Split PDFs" → "Extract Text" +- Structure: ## Overview → ## Quick Start → ## Task Category 1 → ## Task Category 2... + +**3. Reference/Guidelines** (best for standards or specifications) +- Works well for brand guidelines, coding standards, or requirements +- Example: Brand styling with "Brand Guidelines" → "Colors" → "Typography" → "Features" +- Structure: ## Overview → ## Guidelines → ## Specifications → ## Usage... + +**4. Capabilities-Based** (best for integrated systems) +- Works well when the skill provides multiple interrelated features +- Example: Product Management with "Core Capabilities" → numbered capability list +- Structure: ## Overview → ## Core Capabilities → ### 1. Feature → ### 2. Feature... + +Patterns can be mixed and matched as needed. Most skills combine patterns (e.g., start with task-based, add workflow for complex operations). + +Delete this entire "Structuring This Skill" section when done - it's just guidance.] + +## [TODO: Replace with the first main section based on chosen structure] + +[TODO: Add content here. See examples in existing skills: +- Code samples for technical skills +- Decision trees for complex workflows +- Concrete examples with realistic user requests +- References to scripts/templates/references as needed] + +## Resources + +This skill includes example resource directories that demonstrate how to organize different types of bundled resources: + +### scripts/ +Executable code (Python/Bash/etc.) that can be run directly to perform specific operations. + +**Examples from other skills:** +- PDF skill: \`fill_fillable_fields.py\`, \`extract_form_field_info.py\` - utilities for PDF manipulation +- DOCX skill: \`document.py\`, \`utilities.py\` - Python modules for document processing + +**Appropriate for:** Python scripts, shell scripts, or any executable code that performs automation, data processing, or specific operations. + +**Note:** Scripts may be executed without loading into context, but can still be read by Claude for patching or environment adjustments. + +### references/ +Documentation and reference material intended to be loaded into context to inform Claude's process and thinking. + +**Examples from other skills:** +- Product management: \`communication.md\`, \`context_building.md\` - detailed workflow guides +- BigQuery: API reference documentation and query examples +- Finance: Schema documentation, company policies + +**Appropriate for:** In-depth documentation, API references, database schemas, comprehensive guides, or any detailed information that Claude should reference while working. + +### assets/ +Files not intended to be loaded into context, but rather used within the output Claude produces. + +**Examples from other skills:** +- Brand styling: PowerPoint template files (.pptx), logo files +- Frontend builder: HTML/React boilerplate project directories +- Typography: Font files (.ttf, .woff2) + +**Appropriate for:** Templates, boilerplate code, document templates, images, icons, fonts, or any files meant to be copied or used in the final output. + +--- + +**Any unneeded directories can be deleted.** Not every skill requires all three types of resources. +`; + +const EXAMPLE_SCRIPT = (skillName: string) => `#!/usr/bin/env python3 +""" +Example helper script for ${skillName} + +This is a placeholder script that can be executed directly. +Replace with actual implementation or delete if not needed. + +Example real scripts from other skills: +- pdf/scripts/fill_fillable_fields.py - Fills PDF form fields +- pdf/scripts/convert_pdf_to_images.py - Converts PDF pages to images +""" + +def main(): + print("This is an example script for ${skillName}") + # TODO: Add actual script logic here + # This could be data processing, file conversion, API calls, etc. + +if __name__ == "__main__": + main() +`; + +const EXAMPLE_REFERENCE = (skillTitle: string) => `# Reference Documentation for ${skillTitle} + +This is a placeholder for detailed reference documentation. +Replace with actual reference content or delete if not needed. + +Example real reference docs from other skills: +- product-management/references/communication.md - Comprehensive guide for status updates +- product-management/references/context_building.md - Deep-dive on gathering context +- bigquery/references/ - API references and query examples + +## When Reference Docs Are Useful + +Reference docs are ideal for: +- Comprehensive API documentation +- Detailed workflow guides +- Complex multi-step processes +- Information too lengthy for main SKILL.md +- Content that's only needed for specific use cases + +## Structure Suggestions + +### API Reference Example +- Overview +- Authentication +- Endpoints with examples +- Error codes +- Rate limits + +### Workflow Guide Example +- Prerequisites +- Step-by-step instructions +- Common patterns +- Troubleshooting +- Best practices +`; + +const EXAMPLE_ASSET = `# Example Asset File + +This placeholder represents where asset files would be stored. +Replace with actual asset files (templates, images, fonts, etc.) or delete if not needed. + +Asset files are NOT intended to be loaded into context, but rather used within +the output Claude produces. + +Example asset files from other skills: +- Brand guidelines: logo.png, slides_template.pptx +- Frontend builder: hello-world/ directory with HTML/React boilerplate +- Typography: custom-font.ttf, font-family.woff2 +- Data: sample_data.csv, test_dataset.json + +## Common Asset Types + +- Templates: .pptx, .docx, boilerplate directories +- Images: .png, .jpg, .svg, .gif +- Fonts: .ttf, .otf, .woff, .woff2 +- Boilerplate code: Project directories, starter files +- Icons: .ico, .svg +- Data files: .csv, .json, .xml, .yaml + +Note: This is a text placeholder. Actual assets can be any file type. +`; + +function titleCaseSkillName(skillName: string): string { + return skillName + .split('-') + .map((word) => word.charAt(0).toUpperCase() + word.slice(1)) + .join(' '); +} + +async function initSkill(skillName: string, path: string): Promise { + // Determine skill directory path + const skillDir = join(path, skillName); + + // Check if directory already exists + if (existsSync(skillDir)) { + console.log(`❌ Error: Skill directory already exists: ${skillDir}`); + return null; + } + + // Create skill directory + try { + await mkdir(skillDir, { recursive: true }); + console.log(`✅ Created skill directory: ${skillDir}`); + } catch (e) { + console.log(`❌ Error creating directory: ${e}`); + return null; + } + + // Create SKILL.md from template + const skillTitle = titleCaseSkillName(skillName); + const skillContent = SKILL_TEMPLATE(skillName, skillTitle); + + const skillMdPath = join(skillDir, 'SKILL.md'); + try { + await writeFile(skillMdPath, skillContent); + console.log('✅ Created SKILL.md'); + } catch (e) { + console.log(`❌ Error creating SKILL.md: ${e}`); + return null; + } + + // Create resource directories with example files + try { + // Create scripts/ directory with example script + const scriptsDir = join(skillDir, 'scripts'); + await mkdir(scriptsDir, { recursive: true }); + + const exampleScript = join(scriptsDir, 'example.py'); + await writeFile(exampleScript, EXAMPLE_SCRIPT(skillName)); + await chmod(exampleScript, 0o755); + console.log('✅ Created scripts/example.py'); + + // Create references/ directory with example reference doc + const referencesDir = join(skillDir, 'references'); + await mkdir(referencesDir, { recursive: true }); + + const exampleReference = join(referencesDir, 'api_reference.md'); + await writeFile(exampleReference, EXAMPLE_REFERENCE(skillTitle)); + console.log('✅ Created references/api_reference.md'); + + // Create assets/ directory with example asset placeholder + const assetsDir = join(skillDir, 'assets'); + await mkdir(assetsDir, { recursive: true }); + + const exampleAsset = join(assetsDir, 'example_asset.txt'); + await writeFile(exampleAsset, EXAMPLE_ASSET); + console.log('✅ Created assets/example_asset.txt'); + } catch (e) { + console.log(`❌ Error creating resource directories: ${e}`); + return null; + } + + // Print next steps + console.log(`\n✅ Skill '${skillName}' initialized successfully at ${skillDir}`); + console.log('\nNext steps:'); + console.log('1. Edit SKILL.md to complete the TODO items and update the description'); + console.log('2. Customize or delete the example files in scripts/, references/, and assets/'); + console.log('3. Run the validator when ready to check the skill structure'); + + return skillDir; +} + +async function main() { + const args = process.argv.slice(2); + + if (args.length < 3 || args[1] !== '--path') { + console.log('Usage: init_skill.ts --path '); + console.log('\nSkill name requirements:'); + console.log(" - Hyphen-case identifier (e.g., 'data-analyzer')"); + console.log(' - Lowercase letters, digits, and hyphens only'); + console.log(' - Max 40 characters'); + console.log(' - Must match directory name exactly'); + console.log('\nExamples:'); + console.log(' init_skill.ts my-new-skill --path skills/public'); + console.log(' init_skill.ts my-api-helper --path skills/private'); + console.log(' init_skill.ts custom-skill --path /custom/location'); + process.exit(1); + } + + const skillName = args[0]; + const path = args[2]; + + console.log(`🚀 Initializing skill: ${skillName}`); + console.log(` Location: ${path}`); + console.log(); + + const result = await initSkill(skillName, path); + + if (result) { + process.exit(0); + } else { + process.exit(1); + } +} + +main(); diff --git a/skills/claude-code-knowledge/scripts/skill-creator/package_skill.ts b/skills/claude-code-knowledge/scripts/skill-creator/package_skill.ts new file mode 100755 index 0000000..6ad0b98 --- /dev/null +++ b/skills/claude-code-knowledge/scripts/skill-creator/package_skill.ts @@ -0,0 +1,148 @@ +#!/usr/bin/env bun +/** + * Skill Packager - Creates a distributable zip file of a skill folder + * + * Usage: + * bun package_skill.ts [output-directory] + * + * Example: + * bun package_skill.ts skills/public/my-skill + * bun package_skill.ts skills/public/my-skill ./dist + */ + +import { existsSync, readdirSync, statSync } from 'node:fs'; +import { mkdir } from 'node:fs/promises'; +import { basename, join, relative, resolve } from 'node:path'; +import { validateSkill } from './quick_validate'; + +async function packageSkill(skillPath: string, outputDir?: string): Promise { + const skillPathResolved = resolve(skillPath); + + // Validate skill folder exists + if (!existsSync(skillPathResolved)) { + console.log(`❌ Error: Skill folder not found: ${skillPathResolved}`); + return null; + } + + if (!statSync(skillPathResolved).isDirectory()) { + console.log(`❌ Error: Path is not a directory: ${skillPathResolved}`); + return null; + } + + // Validate SKILL.md exists + const skillMd = join(skillPathResolved, 'SKILL.md'); + + if (!existsSync(skillMd)) { + console.log(`❌ Error: SKILL.md not found in ${skillPathResolved}`); + return null; + } + + // Run validation before packaging + console.log('🔍 Validating skill...'); + const { valid, message } = await validateSkill(skillPathResolved); + + if (!valid) { + console.log(`❌ Validation failed: ${message}`); + console.log(' Please fix the validation errors before packaging.'); + return null; + } + + console.log(`✅ ${message}\n`); + + // Determine output location + const skillName = basename(skillPathResolved); + let outputPath: string; + + if (outputDir) { + outputPath = resolve(outputDir); + if (!existsSync(outputPath)) { + await mkdir(outputPath, { recursive: true }); + } + } else { + outputPath = process.cwd(); + } + + const zipFilename = join(outputPath, `${skillName}.zip`); + + // Create the zip file using system zip command + try { + // Remove existing zip file if it exists + if (existsSync(zipFilename)) { + const { unlinkSync } = require('node:fs'); + unlinkSync(zipFilename); + } + + // Collect all files for display + const files: { path: string; arcname: string }[] = []; + + function walkDirectory(dir: string, baseDir: string) { + const entries = readdirSync(dir); + + for (const entry of entries) { + const fullPath = join(dir, entry); + const stat = statSync(fullPath); + + if (stat.isDirectory()) { + walkDirectory(fullPath, baseDir); + } else if (stat.isFile()) { + const arcname = relative(baseDir, fullPath); + files.push({ path: fullPath, arcname }); + } + } + } + + const parentDir = resolve(skillPathResolved, '..'); + walkDirectory(skillPathResolved, parentDir); + + // Create zip using system command + const { $ } = await import('bun'); + const cwd = parentDir; + const skillDirName = basename(skillPathResolved); + + await $`cd ${cwd} && zip -r ${zipFilename} ${skillDirName}`.quiet(); + + // List files that were added + for (const { arcname } of files) { + console.log(` Added: ${arcname}`); + } + + console.log(`\n✅ Successfully packaged skill to: ${zipFilename}`); + return zipFilename; + } catch (e) { + console.log(`❌ Error creating zip file: ${e}`); + return null; + } +} + +async function main() { + const args = process.argv.slice(2); + + if (args.length < 1) { + console.log('Usage: bun package_skill.ts [output-directory]'); + console.log('\nExample:'); + console.log(' bun package_skill.ts skills/public/my-skill'); + console.log(' bun package_skill.ts skills/public/my-skill ./dist'); + process.exit(1); + } + + const skillPath = args[0]; + const outputDir = args[1]; + + console.log(`📦 Packaging skill: ${skillPath}`); + + if (outputDir) { + console.log(` Output directory: ${outputDir}`); + } + + console.log(); + + const result = await packageSkill(skillPath, outputDir); + + if (result) { + process.exit(0); + } else { + process.exit(1); + } +} + +main(); diff --git a/skills/claude-code-knowledge/scripts/skill-creator/quick_validate.ts b/skills/claude-code-knowledge/scripts/skill-creator/quick_validate.ts new file mode 100755 index 0000000..585fd02 --- /dev/null +++ b/skills/claude-code-knowledge/scripts/skill-creator/quick_validate.ts @@ -0,0 +1,104 @@ +#!/usr/bin/env bun +/** + * Quick validation script for skills - minimal version + */ + +import { existsSync } from 'node:fs'; +import { readFile } from 'node:fs/promises'; +import { join } from 'node:path'; + +interface ValidationResult { + valid: boolean; + message: string; +} + +async function validateSkill(skillPath: string): Promise { + // Check SKILL.md exists + const skillMd = join(skillPath, 'SKILL.md'); + + if (!existsSync(skillMd)) { + return { valid: false, message: 'SKILL.md not found' }; + } + + // Read and validate frontmatter + const content = await readFile(skillMd, 'utf-8'); + + if (!content.startsWith('---')) { + return { valid: false, message: 'No YAML frontmatter found' }; + } + + // Extract frontmatter + const frontmatterMatch = content.match(/^---\n(.*?)\n---/s); + + if (!frontmatterMatch) { + return { valid: false, message: 'Invalid frontmatter format' }; + } + + const frontmatter = frontmatterMatch[1]; + + // Check required fields + if (!frontmatter.includes('name:')) { + return { valid: false, message: "Missing 'name' in frontmatter" }; + } + + if (!frontmatter.includes('description:')) { + return { valid: false, message: "Missing 'description' in frontmatter" }; + } + + // Extract name for validation + const nameMatch = frontmatter.match(/name:\s*(.+)/); + + if (nameMatch) { + const name = nameMatch[1].trim(); + + // Check naming convention (hyphen-case: lowercase with hyphens) + if (!/^[a-z0-9-]+$/.test(name)) { + return { + valid: false, + message: `Name '${name}' should be hyphen-case (lowercase letters, digits, and hyphens only)`, + }; + } + + if (name.startsWith('-') || name.endsWith('-') || name.includes('--')) { + return { + valid: false, + message: `Name '${name}' cannot start/end with hyphen or contain consecutive hyphens`, + }; + } + } + + // Extract and validate description + const descMatch = frontmatter.match(/description:\s*(.+)/); + + if (descMatch) { + const description = descMatch[1].trim(); + + // Check for angle brackets + if (description.includes('<') || description.includes('>')) { + return { valid: false, message: 'Description cannot contain angle brackets (< or >)' }; + } + } + + return { valid: true, message: 'Skill is valid!' }; +} + +async function main() { + const args = process.argv.slice(2); + + if (args.length !== 1) { + console.log('Usage: bun quick_validate.ts '); + process.exit(1); + } + + const { valid, message } = await validateSkill(args[0]); + console.log(message); + process.exit(valid ? 0 : 1); +} + +// Export for use in other scripts +export { validateSkill }; + +// Only run main if this is the main module +if (import.meta.main) { + main(); +} diff --git a/skills/skill-rules.json b/skills/skill-rules.json new file mode 100644 index 0000000..240a0b6 --- /dev/null +++ b/skills/skill-rules.json @@ -0,0 +1,68 @@ +{ + "version": "1.0", + "description": "Skill activation triggers for claude-code-knowledge plugin. Automatically suggests the skill when Claude Code topics are mentioned.", + "skills": { + "claude-code-knowledge": { + "type": "domain", + "enforcement": "suggest", + "priority": "high", + "description": "Official Claude Code documentation access with auto-sync", + "promptTriggers": { + "keywords": [ + "claude code", + "claudecode", + "claude-code", + "hook", + "hooks", + "mcp server", + "mcp servers", + "skill", + "skills", + "slash command", + "slash commands", + "claude settings", + "claude config", + "claude feature", + "claude capability", + "claude documentation", + "claude docs", + "sub-agent", + "subagent", + "checkpointing", + "claude memory", + "claude analytics", + "claude security", + "claude plugin", + "claude plugins" + ], + "intentPatterns": [ + "how\\s+(?:do|does|can)\\s+(?:i\\s+)?(?:use\\s+)?claude", + "can\\s+claude", + "does\\s+claude", + "is\\s+claude", + "what\\s+(?:is|are)\\s+claude.*(?:hook|mcp|skill|setting|feature|plugin)", + "how\\s+(?:to|do\\s+i).*(?:create|add|setup|configure|install).*(?:hook|mcp|skill|command|plugin)", + "claude.*(?:work|feature|capability|setting|config)", + "(?:create|add|setup|install|configure).*(?:hook|mcp\\s+server|skill|slash\\s+command|plugin)", + "how\\s+(?:to|do\\s+i).*claude.*(?:hook|mcp|skill|setting|plugin)", + "explain.*(?:hook|mcp|skill|slash\\s+command|plugin)", + "what.*claude.*(?:do|support|feature|capability)", + "claude.*(?:documentation|docs|reference|guide)" + ] + } + } + }, + "notes": { + "usage": "This skill-rules.json is part of the claude-code-knowledge plugin and will be merged with the user's project skill-rules.json when the plugin is installed.", + "enforcement_types": { + "suggest": "Skill suggestion appears but doesn't block execution" + }, + "priority_levels": { + "high": "Important - Trigger for most matches" + }, + "customization": { + "keywords": "Add more Claude Code related terms as the documentation expands", + "intentPatterns": "Use regex for flexible user intent matching" + } + } +}