[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -0,0 +1,317 @@
|
||||
---
|
||||
id: ai-anthropic-skills-patterns
|
||||
title: Anthropic Skills — modular agent capability
|
||||
category: Coding
|
||||
status: draft
|
||||
source_trust_level: B
|
||||
verification_status: conceptual
|
||||
created_at: 2026-05-09
|
||||
updated_at: 2026-05-09
|
||||
tags: [ai, anthropic, agents, vibe-coding]
|
||||
tech_stack: { language: "TS / Markdown", applicable_to: ["AI"] }
|
||||
applied_in: []
|
||||
aliases: [Anthropic Skills, agent skills, modular capability, prompt module, sub-agent, Claude skills]
|
||||
---
|
||||
|
||||
# Anthropic Skills
|
||||
|
||||
> Claude / agent 의 modular capability. **Markdown skill files + structured tools**. Re-usable + composable.
|
||||
|
||||
## 📖 핵심 개념
|
||||
- 매 skill = self-contained doc + tool.
|
||||
- Loaded on-demand.
|
||||
- Modular (mix and match).
|
||||
- LLM 가 자체 invoke.
|
||||
|
||||
## 💻 코드 패턴
|
||||
|
||||
### Skill structure
|
||||
```
|
||||
skills/
|
||||
├── pdf-processor/
|
||||
│ ├── SKILL.md # 의 description + 사용법
|
||||
│ ├── helpers.ts # tool implementation
|
||||
│ └── examples/ # sample input
|
||||
├── data-analyst/
|
||||
│ └── SKILL.md
|
||||
└── code-reviewer/
|
||||
└── SKILL.md
|
||||
```
|
||||
|
||||
### SKILL.md
|
||||
```markdown
|
||||
---
|
||||
name: PDF Processor
|
||||
description: Extract text and structure from PDF files
|
||||
---
|
||||
|
||||
# PDF Processor
|
||||
|
||||
When user asks about PDF processing:
|
||||
1. Use `extract_text(path)` to get raw text.
|
||||
2. Use `extract_tables(path)` for tables.
|
||||
3. Use `summarize(text)` for long docs.
|
||||
|
||||
## Tool examples
|
||||
|
||||
To extract: extract_text('/path/to/doc.pdf')
|
||||
To find tables: extract_tables(path, page=2)
|
||||
```
|
||||
|
||||
→ LLM 가 SKILL.md 읽음 + 자체 use.
|
||||
|
||||
### Discovery
|
||||
```
|
||||
Agent loop:
|
||||
1. User query.
|
||||
2. List available skills.
|
||||
3. LLM 가 relevant skill 선택.
|
||||
4. Skill description + tools 가 context 에.
|
||||
5. Use.
|
||||
```
|
||||
|
||||
→ Lazy load (token 절약).
|
||||
|
||||
### Skill 의 ingredient
|
||||
```
|
||||
- Description: 언제 use.
|
||||
- Examples: input → output.
|
||||
- Tools: 호출 가능.
|
||||
- Constraints: 안 do.
|
||||
- Workflow: step-by-step.
|
||||
```
|
||||
|
||||
### Multi-skill
|
||||
```
|
||||
User: "Analyze this PDF and write a summary email".
|
||||
|
||||
LLM 가:
|
||||
1. PDF Processor skill (extract).
|
||||
2. Data Analyst skill (analyze).
|
||||
3. Email Writer skill (write).
|
||||
|
||||
→ Compose multiple.
|
||||
```
|
||||
|
||||
### vs MCP server
|
||||
```
|
||||
MCP: standardized protocol (Anthropic).
|
||||
Skills: skill 의 unit (markdown + tool).
|
||||
|
||||
→ Skills 가 MCP 위에 사용 가능.
|
||||
```
|
||||
|
||||
→ [[AI_MCP_Server_Building]].
|
||||
|
||||
### Code skill 예
|
||||
```markdown
|
||||
---
|
||||
name: Code Reviewer
|
||||
description: Review code for bugs, style, performance
|
||||
---
|
||||
|
||||
# Code Reviewer
|
||||
|
||||
For each file:
|
||||
1. Check for common bugs (null check, off-by-one).
|
||||
2. Verify style (lint, format).
|
||||
3. Suggest performance improvement.
|
||||
4. Output JSON: { issues: [...], suggestions: [...] }
|
||||
|
||||
## Don't
|
||||
- Don't rewrite entire file.
|
||||
- Don't suggest opinion-based changes (subjective style).
|
||||
```
|
||||
|
||||
### Versioning
|
||||
```
|
||||
skills/
|
||||
├── pdf-processor/
|
||||
│ └── v2/
|
||||
│ ├── SKILL.md
|
||||
│ └── ...
|
||||
```
|
||||
|
||||
→ Multiple version, A/B test.
|
||||
|
||||
### Sharing
|
||||
```
|
||||
Internal company skills:
|
||||
- Marketing Copywriter.
|
||||
- Customer Support Triage.
|
||||
- Code Reviewer.
|
||||
- Data Analyst.
|
||||
|
||||
→ Library 가 매 team 가 share.
|
||||
```
|
||||
|
||||
### Public skill marketplace
|
||||
```
|
||||
2026 의 가능성:
|
||||
- "Skills marketplace" (Hugging Face 식).
|
||||
- 매 skill 가 review / rating.
|
||||
- 매 use case 의 best skill.
|
||||
```
|
||||
|
||||
### Custom Claude
|
||||
```
|
||||
Claude Pro / Team:
|
||||
- Custom instruction (system prompt).
|
||||
- Memory (persistent).
|
||||
- Skills (loaded on demand).
|
||||
|
||||
→ Specialized assistant.
|
||||
```
|
||||
|
||||
### Anthropic Computer Use + Skills
|
||||
```
|
||||
Skill: 'Search the web for X and summarize'.
|
||||
- Computer Use tool.
|
||||
- Browser navigation.
|
||||
- Reading + summary.
|
||||
|
||||
→ Modular agent.
|
||||
```
|
||||
|
||||
### Skill 작성 가이드
|
||||
```
|
||||
1. Description 가 specific (애매 X).
|
||||
2. Examples (input → expected output).
|
||||
3. Constraints (안 do).
|
||||
4. Tool 가 명확.
|
||||
5. Output format (JSON 등).
|
||||
6. Eval (test cases).
|
||||
```
|
||||
|
||||
### Iterative improve
|
||||
```
|
||||
1. Initial skill.
|
||||
2. Test cases.
|
||||
3. Fail case 분석.
|
||||
4. Skill update.
|
||||
5. Re-test.
|
||||
|
||||
→ "Skill engineering" 의 process.
|
||||
```
|
||||
|
||||
### vs prompt template
|
||||
```
|
||||
Prompt template: 1 prompt + variable.
|
||||
Skill: doc + tool + workflow.
|
||||
|
||||
→ Skill 가 더 큰 unit.
|
||||
```
|
||||
|
||||
### Production
|
||||
```
|
||||
- Code review bot (PR 매번).
|
||||
- Data analyst (Slack bot).
|
||||
- Customer support (1-line).
|
||||
- Personal assistant.
|
||||
|
||||
→ 매 task = own skill.
|
||||
```
|
||||
|
||||
### Skills + RAG
|
||||
```
|
||||
Skill 가 own knowledge base:
|
||||
- Doc 가 vector DB.
|
||||
- Skill 가 retrieve.
|
||||
- LLM 가 answer.
|
||||
|
||||
→ Skill 가 expert in domain.
|
||||
```
|
||||
|
||||
### Skills + sub-agent
|
||||
```
|
||||
Main agent: orchestrator.
|
||||
Skill A → sub-agent A.
|
||||
Skill B → sub-agent B.
|
||||
|
||||
→ Multi-agent coordination.
|
||||
```
|
||||
|
||||
→ [[AI_Multi_Agent_Coordination]].
|
||||
|
||||
### Anthropic 의 official format
|
||||
```
|
||||
2026 시점 evolving.
|
||||
- Markdown + frontmatter.
|
||||
- Tool definitions.
|
||||
- Examples.
|
||||
- Constraints.
|
||||
```
|
||||
|
||||
### Implementation 예 (TS)
|
||||
```ts
|
||||
class SkillManager {
|
||||
skills = new Map<string, Skill>();
|
||||
|
||||
register(skill: Skill) {
|
||||
this.skills.set(skill.name, skill);
|
||||
}
|
||||
|
||||
list(): SkillSummary[] {
|
||||
return [...this.skills.values()].map(s => ({
|
||||
name: s.name,
|
||||
description: s.description,
|
||||
}));
|
||||
}
|
||||
|
||||
async load(name: string): Promise<string> {
|
||||
const skill = this.skills.get(name);
|
||||
return skill ? skill.fullContent : '';
|
||||
}
|
||||
}
|
||||
|
||||
// LLM 의 system prompt 에 skill list.
|
||||
// LLM 가 'load_skill(name)' tool 호출.
|
||||
// Loaded skill content 가 context 에 추가.
|
||||
```
|
||||
|
||||
### 함정
|
||||
```
|
||||
- Skill 너무 많음 = LLM 가 헷갈림.
|
||||
- Description 가 vague.
|
||||
- Tool overlap.
|
||||
- No eval.
|
||||
- Version 관리 X.
|
||||
- Cross-skill state share.
|
||||
```
|
||||
|
||||
### Best practice
|
||||
```
|
||||
1. Specific name + description.
|
||||
2. Self-contained (depend X).
|
||||
3. Test case (10+).
|
||||
4. Versioning (skill v1, v2).
|
||||
5. Composable (다른 skill 와 stack).
|
||||
6. Idempotent (re-run OK).
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준
|
||||
| 작업 | 추천 |
|
||||
|---|---|
|
||||
| Specific task | Skill |
|
||||
| 일반 prompt | System prompt |
|
||||
| External integration | MCP |
|
||||
| Multi-step | Skill + sub-agent |
|
||||
| Re-usable across team | Skill library |
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Skill 너무 많음**: LLM 헷갈림.
|
||||
- **Vague description**: 안 invoke.
|
||||
- **No example**: bad output.
|
||||
- **Tool overlap**: confusion.
|
||||
- **No eval**: silent regression.
|
||||
|
||||
## 🤖 LLM 활용 힌트
|
||||
- Skills = modular capability.
|
||||
- Markdown + tool 가 unit.
|
||||
- MCP 위 가능.
|
||||
- Specific name + description 가 핵심.
|
||||
|
||||
## 🔗 관련 문서
|
||||
- [[AI_Skills_Patterns]]
|
||||
- [[AI_MCP_Integration_Patterns]]
|
||||
- [[AI_Multi_Agent_Coordination]]
|
||||
Reference in New Issue
Block a user