Initial commit

This commit is contained in:
Zhongwei Li
2025-11-29 18:14:51 +08:00
commit e5cbabbd94
17 changed files with 2012 additions and 0 deletions

View File

@@ -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/<topic>.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)

View File

@@ -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/<topic>.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.

View File

@@ -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=="],
}
}

View File

@@ -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/<topic>.md');
console.log('Example: cat docs/hooks.md');
} catch (e) {
console.error(`Error reading docs directory: ${e}`);
process.exit(1);
}

View File

@@ -0,0 +1,9 @@
{
"name": "claude-code-knowledge-scripts",
"version": "1.0.0",
"private": true,
"type": "module",
"devDependencies": {
"@types/bun": "latest"
}
}

View File

@@ -0,0 +1,301 @@
#!/usr/bin/env bun
/**
* Skill Initializer - Creates a new skill from template
*
* Usage:
* init_skill.ts <skill-name> --path <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<string | null> {
// 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 <skill-name> --path <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();

View File

@@ -0,0 +1,148 @@
#!/usr/bin/env bun
/**
* Skill Packager - Creates a distributable zip file of a skill folder
*
* Usage:
* bun package_skill.ts <path/to/skill-folder> [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<string | null> {
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 <path/to/skill-folder> [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();

View File

@@ -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<ValidationResult> {
// 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 <skill_directory>');
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();
}

68
skills/skill-rules.json Normal file
View File

@@ -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"
}
}
}