📦 deps(thirdparty): update snapshots
This commit is contained in:
@@ -0,0 +1,130 @@
|
||||
# Context Modes
|
||||
|
||||
How `context` field controls skill execution environment.
|
||||
|
||||
## inherit (default)
|
||||
|
||||
Skill runs in the main conversation context.
|
||||
|
||||
**Characteristics:**
|
||||
- Access to full conversation history
|
||||
- Prior tool results available
|
||||
- Changes affect main context
|
||||
- Shared memory/state
|
||||
|
||||
**When to use:**
|
||||
- Skills that build on conversation context
|
||||
- Iterative workflows
|
||||
- Skills that need prior decisions/results
|
||||
|
||||
```yaml
|
||||
---
|
||||
name: code-improver
|
||||
context: inherit
|
||||
---
|
||||
```
|
||||
|
||||
## fork
|
||||
|
||||
Skill runs in isolated subagent context.
|
||||
|
||||
**Characteristics:**
|
||||
- Clean context (no conversation history)
|
||||
- Only skill instructions + user input
|
||||
- Results return to main context, but intermediate work doesn't
|
||||
- Can run in parallel
|
||||
|
||||
**When to use:**
|
||||
- Prevent context pollution from verbose analysis
|
||||
- Parallel execution of independent tasks
|
||||
- Specialized processing that shouldn't affect main flow
|
||||
- Security-sensitive operations with limited exposure
|
||||
|
||||
```yaml
|
||||
---
|
||||
name: security-audit
|
||||
context: fork
|
||||
agent: outfitter:reviewer
|
||||
model: sonnet
|
||||
---
|
||||
```
|
||||
|
||||
## Fork Configuration
|
||||
|
||||
When using `context: fork`, additional fields control the subagent:
|
||||
|
||||
| Field | Purpose | Example |
|
||||
|-------|---------|---------|
|
||||
| `agent` | Agent type for the fork | `outfitter:analyst` |
|
||||
| `model` | Model override | `haiku`, `sonnet`, `opus` |
|
||||
|
||||
### Agent Selection
|
||||
|
||||
Choose agents based on the skill's purpose:
|
||||
|
||||
| Agent | Best For |
|
||||
|-------|----------|
|
||||
| `outfitter:analyst` | Research, analysis, synthesis |
|
||||
| `outfitter:reviewer` | Code review, security audit |
|
||||
| `outfitter:engineer` | Implementation, refactoring |
|
||||
| `Explore` | Read-only codebase exploration |
|
||||
|
||||
### Model Selection
|
||||
|
||||
| Model | When to Use |
|
||||
|-------|-------------|
|
||||
| `haiku` | Fast, simple tasks, exploration |
|
||||
| `sonnet` | Balanced (default) |
|
||||
| `opus` | Complex reasoning, nuanced judgment |
|
||||
|
||||
## Patterns
|
||||
|
||||
### Analysis Without Pollution
|
||||
|
||||
```yaml
|
||||
---
|
||||
name: codebase-metrics
|
||||
context: fork
|
||||
agent: outfitter:analyst
|
||||
model: haiku
|
||||
description: Analyzes codebase for metrics without polluting main context
|
||||
---
|
||||
```
|
||||
|
||||
The skill can do extensive file reading and analysis; only the summary returns.
|
||||
|
||||
### Parallel Security Reviews
|
||||
|
||||
```yaml
|
||||
---
|
||||
name: security-scan
|
||||
context: fork
|
||||
agent: outfitter:reviewer
|
||||
model: sonnet
|
||||
---
|
||||
```
|
||||
|
||||
Multiple security scans can run in parallel via `run_in_background: true` in Task tool.
|
||||
|
||||
### Specialized Processing
|
||||
|
||||
```yaml
|
||||
---
|
||||
name: log-analyzer
|
||||
context: fork
|
||||
agent: Explore
|
||||
model: haiku
|
||||
description: Processes large log files without filling main context
|
||||
---
|
||||
```
|
||||
|
||||
## Decision Guide
|
||||
|
||||
| Scenario | Context | Why |
|
||||
|----------|---------|-----|
|
||||
| Building on conversation | `inherit` | Needs prior context |
|
||||
| One-off analysis | `fork` | Keep main context clean |
|
||||
| Verbose intermediate work | `fork` | Prevent pollution |
|
||||
| Parallel execution | `fork` | Independent subagents |
|
||||
| Iterative refinement | `inherit` | Needs state between calls |
|
||||
| Security-sensitive | `fork` | Isolated, controlled exposure |
|
||||
@@ -0,0 +1,272 @@
|
||||
# Integration Patterns
|
||||
|
||||
How skills integrate with commands, hooks, MCP servers, and agents.
|
||||
|
||||
## Skills + Commands
|
||||
|
||||
Commands can trigger skills implicitly through context.
|
||||
|
||||
### Pattern: Command as Entry Point
|
||||
|
||||
**Command** (`.claude/commands/audit-security.md`):
|
||||
|
||||
```markdown
|
||||
---
|
||||
description: Run security audit on codebase
|
||||
allowed-tools: Read Grep Glob
|
||||
---
|
||||
|
||||
Perform a security audit focusing on:
|
||||
- Authentication flows
|
||||
- Input validation
|
||||
- SQL injection vectors
|
||||
|
||||
Use the security-audit skill methodology.
|
||||
```
|
||||
|
||||
Claude recognizes the security context and activates the skill automatically.
|
||||
|
||||
### Pattern: Explicit Skill Loading
|
||||
|
||||
**Command**:
|
||||
|
||||
```markdown
|
||||
---
|
||||
description: Review PR with style checks
|
||||
---
|
||||
|
||||
Use the Skill tool to load the code-review skill, then:
|
||||
1. Review changes in the current PR
|
||||
2. Check against style guidelines
|
||||
3. Generate review comments
|
||||
```
|
||||
|
||||
## Skills + Hooks
|
||||
|
||||
Hooks can trigger skill loading or suggest usage.
|
||||
|
||||
### PostToolUse Suggestion
|
||||
|
||||
```json
|
||||
{
|
||||
"hooks": {
|
||||
"PostToolUse": [
|
||||
{
|
||||
"matcher": "Edit(*.ts)|Write(*.ts)",
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "echo 'Consider running the typescript-linter skill'"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### PreToolUse Validation
|
||||
|
||||
```json
|
||||
{
|
||||
"hooks": {
|
||||
"PreToolUse": [
|
||||
{
|
||||
"matcher": "Write(**/SKILL.md)|Edit(**/SKILL.md)",
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/validate-skill.ts"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Stop Hook for Quality Gates
|
||||
|
||||
```json
|
||||
{
|
||||
"hooks": {
|
||||
"Stop": [
|
||||
{
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "bun run lint && bun test"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Skills + MCP Servers
|
||||
|
||||
**Pattern**: Skills provide workflows, MCP servers provide data/tools.
|
||||
|
||||
### Architecture
|
||||
|
||||
- **MCP Server**: Handles authentication, rate limiting, data access
|
||||
- **Skill**: Handles business logic, formatting, workflows
|
||||
|
||||
### Example: Linear Integration
|
||||
|
||||
```yaml
|
||||
---
|
||||
name: linear-standup
|
||||
description: Generates team standup reports from Linear issues
|
||||
allowed-tools: mcp__linear__get_issues mcp__linear__get_projects
|
||||
---
|
||||
|
||||
# Linear Standup
|
||||
|
||||
Use the Linear MCP server to:
|
||||
1. Fetch issues by status and assignee
|
||||
2. Group by project and priority
|
||||
3. Format as standup report
|
||||
```
|
||||
|
||||
### Example: Memory Integration
|
||||
|
||||
```yaml
|
||||
---
|
||||
name: context-saver
|
||||
description: Saves important context to memory for later retrieval
|
||||
allowed-tools: mcp__memory__store mcp__memory__retrieve
|
||||
---
|
||||
|
||||
# Context Saver
|
||||
|
||||
When the user says "remember this" or similar:
|
||||
1. Extract key information
|
||||
2. Store via memory MCP server
|
||||
3. Confirm what was saved
|
||||
```
|
||||
|
||||
## Skills + Agents
|
||||
|
||||
Skills can specify agents for forked execution.
|
||||
|
||||
### Skill-Loaded Agent
|
||||
|
||||
```yaml
|
||||
---
|
||||
name: deep-analysis
|
||||
context: fork
|
||||
agent: outfitter:analyst
|
||||
model: opus
|
||||
description: Deep analysis requiring extensive reasoning
|
||||
---
|
||||
|
||||
# Deep Analysis
|
||||
|
||||
Perform thorough analysis of the given topic...
|
||||
```
|
||||
|
||||
When invoked, skill runs in a forked context using the analyst agent with opus model.
|
||||
|
||||
### Agent Loading Skills
|
||||
|
||||
Agents can load skills for specific capabilities:
|
||||
|
||||
```markdown
|
||||
# Security Reviewer Agent
|
||||
|
||||
When reviewing code:
|
||||
1. Load the security-patterns skill for vulnerability patterns
|
||||
2. Apply patterns to codebase
|
||||
3. Report findings with remediation
|
||||
```
|
||||
|
||||
## Master-Clone Pattern
|
||||
|
||||
Orchestrate specialized work with context isolation.
|
||||
|
||||
```
|
||||
User request
|
||||
|
|
||||
Master agent (main context)
|
||||
|
|
||||
+---> Fork: security-audit skill (isolated)
|
||||
| Returns: findings summary
|
||||
|
|
||||
+---> Fork: performance-analysis skill (isolated)
|
||||
| Returns: performance report
|
||||
|
|
||||
Master synthesizes results
|
||||
|
|
||||
Response to user
|
||||
```
|
||||
|
||||
### Implementation
|
||||
|
||||
**Skill 1** (`security-audit`):
|
||||
|
||||
```yaml
|
||||
---
|
||||
name: security-audit
|
||||
context: fork
|
||||
agent: outfitter:reviewer
|
||||
---
|
||||
```
|
||||
|
||||
**Skill 2** (`performance-analysis`):
|
||||
|
||||
```yaml
|
||||
---
|
||||
name: performance-analysis
|
||||
context: fork
|
||||
agent: outfitter:analyst
|
||||
---
|
||||
```
|
||||
|
||||
**Master agent invokes via Task tool:**
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"description": "Security audit",
|
||||
"prompt": "Run security-audit skill on src/auth/",
|
||||
"subagent_type": "outfitter:reviewer",
|
||||
"run_in_background": true
|
||||
},
|
||||
{
|
||||
"description": "Performance analysis",
|
||||
"prompt": "Run performance-analysis skill on src/api/",
|
||||
"subagent_type": "outfitter:analyst",
|
||||
"run_in_background": true
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## Chaining Skills
|
||||
|
||||
Skills can reference other skills for complex workflows.
|
||||
|
||||
### Sequential Chain
|
||||
|
||||
```markdown
|
||||
# Code Review Skill
|
||||
|
||||
1. Load `code-quality` skill for static analysis
|
||||
2. Load `security-patterns` skill for vulnerability check
|
||||
3. Load `performance-tips` skill for optimization suggestions
|
||||
4. Synthesize into unified review
|
||||
```
|
||||
|
||||
### Conditional Loading
|
||||
|
||||
```markdown
|
||||
# Smart Analyzer
|
||||
|
||||
Based on file type:
|
||||
- `.ts`/`.tsx`: Load `typescript-patterns` skill
|
||||
- `.rs`: Load `rust-patterns` skill
|
||||
- `.py`: Load `python-patterns` skill
|
||||
|
||||
Then proceed with analysis.
|
||||
```
|
||||
@@ -0,0 +1,126 @@
|
||||
# Performance Considerations
|
||||
|
||||
Token impact and optimization strategies for Claude Code skills.
|
||||
|
||||
## Token Impact
|
||||
|
||||
Every skill activation loads the full SKILL.md into context.
|
||||
|
||||
| SKILL.md Size | Approximate Tokens |
|
||||
|---------------|-------------------|
|
||||
| 100 lines | ~700 tokens |
|
||||
| 300 lines | ~2,000 tokens |
|
||||
| 500 lines | ~3,500 tokens |
|
||||
| 1,000 lines | ~7,000 tokens |
|
||||
| 1,500 lines | ~10,000 tokens |
|
||||
|
||||
**Rule**: Keep SKILL.md under 500 lines. Use progressive disclosure for details.
|
||||
|
||||
## Progressive Disclosure
|
||||
|
||||
Move details out of SKILL.md:
|
||||
|
||||
```
|
||||
skill-name/
|
||||
+-- SKILL.md # Core workflow (~300 lines)
|
||||
+-- references/ # Deep-dive docs
|
||||
| +-- patterns.md
|
||||
| +-- edge-cases.md
|
||||
+-- examples/ # Worked examples
|
||||
```
|
||||
|
||||
**Loading pattern**:
|
||||
1. SKILL.md loads on activation (~2,000 tokens)
|
||||
2. References load only when explicitly needed
|
||||
3. Examples load only for clarification
|
||||
|
||||
## Tool Restrictions Reduce Latency
|
||||
|
||||
Without `allowed-tools`: Claude asks permission for each tool.
|
||||
With `allowed-tools`: Listed tools run immediately.
|
||||
|
||||
```yaml
|
||||
# Fast (no permission prompts)
|
||||
allowed-tools: Read Grep Glob
|
||||
|
||||
# Slower (prompts for unlisted tools)
|
||||
# (no allowed-tools field)
|
||||
```
|
||||
|
||||
## Context Mode Optimization
|
||||
|
||||
### When to Fork
|
||||
|
||||
| Scenario | Recommendation |
|
||||
|----------|----------------|
|
||||
| Verbose intermediate work | Fork (keeps main context clean) |
|
||||
| Parallel independent tasks | Fork (run simultaneously) |
|
||||
| Building on conversation | Inherit (needs prior context) |
|
||||
| Simple one-shot task | Either (fork slightly cleaner) |
|
||||
|
||||
Fork trades context sharing for isolation. Each fork starts fresh.
|
||||
|
||||
### Fork Overhead
|
||||
|
||||
Each forked skill invocation:
|
||||
- Loads skill instructions fresh
|
||||
- No conversation history
|
||||
- Returns only final output
|
||||
|
||||
Benefit: Main context stays lean
|
||||
Cost: No state sharing between forks
|
||||
|
||||
## Description Efficiency
|
||||
|
||||
Descriptions load into system prompt for every message. Keep them concise.
|
||||
|
||||
```yaml
|
||||
# Good: Concise, specific
|
||||
description: Parse PDF files for text extraction. Use when working with .pdf files.
|
||||
|
||||
# Bad: Verbose, redundant
|
||||
description: This skill is designed to help you parse and extract text content from PDF files. It can be used whenever you need to work with PDF documents, extract text, or process PDF files for analysis.
|
||||
```
|
||||
|
||||
## Activation Efficiency
|
||||
|
||||
### Auto-Activation
|
||||
|
||||
Claude evaluates skill descriptions against user input. More specific descriptions activate faster (fewer false considerations).
|
||||
|
||||
```yaml
|
||||
# Specific (fast match)
|
||||
description: Extract tables from Excel .xlsx files
|
||||
|
||||
# Vague (many false considerations)
|
||||
description: Work with files and data
|
||||
```
|
||||
|
||||
### Manual Activation
|
||||
|
||||
For skills that shouldn't auto-activate:
|
||||
|
||||
```yaml
|
||||
disable-model-invocation: true
|
||||
```
|
||||
|
||||
Requires explicit Skill tool call. Avoids description evaluation overhead.
|
||||
|
||||
## Caching
|
||||
|
||||
Skills are cached per session. Changes require:
|
||||
|
||||
```
|
||||
/clear
|
||||
```
|
||||
|
||||
Or start a new session.
|
||||
|
||||
## Optimization Checklist
|
||||
|
||||
- [ ] SKILL.md under 500 lines
|
||||
- [ ] Details in `references/`
|
||||
- [ ] Specific description with trigger keywords
|
||||
- [ ] `allowed-tools` for frequently-used tools
|
||||
- [ ] `context: fork` for verbose processing
|
||||
- [ ] `disable-model-invocation: true` for manual-only skills
|
||||
Reference in New Issue
Block a user