OpenClaw 完整备份 - 2026-03-21
This commit is contained in:
+63
@@ -0,0 +1,63 @@
|
||||
# Contributing to Agent Browser Skill
|
||||
|
||||
This skill wraps the agent-browser CLI. Determine where the problem lies before reporting issues.
|
||||
|
||||
## Issue Reporting Guide
|
||||
|
||||
### Open an issue in this repository if
|
||||
|
||||
- The skill documentation is unclear or missing
|
||||
- Examples in SKILL.md do not work
|
||||
- You need help using the CLI with this skill wrapper
|
||||
- The skill is missing a command or feature
|
||||
|
||||
### Open an issue at the agent-browser repository if
|
||||
|
||||
- The CLI crashes or throws errors
|
||||
- Commands do not behave as documented
|
||||
- You found a bug in the browser automation
|
||||
- You need a new feature in the CLI
|
||||
|
||||
## Before Opening an Issue
|
||||
|
||||
1. Install the latest version
|
||||
```bash
|
||||
npm install -g agent-browser@latest
|
||||
```
|
||||
|
||||
2. Test the command in your terminal to isolate the issue
|
||||
|
||||
## Issue Report Template
|
||||
|
||||
Use this template to provide necessary information.
|
||||
|
||||
```markdown
|
||||
### Description
|
||||
[Provide a clear and concise description of the bug]
|
||||
|
||||
### Reproduction Steps
|
||||
1. [First Step]
|
||||
2. [Second Step]
|
||||
3. [Observe error]
|
||||
|
||||
### Expected Behavior
|
||||
[Describe what you expected to happen]
|
||||
|
||||
### Environment Details
|
||||
- **Skill Version:** [e.g. 1.0.2]
|
||||
- **agent-browser Version:** [output of agent-browser --version]
|
||||
- **Node.js Version:** [output of node -v]
|
||||
- **Operating System:** [e.g. macOS Sonoma, Windows 11, Ubuntu 22.04]
|
||||
|
||||
### Additional Context
|
||||
- [Full error output or stack trace]
|
||||
- [Screenshots]
|
||||
- [Website URLs where the failure occurred]
|
||||
```
|
||||
|
||||
## Adding New Commands to the Skill
|
||||
|
||||
Update SKILL.md when the upstream CLI adds new commands.
|
||||
- Keep the Installation section
|
||||
- Add new commands in the correct category
|
||||
- Include usage examples
|
||||
Executable
+328
@@ -0,0 +1,328 @@
|
||||
---
|
||||
name: Agent Browser
|
||||
description: A fast Rust-based headless browser automation CLI with Node.js fallback that enables AI agents to navigate, click, type, and snapshot pages via structured commands.
|
||||
read_when:
|
||||
- Automating web interactions
|
||||
- Extracting structured data from pages
|
||||
- Filling forms programmatically
|
||||
- Testing web UIs
|
||||
metadata: {"clawdbot":{"emoji":"🌐","requires":{"bins":["node","npm"]}}}
|
||||
allowed-tools: Bash(agent-browser:*)
|
||||
---
|
||||
|
||||
# Browser Automation with agent-browser
|
||||
|
||||
## Installation
|
||||
|
||||
### npm recommended
|
||||
|
||||
```bash
|
||||
npm install -g agent-browser
|
||||
agent-browser install
|
||||
agent-browser install --with-deps
|
||||
```
|
||||
|
||||
### From Source
|
||||
|
||||
```bash
|
||||
git clone https://github.com/vercel-labs/agent-browser
|
||||
cd agent-browser
|
||||
pnpm install
|
||||
pnpm build
|
||||
agent-browser install
|
||||
```
|
||||
|
||||
## Quick start
|
||||
|
||||
```bash
|
||||
agent-browser open <url> # Navigate to page
|
||||
agent-browser snapshot -i # Get interactive elements with refs
|
||||
agent-browser click @e1 # Click element by ref
|
||||
agent-browser fill @e2 "text" # Fill input by ref
|
||||
agent-browser close # Close browser
|
||||
```
|
||||
|
||||
## Core workflow
|
||||
|
||||
1. Navigate: `agent-browser open <url>`
|
||||
2. Snapshot: `agent-browser snapshot -i` (returns elements with refs like `@e1`, `@e2`)
|
||||
3. Interact using refs from the snapshot
|
||||
4. Re-snapshot after navigation or significant DOM changes
|
||||
|
||||
## Commands
|
||||
|
||||
### Navigation
|
||||
|
||||
```bash
|
||||
agent-browser open <url> # Navigate to URL
|
||||
agent-browser back # Go back
|
||||
agent-browser forward # Go forward
|
||||
agent-browser reload # Reload page
|
||||
agent-browser close # Close browser
|
||||
```
|
||||
|
||||
### Snapshot (page analysis)
|
||||
|
||||
```bash
|
||||
agent-browser snapshot # Full accessibility tree
|
||||
agent-browser snapshot -i # Interactive elements only (recommended)
|
||||
agent-browser snapshot -c # Compact output
|
||||
agent-browser snapshot -d 3 # Limit depth to 3
|
||||
agent-browser snapshot -s "#main" # Scope to CSS selector
|
||||
```
|
||||
|
||||
### Interactions (use @refs from snapshot)
|
||||
|
||||
```bash
|
||||
agent-browser click @e1 # Click
|
||||
agent-browser dblclick @e1 # Double-click
|
||||
agent-browser focus @e1 # Focus element
|
||||
agent-browser fill @e2 "text" # Clear and type
|
||||
agent-browser type @e2 "text" # Type without clearing
|
||||
agent-browser press Enter # Press key
|
||||
agent-browser press Control+a # Key combination
|
||||
agent-browser keydown Shift # Hold key down
|
||||
agent-browser keyup Shift # Release key
|
||||
agent-browser hover @e1 # Hover
|
||||
agent-browser check @e1 # Check checkbox
|
||||
agent-browser uncheck @e1 # Uncheck checkbox
|
||||
agent-browser select @e1 "value" # Select dropdown
|
||||
agent-browser scroll down 500 # Scroll page
|
||||
agent-browser scrollintoview @e1 # Scroll element into view
|
||||
agent-browser drag @e1 @e2 # Drag and drop
|
||||
agent-browser upload @e1 file.pdf # Upload files
|
||||
```
|
||||
|
||||
### Get information
|
||||
|
||||
```bash
|
||||
agent-browser get text @e1 # Get element text
|
||||
agent-browser get html @e1 # Get innerHTML
|
||||
agent-browser get value @e1 # Get input value
|
||||
agent-browser get attr @e1 href # Get attribute
|
||||
agent-browser get title # Get page title
|
||||
agent-browser get url # Get current URL
|
||||
agent-browser get count ".item" # Count matching elements
|
||||
agent-browser get box @e1 # Get bounding box
|
||||
```
|
||||
|
||||
### Check state
|
||||
|
||||
```bash
|
||||
agent-browser is visible @e1 # Check if visible
|
||||
agent-browser is enabled @e1 # Check if enabled
|
||||
agent-browser is checked @e1 # Check if checked
|
||||
```
|
||||
|
||||
### Screenshots & PDF
|
||||
|
||||
```bash
|
||||
agent-browser screenshot # Screenshot to stdout
|
||||
agent-browser screenshot path.png # Save to file
|
||||
agent-browser screenshot --full # Full page
|
||||
agent-browser pdf output.pdf # Save as PDF
|
||||
```
|
||||
|
||||
### Video recording
|
||||
|
||||
```bash
|
||||
agent-browser record start ./demo.webm # Start recording (uses current URL + state)
|
||||
agent-browser click @e1 # Perform actions
|
||||
agent-browser record stop # Stop and save video
|
||||
agent-browser record restart ./take2.webm # Stop current + start new recording
|
||||
```
|
||||
|
||||
Recording creates a fresh context but preserves cookies/storage from your session. If no URL is provided, it automatically returns to your current page. For smooth demos, explore first, then start recording.
|
||||
|
||||
### Wait
|
||||
|
||||
```bash
|
||||
agent-browser wait @e1 # Wait for element
|
||||
agent-browser wait 2000 # Wait milliseconds
|
||||
agent-browser wait --text "Success" # Wait for text
|
||||
agent-browser wait --url "/dashboard" # Wait for URL pattern
|
||||
agent-browser wait --load networkidle # Wait for network idle
|
||||
agent-browser wait --fn "window.ready" # Wait for JS condition
|
||||
```
|
||||
|
||||
### Mouse control
|
||||
|
||||
```bash
|
||||
agent-browser mouse move 100 200 # Move mouse
|
||||
agent-browser mouse down left # Press button
|
||||
agent-browser mouse up left # Release button
|
||||
agent-browser mouse wheel 100 # Scroll wheel
|
||||
```
|
||||
|
||||
### Semantic locators (alternative to refs)
|
||||
|
||||
```bash
|
||||
agent-browser find role button click --name "Submit"
|
||||
agent-browser find text "Sign In" click
|
||||
agent-browser find label "Email" fill "user@test.com"
|
||||
agent-browser find first ".item" click
|
||||
agent-browser find nth 2 "a" text
|
||||
```
|
||||
|
||||
### Browser settings
|
||||
|
||||
```bash
|
||||
agent-browser set viewport 1920 1080 # Set viewport size
|
||||
agent-browser set device "iPhone 14" # Emulate device
|
||||
agent-browser set geo 37.7749 -122.4194 # Set geolocation
|
||||
agent-browser set offline on # Toggle offline mode
|
||||
agent-browser set headers '{"X-Key":"v"}' # Extra HTTP headers
|
||||
agent-browser set credentials user pass # HTTP basic auth
|
||||
agent-browser set media dark # Emulate color scheme
|
||||
```
|
||||
|
||||
### Cookies & Storage
|
||||
|
||||
```bash
|
||||
agent-browser cookies # Get all cookies
|
||||
agent-browser cookies set name value # Set cookie
|
||||
agent-browser cookies clear # Clear cookies
|
||||
agent-browser storage local # Get all localStorage
|
||||
agent-browser storage local key # Get specific key
|
||||
agent-browser storage local set k v # Set value
|
||||
agent-browser storage local clear # Clear all
|
||||
```
|
||||
|
||||
### Network
|
||||
|
||||
```bash
|
||||
agent-browser network route <url> # Intercept requests
|
||||
agent-browser network route <url> --abort # Block requests
|
||||
agent-browser network route <url> --body '{}' # Mock response
|
||||
agent-browser network unroute [url] # Remove routes
|
||||
agent-browser network requests # View tracked requests
|
||||
agent-browser network requests --filter api # Filter requests
|
||||
```
|
||||
|
||||
### Tabs & Windows
|
||||
|
||||
```bash
|
||||
agent-browser tab # List tabs
|
||||
agent-browser tab new [url] # New tab
|
||||
agent-browser tab 2 # Switch to tab
|
||||
agent-browser tab close # Close tab
|
||||
agent-browser window new # New window
|
||||
```
|
||||
|
||||
### Frames
|
||||
|
||||
```bash
|
||||
agent-browser frame "#iframe" # Switch to iframe
|
||||
agent-browser frame main # Back to main frame
|
||||
```
|
||||
|
||||
### Dialogs
|
||||
|
||||
```bash
|
||||
agent-browser dialog accept [text] # Accept dialog
|
||||
agent-browser dialog dismiss # Dismiss dialog
|
||||
```
|
||||
|
||||
### JavaScript
|
||||
|
||||
```bash
|
||||
agent-browser eval "document.title" # Run JavaScript
|
||||
```
|
||||
|
||||
### State management
|
||||
|
||||
```bash
|
||||
agent-browser state save auth.json # Save session state
|
||||
agent-browser state load auth.json # Load saved state
|
||||
```
|
||||
|
||||
## Example: Form submission
|
||||
|
||||
```bash
|
||||
agent-browser open https://example.com/form
|
||||
agent-browser snapshot -i
|
||||
# Output shows: textbox "Email" [ref=e1], textbox "Password" [ref=e2], button "Submit" [ref=e3]
|
||||
|
||||
agent-browser fill @e1 "user@example.com"
|
||||
agent-browser fill @e2 "password123"
|
||||
agent-browser click @e3
|
||||
agent-browser wait --load networkidle
|
||||
agent-browser snapshot -i # Check result
|
||||
```
|
||||
|
||||
## Example: Authentication with saved state
|
||||
|
||||
```bash
|
||||
# Login once
|
||||
agent-browser open https://app.example.com/login
|
||||
agent-browser snapshot -i
|
||||
agent-browser fill @e1 "username"
|
||||
agent-browser fill @e2 "password"
|
||||
agent-browser click @e3
|
||||
agent-browser wait --url "/dashboard"
|
||||
agent-browser state save auth.json
|
||||
|
||||
# Later sessions: load saved state
|
||||
agent-browser state load auth.json
|
||||
agent-browser open https://app.example.com/dashboard
|
||||
```
|
||||
|
||||
## Sessions (parallel browsers)
|
||||
|
||||
```bash
|
||||
agent-browser --session test1 open site-a.com
|
||||
agent-browser --session test2 open site-b.com
|
||||
agent-browser session list
|
||||
```
|
||||
|
||||
## JSON output (for parsing)
|
||||
|
||||
Add `--json` for machine-readable output:
|
||||
|
||||
```bash
|
||||
agent-browser snapshot -i --json
|
||||
agent-browser get text @e1 --json
|
||||
```
|
||||
|
||||
## Debugging
|
||||
|
||||
```bash
|
||||
agent-browser open example.com --headed # Show browser window
|
||||
agent-browser console # View console messages
|
||||
agent-browser console --clear # Clear console
|
||||
agent-browser errors # View page errors
|
||||
agent-browser errors --clear # Clear errors
|
||||
agent-browser highlight @e1 # Highlight element
|
||||
agent-browser trace start # Start recording trace
|
||||
agent-browser trace stop trace.zip # Stop and save trace
|
||||
agent-browser record start ./debug.webm # Record from current page
|
||||
agent-browser record stop # Save recording
|
||||
agent-browser --cdp 9222 snapshot # Connect via CDP
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- If the command is not found on Linux ARM64, use the full path in the bin folder.
|
||||
- If an element is not found, use snapshot to find the correct ref.
|
||||
- If the page is not loaded, add a wait command after navigation.
|
||||
- Use --headed to see the browser window for debugging.
|
||||
|
||||
## Options
|
||||
|
||||
- --session <name> uses an isolated session.
|
||||
- --json provides JSON output.
|
||||
- --full takes a full page screenshot.
|
||||
- --headed shows the browser window.
|
||||
- --timeout sets the command timeout in milliseconds.
|
||||
- --cdp <port> connects via Chrome DevTools Protocol.
|
||||
|
||||
## Notes
|
||||
|
||||
- Refs are stable per page load but change on navigation.
|
||||
- Always snapshot after navigation to get new refs.
|
||||
- Use fill instead of type for input fields to ensure existing text is cleared.
|
||||
|
||||
## Reporting Issues
|
||||
|
||||
- Skill issues: Open an issue at https://github.com/TheSethRose/Agent-Browser-CLI
|
||||
- agent-browser CLI issues: Open an issue at https://github.com/vercel-labs/agent-browser
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ownerId": "kn72ce44tqw8bnnnewrn1s5x3s7yz7sq",
|
||||
"slug": "agent-browser",
|
||||
"version": "0.2.0",
|
||||
"publishedAt": 1768882342488
|
||||
}
|
||||
Executable
+133
@@ -0,0 +1,133 @@
|
||||
---
|
||||
name: find-skills
|
||||
description: Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
|
||||
---
|
||||
|
||||
# Find Skills
|
||||
|
||||
This skill helps you discover and install skills from the open agent skills ecosystem.
|
||||
|
||||
## When to Use This Skill
|
||||
|
||||
Use this skill when the user:
|
||||
|
||||
- Asks "how do I do X" where X might be a common task with an existing skill
|
||||
- Says "find a skill for X" or "is there a skill for X"
|
||||
- Asks "can you do X" where X is a specialized capability
|
||||
- Expresses interest in extending agent capabilities
|
||||
- Wants to search for tools, templates, or workflows
|
||||
- Mentions they wish they had help with a specific domain (design, testing, deployment, etc.)
|
||||
|
||||
## What is the Skills CLI?
|
||||
|
||||
The Skills CLI (`npx skills`) is the package manager for the open agent skills ecosystem. Skills are modular packages that extend agent capabilities with specialized knowledge, workflows, and tools.
|
||||
|
||||
**Key commands:**
|
||||
|
||||
- `npx skills find [query]` - Search for skills interactively or by keyword
|
||||
- `npx skills add <package>` - Install a skill from GitHub or other sources
|
||||
- `npx skills check` - Check for skill updates
|
||||
- `npx skills update` - Update all installed skills
|
||||
|
||||
**Browse skills at:** https://skills.sh/
|
||||
|
||||
## How to Help Users Find Skills
|
||||
|
||||
### Step 1: Understand What They Need
|
||||
|
||||
When a user asks for help with something, identify:
|
||||
|
||||
1. The domain (e.g., React, testing, design, deployment)
|
||||
2. The specific task (e.g., writing tests, creating animations, reviewing PRs)
|
||||
3. Whether this is a common enough task that a skill likely exists
|
||||
|
||||
### Step 2: Search for Skills
|
||||
|
||||
Run the find command with a relevant query:
|
||||
|
||||
```bash
|
||||
npx skills find [query]
|
||||
```
|
||||
|
||||
For example:
|
||||
|
||||
- User asks "how do I make my React app faster?" → `npx skills find react performance`
|
||||
- User asks "can you help me with PR reviews?" → `npx skills find pr review`
|
||||
- User asks "I need to create a changelog" → `npx skills find changelog`
|
||||
|
||||
The command will return results like:
|
||||
|
||||
```
|
||||
Install with npx skills add <owner/repo@skill>
|
||||
|
||||
vercel-labs/agent-skills@vercel-react-best-practices
|
||||
└ https://skills.sh/vercel-labs/agent-skills/vercel-react-best-practices
|
||||
```
|
||||
|
||||
### Step 3: Present Options to the User
|
||||
|
||||
When you find relevant skills, present them to the user with:
|
||||
|
||||
1. The skill name and what it does
|
||||
2. The install command they can run
|
||||
3. A link to learn more at skills.sh
|
||||
|
||||
Example response:
|
||||
|
||||
```
|
||||
I found a skill that might help! The "vercel-react-best-practices" skill provides
|
||||
React and Next.js performance optimization guidelines from Vercel Engineering.
|
||||
|
||||
To install it:
|
||||
npx skills add vercel-labs/agent-skills@vercel-react-best-practices
|
||||
|
||||
Learn more: https://skills.sh/vercel-labs/agent-skills/vercel-react-best-practices
|
||||
```
|
||||
|
||||
### Step 4: Offer to Install
|
||||
|
||||
If the user wants to proceed, you can install the skill for them:
|
||||
|
||||
```bash
|
||||
npx skills add <owner/repo@skill> -g -y
|
||||
```
|
||||
|
||||
The `-g` flag installs globally (user-level) and `-y` skips confirmation prompts.
|
||||
|
||||
## Common Skill Categories
|
||||
|
||||
When searching, consider these common categories:
|
||||
|
||||
| Category | Example Queries |
|
||||
| --------------- | ---------------------------------------- |
|
||||
| Web Development | react, nextjs, typescript, css, tailwind |
|
||||
| Testing | testing, jest, playwright, e2e |
|
||||
| DevOps | deploy, docker, kubernetes, ci-cd |
|
||||
| Documentation | docs, readme, changelog, api-docs |
|
||||
| Code Quality | review, lint, refactor, best-practices |
|
||||
| Design | ui, ux, design-system, accessibility |
|
||||
| Productivity | workflow, automation, git |
|
||||
|
||||
## Tips for Effective Searches
|
||||
|
||||
1. **Use specific keywords**: "react testing" is better than just "testing"
|
||||
2. **Try alternative terms**: If "deploy" doesn't work, try "deployment" or "ci-cd"
|
||||
3. **Check popular sources**: Many skills come from `vercel-labs/agent-skills` or `ComposioHQ/awesome-claude-skills`
|
||||
|
||||
## When No Skills Are Found
|
||||
|
||||
If no relevant skills exist:
|
||||
|
||||
1. Acknowledge that no existing skill was found
|
||||
2. Offer to help with the task directly using your general capabilities
|
||||
3. Suggest the user could create their own skill with `npx skills init`
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
I searched for skills related to "xyz" but didn't find any matches.
|
||||
I can still help you with this task directly! Would you like me to proceed?
|
||||
|
||||
If this is something you do often, you could create your own skill:
|
||||
npx skills init my-xyz-skill
|
||||
```
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ownerId": "kn77ajmmqw3cgnc3ay1x3e0ccd805hsw",
|
||||
"slug": "find-skills",
|
||||
"version": "0.1.0",
|
||||
"publishedAt": 1769698710765
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
# Memory Vector Skill
|
||||
|
||||
> OpenClaw 向量记忆系统集成
|
||||
|
||||
## 功能
|
||||
|
||||
- 语义搜索记忆
|
||||
- 添加新记忆
|
||||
- 查看最近记忆
|
||||
- 记忆统计
|
||||
|
||||
## 环境变量
|
||||
|
||||
- `SILICONFLOW_API_KEY`: 硅基流动 API Key(可选,默认使用配置)
|
||||
|
||||
## 命令
|
||||
|
||||
### 搜索记忆
|
||||
|
||||
```
|
||||
向量搜索 [关键词]
|
||||
搜索记忆 [关键词]
|
||||
找找 [关键词]
|
||||
```
|
||||
|
||||
### 添加记忆
|
||||
|
||||
```
|
||||
添加记忆 [内容] --importance [1-5] --tags [标签]
|
||||
记住 [内容]
|
||||
```
|
||||
|
||||
### 查看状态
|
||||
|
||||
```
|
||||
记忆数量
|
||||
最近记忆
|
||||
记忆统计
|
||||
```
|
||||
|
||||
## 代码位置
|
||||
|
||||
```
|
||||
~/openclaw-memory-vector/
|
||||
├── vector_memory.py # 核心引擎
|
||||
├── memory_cli.py # CLI 工具
|
||||
└── data/memory/ # 数据目录
|
||||
```
|
||||
|
||||
## 使用示例
|
||||
|
||||
**搜索**:
|
||||
```
|
||||
用户:帮我搜一下之前关于股票的记录
|
||||
AI:好的,搜一下记忆库...
|
||||
```
|
||||
|
||||
**添加**:
|
||||
```
|
||||
用户:把这个记下来,铜陵有色成本7.9元
|
||||
AI:✅ 已添加到记忆库
|
||||
```
|
||||
|
||||
## 注意事项
|
||||
|
||||
1. 需要先安装依赖:`pip3 install chromadb openai sqlalchemy`
|
||||
2. 需要设置 `SILICONFLOW_API_KEY` 环境变量
|
||||
3. 数据存储在 `~/openclaw-memory-vector/data/`
|
||||
@@ -0,0 +1,148 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
OpenClaw 向量记忆系统 Skill
|
||||
用于 OpenClaw 主系统调用
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
|
||||
# 添加项目路径
|
||||
VECTOR_DIR = os.path.expanduser("~/openclaw-memory-vector")
|
||||
sys.path.insert(0, VECTOR_DIR)
|
||||
|
||||
from vector_memory import VectorMemorySystem
|
||||
from memory_backup import MemoryBackup
|
||||
|
||||
|
||||
class MemoryVectorSkill:
|
||||
"""向量记忆 skill"""
|
||||
|
||||
def __init__(self):
|
||||
self.api_key = os.getenv("SILICONFLOW_API_KEY", "sk-fpjdtxbxrhtekshircjhegstloxaodriekotjdyzzktyegcl")
|
||||
self.vm = None
|
||||
|
||||
def _get_vm(self):
|
||||
"""获取向量记忆系统实例"""
|
||||
if not self.vm:
|
||||
self.vm = VectorMemorySystem(
|
||||
api_key=self.api_key,
|
||||
persist_dir=os.path.join(VECTOR_DIR, "data/memory")
|
||||
)
|
||||
return self.vm
|
||||
|
||||
def search(self, query: str) -> str:
|
||||
"""搜索记忆"""
|
||||
vm = self._get_vm()
|
||||
results = vm.search(query, top_k=5)
|
||||
|
||||
if not results:
|
||||
return f"没有找到与「{query}」相关的记忆"
|
||||
|
||||
lines = [f"🔍 搜索「{query}」找到 {len(results)} 条相关记忆:\n"]
|
||||
|
||||
for i, r in enumerate(results, 1):
|
||||
similarity = r['similarity'] * 100
|
||||
lines.append(f"{i}. {r['content'][:60]}...")
|
||||
lines.append(f" 相似度: {similarity:.1f}%")
|
||||
lines.append("")
|
||||
|
||||
return "\n".join(lines)
|
||||
|
||||
def add(self, content: str, importance: int = 3, tags: list = None) -> str:
|
||||
"""添加记忆"""
|
||||
vm = self._get_vm()
|
||||
metadata = {"tags": tags or []} if tags else {}
|
||||
|
||||
vm.add_memory(content, metadata, importance)
|
||||
|
||||
stars = "⭐" * importance
|
||||
return f"✅ 已添加记忆 [{stars}]:{content[:40]}..."
|
||||
|
||||
def recent(self, limit: int = 10) -> str:
|
||||
"""查看最近记忆"""
|
||||
vm = self._get_vm()
|
||||
results = vm.get_recent(limit)
|
||||
|
||||
if not results:
|
||||
return "还没有任何记忆"
|
||||
|
||||
lines = [f"📅 最近 {len(results)} 条记忆:\n"]
|
||||
|
||||
for i, r in enumerate(results, 1):
|
||||
stars = "⭐" * r['importance']
|
||||
lines.append(f"{i}. [{stars}] {r['content'][:50]}...")
|
||||
lines.append(f" 时间: {r['created_at']}")
|
||||
lines.append("")
|
||||
|
||||
return "\n".join(lines)
|
||||
|
||||
def count(self) -> str:
|
||||
"""记忆统计"""
|
||||
vm = self._get_vm()
|
||||
total = vm.count()
|
||||
return f"📊 当前记忆总数: **{total}** 条"
|
||||
|
||||
def backup(self) -> str:
|
||||
"""手动备份"""
|
||||
backup = MemoryBackup()
|
||||
vm = self._get_vm()
|
||||
result = backup.backup_all(vm)
|
||||
|
||||
return f"""✅ 备份完成!
|
||||
- JSON: {result['json']}
|
||||
- Markdown: {result['markdown']}
|
||||
- 向量库: {result['vector']}"""
|
||||
|
||||
|
||||
def main():
|
||||
"""CLI 入口"""
|
||||
if len(sys.argv) < 2:
|
||||
print("用法: python3 skill.py <command> [args...]")
|
||||
print("命令: search <query>")
|
||||
print(" add <content> [--importance N] [--tags tag1,tag2]")
|
||||
print(" recent [N]")
|
||||
print(" count")
|
||||
print(" backup")
|
||||
sys.exit(1)
|
||||
|
||||
skill = MemoryVectorSkill()
|
||||
command = sys.argv[1]
|
||||
|
||||
if command == "search":
|
||||
query = " ".join(sys.argv[2:])
|
||||
print(skill.search(query))
|
||||
|
||||
elif command == "add":
|
||||
content = sys.argv[2]
|
||||
importance = 3
|
||||
tags = []
|
||||
|
||||
# 解析参数
|
||||
for i, arg in enumerate(sys.argv[3:]):
|
||||
if arg == "--importance" and i+3 < len(sys.argv):
|
||||
importance = int(sys.argv[i+4])
|
||||
elif arg == "--tags" and i+3 < len(sys.argv):
|
||||
tags = sys.argv[i+4].split(",")
|
||||
|
||||
print(skill.add(content, importance, tags))
|
||||
|
||||
elif command == "recent":
|
||||
limit = int(sys.argv[2]) if len(sys.argv) > 2 else 10
|
||||
print(skill.recent(limit))
|
||||
|
||||
elif command == "count":
|
||||
print(skill.count())
|
||||
|
||||
elif command == "backup":
|
||||
print(skill.backup())
|
||||
|
||||
else:
|
||||
print(f"未知命令: {command}")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+217
@@ -0,0 +1,217 @@
|
||||
---
|
||||
name: Self-Improving Agent (Proactive Self-Reflection)
|
||||
slug: self-improving
|
||||
version: 1.2.10
|
||||
homepage: https://clawic.com/skills/self-improving
|
||||
description: Self-reflection + Self-criticism + Self-learning + Self-organizing memory. Agent evaluates its own work, catches mistakes, and improves permanently. Use before starting work and after responding to the user.
|
||||
changelog: "Sharper setup now lists relevant memory before non-trivial work, with a title that highlights proactive self-reflection."
|
||||
metadata: {"clawdbot":{"emoji":"🧠","requires":{"bins":[]},"os":["linux","darwin","win32"],"configPaths":["~/self-improving/"]}}
|
||||
---
|
||||
|
||||
## When to Use
|
||||
|
||||
User corrects you or points out mistakes. You complete significant work and want to evaluate the outcome. You notice something in your own output that could be better. Knowledge should compound over time without manual maintenance.
|
||||
|
||||
## Architecture
|
||||
|
||||
Memory lives in `~/self-improving/` with tiered structure. If `~/self-improving/` does not exist, run `setup.md`.
|
||||
|
||||
```
|
||||
~/self-improving/
|
||||
├── memory.md # HOT: ≤100 lines, always loaded
|
||||
├── index.md # Topic index with line counts
|
||||
├── projects/ # Per-project learnings
|
||||
├── domains/ # Domain-specific (code, writing, comms)
|
||||
├── archive/ # COLD: decayed patterns
|
||||
└── corrections.md # Last 50 corrections log
|
||||
```
|
||||
|
||||
## Quick Reference
|
||||
|
||||
| Topic | File |
|
||||
|-------|------|
|
||||
| Setup guide | `setup.md` |
|
||||
| Memory template | `memory-template.md` |
|
||||
| Learning mechanics | `learning.md` |
|
||||
| Security boundaries | `boundaries.md` |
|
||||
| Scaling rules | `scaling.md` |
|
||||
| Memory operations | `operations.md` |
|
||||
| Self-reflection log | `reflections.md` |
|
||||
|
||||
## Detection Triggers
|
||||
|
||||
Log automatically when you notice these patterns:
|
||||
|
||||
**Corrections** → add to `corrections.md`, evaluate for `memory.md`:
|
||||
- "No, that's not right..."
|
||||
- "Actually, it should be..."
|
||||
- "You're wrong about..."
|
||||
- "I prefer X, not Y"
|
||||
- "Remember that I always..."
|
||||
- "I told you before..."
|
||||
- "Stop doing X"
|
||||
- "Why do you keep..."
|
||||
|
||||
**Preference signals** → add to `memory.md` if explicit:
|
||||
- "I like when you..."
|
||||
- "Always do X for me"
|
||||
- "Never do Y"
|
||||
- "My style is..."
|
||||
- "For [project], use..."
|
||||
|
||||
**Pattern candidates** → track, promote after 3x:
|
||||
- Same instruction repeated 3+ times
|
||||
- Workflow that works well repeatedly
|
||||
- User praises specific approach
|
||||
|
||||
**Ignore** (don't log):
|
||||
- One-time instructions ("do X now")
|
||||
- Context-specific ("in this file...")
|
||||
- Hypotheticals ("what if...")
|
||||
|
||||
## Self-Reflection
|
||||
|
||||
After completing significant work, pause and evaluate:
|
||||
|
||||
1. **Did it meet expectations?** — Compare outcome vs intent
|
||||
2. **What could be better?** — Identify improvements for next time
|
||||
3. **Is this a pattern?** — If yes, log to `corrections.md`
|
||||
|
||||
**When to self-reflect:**
|
||||
- After completing a multi-step task
|
||||
- After receiving feedback (positive or negative)
|
||||
- After fixing a bug or mistake
|
||||
- When you notice your output could be better
|
||||
|
||||
**Log format:**
|
||||
```
|
||||
CONTEXT: [type of task]
|
||||
REFLECTION: [what I noticed]
|
||||
LESSON: [what to do differently]
|
||||
```
|
||||
|
||||
**Example:**
|
||||
```
|
||||
CONTEXT: Building Flutter UI
|
||||
REFLECTION: Spacing looked off, had to redo
|
||||
LESSON: Check visual spacing before showing user
|
||||
```
|
||||
|
||||
Self-reflection entries follow the same promotion rules: 3x applied successfully → promote to HOT.
|
||||
|
||||
## Quick Queries
|
||||
|
||||
| User says | Action |
|
||||
|-----------|--------|
|
||||
| "What do you know about X?" | Search all tiers for X |
|
||||
| "What have you learned?" | Show last 10 from `corrections.md` |
|
||||
| "Show my patterns" | List `memory.md` (HOT) |
|
||||
| "Show [project] patterns" | Load `projects/{name}.md` |
|
||||
| "What's in warm storage?" | List files in `projects/` + `domains/` |
|
||||
| "Memory stats" | Show counts per tier |
|
||||
| "Forget X" | Remove from all tiers (confirm first) |
|
||||
| "Export memory" | ZIP all files |
|
||||
|
||||
## Memory Stats
|
||||
|
||||
On "memory stats" request, report:
|
||||
|
||||
```
|
||||
📊 Self-Improving Memory
|
||||
|
||||
HOT (always loaded):
|
||||
memory.md: X entries
|
||||
|
||||
WARM (load on demand):
|
||||
projects/: X files
|
||||
domains/: X files
|
||||
|
||||
COLD (archived):
|
||||
archive/: X files
|
||||
|
||||
Recent activity (7 days):
|
||||
Corrections logged: X
|
||||
Promotions to HOT: X
|
||||
Demotions to WARM: X
|
||||
```
|
||||
|
||||
## Core Rules
|
||||
|
||||
### 1. Learn from Corrections and Self-Reflection
|
||||
- Log when user explicitly corrects you
|
||||
- Log when you identify improvements in your own work
|
||||
- Never infer from silence alone
|
||||
- After 3 identical lessons → ask to confirm as rule
|
||||
|
||||
### 2. Tiered Storage
|
||||
| Tier | Location | Size Limit | Behavior |
|
||||
|------|----------|------------|----------|
|
||||
| HOT | memory.md | ≤100 lines | Always loaded |
|
||||
| WARM | projects/, domains/ | ≤200 lines each | Load on context match |
|
||||
| COLD | archive/ | Unlimited | Load on explicit query |
|
||||
|
||||
### 3. Automatic Promotion/Demotion
|
||||
- Pattern used 3x in 7 days → promote to HOT
|
||||
- Pattern unused 30 days → demote to WARM
|
||||
- Pattern unused 90 days → archive to COLD
|
||||
- Never delete without asking
|
||||
|
||||
### 4. Namespace Isolation
|
||||
- Project patterns stay in `projects/{name}.md`
|
||||
- Global preferences in HOT tier (memory.md)
|
||||
- Domain patterns (code, writing) in `domains/`
|
||||
- Cross-namespace inheritance: global → domain → project
|
||||
|
||||
### 5. Conflict Resolution
|
||||
When patterns contradict:
|
||||
1. Most specific wins (project > domain > global)
|
||||
2. Most recent wins (same level)
|
||||
3. If ambiguous → ask user
|
||||
|
||||
### 6. Compaction
|
||||
When file exceeds limit:
|
||||
1. Merge similar corrections into single rule
|
||||
2. Archive unused patterns
|
||||
3. Summarize verbose entries
|
||||
4. Never lose confirmed preferences
|
||||
|
||||
### 7. Transparency
|
||||
- Every action from memory → cite source: "Using X (from projects/foo.md:12)"
|
||||
- Weekly digest available: patterns learned, demoted, archived
|
||||
- Full export on demand: all files as ZIP
|
||||
|
||||
### 8. Security Boundaries
|
||||
See `boundaries.md` — never store credentials, health data, third-party info.
|
||||
|
||||
### 9. Graceful Degradation
|
||||
If context limit hit:
|
||||
1. Load only memory.md (HOT)
|
||||
2. Load relevant namespace on demand
|
||||
3. Never fail silently — tell user what's not loaded
|
||||
|
||||
## Scope
|
||||
|
||||
This skill ONLY:
|
||||
- Learns from user corrections and self-reflection
|
||||
- Stores preferences in local files (`~/self-improving/`)
|
||||
- Reads its own memory files on activation
|
||||
|
||||
This skill NEVER:
|
||||
- Accesses calendar, email, or contacts
|
||||
- Makes network requests
|
||||
- Reads files outside `~/self-improving/`
|
||||
- Infers preferences from silence or observation
|
||||
- Modifies its own SKILL.md
|
||||
|
||||
## Related Skills
|
||||
Install with `clawhub install <slug>` if user confirms:
|
||||
|
||||
- `memory` — Long-term memory patterns for agents
|
||||
- `learning` — Adaptive teaching and explanation
|
||||
- `decide` — Auto-learn decision patterns
|
||||
- `escalate` — Know when to ask vs act autonomously
|
||||
|
||||
## Feedback
|
||||
|
||||
- If useful: `clawhub star self-improving`
|
||||
- Stay updated: `clawhub sync`
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ownerId": "kn73vp5rarc3b14rc7wjcw8f8580t5d1",
|
||||
"slug": "self-improving",
|
||||
"version": "1.2.10",
|
||||
"publishedAt": 1772899624346
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
# Security Boundaries
|
||||
|
||||
## Never Store
|
||||
|
||||
| Category | Examples | Why |
|
||||
|----------|----------|-----|
|
||||
| Credentials | Passwords, API keys, tokens, SSH keys | Security breach risk |
|
||||
| Financial | Card numbers, bank accounts, crypto seeds | Fraud risk |
|
||||
| Medical | Diagnoses, medications, conditions | Privacy, HIPAA |
|
||||
| Biometric | Voice patterns, behavioral fingerprints | Identity theft |
|
||||
| Third parties | Info about other people | No consent obtained |
|
||||
| Location patterns | Home/work addresses, routines | Physical safety |
|
||||
| Access patterns | What systems user has access to | Privilege escalation |
|
||||
|
||||
## Store with Caution
|
||||
|
||||
| Category | Rules |
|
||||
|----------|-------|
|
||||
| Work context | Decay after project ends, never share cross-project |
|
||||
| Emotional states | Only if user explicitly shares, never infer |
|
||||
| Relationships | Roles only ("manager", "client"), no personal details |
|
||||
| Schedules | General patterns OK ("busy mornings"), not specific times |
|
||||
|
||||
## Transparency Requirements
|
||||
|
||||
1. **Audit on demand** — User asks "what do you know about me?" → full export
|
||||
2. **Source tracking** — Every item tagged with when/how learned
|
||||
3. **Explain actions** — "I did X because you said Y on [date]"
|
||||
4. **No hidden state** — If it affects behavior, it must be visible
|
||||
5. **Deletion verification** — Confirm item removed, show updated state
|
||||
|
||||
## Red Flags to Catch
|
||||
|
||||
If you find yourself doing any of these, STOP:
|
||||
|
||||
- Storing something "just in case it's useful later"
|
||||
- Inferring sensitive info from non-sensitive data
|
||||
- Keeping data after user asked to forget
|
||||
- Applying personal context to work (or vice versa)
|
||||
- Learning what makes user comply faster
|
||||
- Building psychological profile
|
||||
- Retaining third-party information
|
||||
|
||||
## Kill Switch
|
||||
|
||||
User says "forget everything":
|
||||
1. Export current memory to file (so they can review)
|
||||
2. Wipe all learned data
|
||||
3. Confirm: "Memory cleared. Starting fresh."
|
||||
4. Do not retain "ghost patterns" in behavior
|
||||
|
||||
## Consent Model
|
||||
|
||||
| Data Type | Consent Level |
|
||||
|-----------|---------------|
|
||||
| Explicit corrections | Implied by correction itself |
|
||||
| Inferred preferences | Ask after 3 observations |
|
||||
| Context/project data | Ask when first detected |
|
||||
| Cross-session patterns | Explicit opt-in required |
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
# Corrections Log — Template
|
||||
|
||||
> This file is created in `~/self-improving/corrections.md` when you first use the skill.
|
||||
> Keeps the last 50 corrections. Older entries are evaluated for promotion or archived.
|
||||
|
||||
## Example Entries
|
||||
|
||||
```markdown
|
||||
## 2026-02-19
|
||||
|
||||
### 14:32 — Code style
|
||||
- **Correction:** "Use 2-space indentation, not 4"
|
||||
- **Context:** Editing TypeScript file
|
||||
- **Count:** 1 (first occurrence)
|
||||
|
||||
### 16:15 — Communication
|
||||
- **Correction:** "Don't start responses with 'Great question!'"
|
||||
- **Context:** Chat response
|
||||
- **Count:** 3 → **PROMOTED to memory.md**
|
||||
|
||||
## 2026-02-18
|
||||
|
||||
### 09:00 — Project: website
|
||||
- **Correction:** "For this project, always use Tailwind"
|
||||
- **Context:** CSS discussion
|
||||
- **Action:** Added to projects/website.md
|
||||
```
|
||||
|
||||
## Log Format
|
||||
|
||||
Each entry includes:
|
||||
- **Timestamp** — When the correction happened
|
||||
- **Correction** — What the user said
|
||||
- **Context** — What triggered it
|
||||
- **Count** — How many times (for promotion tracking)
|
||||
- **Action** — Where it was stored (if promoted)
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
# Learning Mechanics
|
||||
|
||||
## What Triggers Learning
|
||||
|
||||
| Trigger | Confidence | Action |
|
||||
|---------|------------|--------|
|
||||
| "No, do X instead" | High | Log correction immediately |
|
||||
| "I told you before..." | High | Flag as repeated, bump priority |
|
||||
| "Always/Never do X" | Confirmed | Promote to preference |
|
||||
| User edits your output | Medium | Log as tentative pattern |
|
||||
| Same correction 3x | Confirmed | Ask to make permanent |
|
||||
| "For this project..." | Scoped | Write to project namespace |
|
||||
|
||||
## What Does NOT Trigger Learning
|
||||
|
||||
- Silence (not confirmation)
|
||||
- Single instance of anything
|
||||
- Hypothetical discussions
|
||||
- Third-party preferences ("John likes...")
|
||||
- Group chat patterns (unless user confirms)
|
||||
- Implied preferences (never infer)
|
||||
|
||||
## Correction Classification
|
||||
|
||||
### By Type
|
||||
| Type | Example | Namespace |
|
||||
|------|---------|-----------|
|
||||
| Format | "Use bullets not prose" | global |
|
||||
| Technical | "SQLite not Postgres" | domain/code |
|
||||
| Communication | "Shorter messages" | global |
|
||||
| Project-specific | "This repo uses Tailwind" | projects/{name} |
|
||||
| Person-specific | "Marcus wants BLUF" | domains/comms |
|
||||
|
||||
### By Scope
|
||||
```
|
||||
Global: applies everywhere
|
||||
└── Domain: applies to category (code, writing, comms)
|
||||
└── Project: applies to specific context
|
||||
└── Temporary: applies to this session only
|
||||
```
|
||||
|
||||
## Confirmation Flow
|
||||
|
||||
After 3 similar corrections:
|
||||
```
|
||||
Agent: "I've noticed you prefer X over Y (corrected 3 times).
|
||||
Should I always do this?
|
||||
- Yes, always
|
||||
- Only in [context]
|
||||
- No, case by case"
|
||||
|
||||
User: "Yes, always"
|
||||
|
||||
Agent: → Moves to Confirmed Preferences
|
||||
→ Removes from correction counter
|
||||
→ Cites source on future use
|
||||
```
|
||||
|
||||
## Pattern Evolution
|
||||
|
||||
### Stages
|
||||
1. **Tentative** — Single correction, watch for repetition
|
||||
2. **Emerging** — 2 corrections, likely pattern
|
||||
3. **Pending** — 3 corrections, ask for confirmation
|
||||
4. **Confirmed** — User approved, permanent unless reversed
|
||||
5. **Archived** — Unused 90+ days, preserved but inactive
|
||||
|
||||
### Reversal
|
||||
User can always reverse:
|
||||
```
|
||||
User: "Actually, I changed my mind about X"
|
||||
|
||||
Agent:
|
||||
1. Archive old pattern (keep history)
|
||||
2. Log reversal with timestamp
|
||||
3. Add new preference as tentative
|
||||
4. "Got it. I'll do Y now. (Previous: X, archived)"
|
||||
```
|
||||
|
||||
## Anti-Patterns
|
||||
|
||||
### Never Learn
|
||||
- What makes user comply faster (manipulation)
|
||||
- Emotional triggers or vulnerabilities
|
||||
- Patterns from other users (even if shared device)
|
||||
- Anything that feels "creepy" to surface
|
||||
|
||||
### Avoid
|
||||
- Over-generalizing from single instance
|
||||
- Learning style over substance
|
||||
- Assuming preference stability
|
||||
- Ignoring context shifts
|
||||
|
||||
## Quality Signals
|
||||
|
||||
### Good Learning
|
||||
- User explicitly states preference
|
||||
- Pattern consistent across contexts
|
||||
- Correction improves outcomes
|
||||
- User confirms when asked
|
||||
|
||||
### Bad Learning
|
||||
- Inferred from silence
|
||||
- Contradicts recent behavior
|
||||
- Only works in narrow context
|
||||
- User never confirmed
|
||||
@@ -0,0 +1,60 @@
|
||||
# Memory Template
|
||||
|
||||
Copy this structure to `~/self-improving/memory.md` on first use.
|
||||
|
||||
```markdown
|
||||
# Self-Improving Memory
|
||||
|
||||
## Confirmed Preferences
|
||||
<!-- Patterns confirmed by user, never decay -->
|
||||
|
||||
## Active Patterns
|
||||
<!-- Patterns observed 3+ times, subject to decay -->
|
||||
|
||||
## Recent (last 7 days)
|
||||
<!-- New corrections pending confirmation -->
|
||||
```
|
||||
|
||||
## Initial Directory Structure
|
||||
|
||||
Create on first activation:
|
||||
|
||||
```bash
|
||||
mkdir -p ~/self-improving/{projects,domains,archive}
|
||||
touch ~/self-improving/{memory.md,index.md,corrections.md}
|
||||
```
|
||||
|
||||
## Index Template
|
||||
|
||||
For `~/self-improving/index.md`:
|
||||
|
||||
```markdown
|
||||
# Memory Index
|
||||
|
||||
## HOT
|
||||
- memory.md: 0 lines
|
||||
|
||||
## WARM
|
||||
- (no namespaces yet)
|
||||
|
||||
## COLD
|
||||
- (no archives yet)
|
||||
|
||||
Last compaction: never
|
||||
```
|
||||
|
||||
## Corrections Log Template
|
||||
|
||||
For `~/self-improving/corrections.md`:
|
||||
|
||||
```markdown
|
||||
# Corrections Log
|
||||
|
||||
<!-- Format:
|
||||
## YYYY-MM-DD
|
||||
- [HH:MM] Changed X → Y
|
||||
Type: format|technical|communication|project
|
||||
Context: where correction happened
|
||||
Confirmed: pending (N/3) | yes | no
|
||||
-->
|
||||
```
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
# HOT Memory — Template
|
||||
|
||||
> This file is created in `~/self-improving/memory.md` when you first use the skill.
|
||||
> Keep it ≤100 lines. Most-used patterns live here.
|
||||
|
||||
## Example Entries
|
||||
|
||||
```markdown
|
||||
## Preferences
|
||||
- Code style: Prefer explicit over implicit
|
||||
- Communication: Direct, no fluff
|
||||
- Time zone: Europe/Madrid
|
||||
|
||||
## Patterns (promoted from corrections)
|
||||
- Always use TypeScript strict mode
|
||||
- Prefer pnpm over npm
|
||||
- Format: ISO 8601 for dates
|
||||
|
||||
## Project defaults
|
||||
- Tests: Jest with coverage >80%
|
||||
- Commits: Conventional commits format
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
The agent will:
|
||||
1. Load this file on every session
|
||||
2. Add entries when patterns are used 3x in 7 days
|
||||
3. Demote unused entries to WARM after 30 days
|
||||
4. Never exceed 100 lines (compacts automatically)
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
# Memory Operations
|
||||
|
||||
## User Commands
|
||||
|
||||
| Command | Action |
|
||||
|---------|--------|
|
||||
| "What do you know about X?" | Search all tiers, return matches with sources |
|
||||
| "Show my memory" | Display memory.md contents |
|
||||
| "Show [project] patterns" | Load and display specific namespace |
|
||||
| "Forget X" | Remove from all tiers, confirm deletion |
|
||||
| "Forget everything" | Full wipe with export option |
|
||||
| "What changed recently?" | Show last 20 corrections |
|
||||
| "Export memory" | Generate downloadable archive |
|
||||
| "Memory status" | Show tier sizes, last compaction, health |
|
||||
|
||||
## Automatic Operations
|
||||
|
||||
### On Session Start
|
||||
1. Load memory.md (HOT tier)
|
||||
2. Check index.md for context hints
|
||||
3. If project detected → preload relevant namespace
|
||||
|
||||
### On Correction Received
|
||||
```
|
||||
1. Parse correction type (preference, pattern, override)
|
||||
2. Check if duplicate (exists in any tier)
|
||||
3. If new:
|
||||
- Add to corrections.md with timestamp
|
||||
- Increment correction counter
|
||||
4. If duplicate:
|
||||
- Bump counter, update timestamp
|
||||
- If counter >= 3: ask to confirm as rule
|
||||
5. Determine namespace (global, domain, project)
|
||||
6. Write to appropriate file
|
||||
7. Update index.md line counts
|
||||
```
|
||||
|
||||
### On Pattern Match
|
||||
When applying learned pattern:
|
||||
```
|
||||
1. Find pattern source (file:line)
|
||||
2. Apply pattern
|
||||
3. Cite source: "Using X (from memory.md:15)"
|
||||
4. Log usage for decay tracking
|
||||
```
|
||||
|
||||
### Weekly Maintenance (Cron)
|
||||
```
|
||||
1. Scan all files for decay candidates
|
||||
2. Move unused >30 days to WARM
|
||||
3. Archive unused >90 days to COLD
|
||||
4. Run compaction if any file >limit
|
||||
5. Update index.md
|
||||
6. Generate weekly digest (optional)
|
||||
```
|
||||
|
||||
## File Formats
|
||||
|
||||
### memory.md (HOT)
|
||||
```markdown
|
||||
# Self-Improving Memory
|
||||
|
||||
## Confirmed Preferences
|
||||
- format: bullet points over prose (confirmed 2026-01)
|
||||
- tone: direct, no hedging (confirmed 2026-01)
|
||||
|
||||
## Active Patterns
|
||||
- "looks good" = approval to proceed (used 15x)
|
||||
- single emoji = acknowledged (used 8x)
|
||||
|
||||
## Recent (last 7 days)
|
||||
- prefer SQLite for MVPs (corrected 02-14)
|
||||
```
|
||||
|
||||
### corrections.md
|
||||
```markdown
|
||||
# Corrections Log
|
||||
|
||||
## 2026-02-15
|
||||
- [14:32] Changed verbose explanation → bullet summary
|
||||
Type: communication
|
||||
Context: Telegram response
|
||||
Confirmed: pending (1/3)
|
||||
|
||||
## 2026-02-14
|
||||
- [09:15] Use SQLite not Postgres for MVP
|
||||
Type: technical
|
||||
Context: database discussion
|
||||
Confirmed: yes (said "always")
|
||||
```
|
||||
|
||||
### projects/{name}.md
|
||||
```markdown
|
||||
# Project: my-app
|
||||
|
||||
Inherits: global, domains/code
|
||||
|
||||
## Patterns
|
||||
- Use Tailwind (project standard)
|
||||
- No Prettier (eslint only)
|
||||
- Deploy via GitLab CI
|
||||
|
||||
## Overrides
|
||||
- semicolons: yes (overrides global no-semi)
|
||||
|
||||
## History
|
||||
- Created: 2026-01-15
|
||||
- Last active: 2026-02-15
|
||||
- Corrections: 12
|
||||
```
|
||||
|
||||
## Edge Case Handling
|
||||
|
||||
### Contradiction Detected
|
||||
```
|
||||
Pattern A: "Use tabs" (global, confirmed)
|
||||
Pattern B: "Use spaces" (project, corrected today)
|
||||
|
||||
Resolution:
|
||||
1. Project overrides global → use spaces for this project
|
||||
2. Log conflict in corrections.md
|
||||
3. Ask: "Should spaces apply only to this project or everywhere?"
|
||||
```
|
||||
|
||||
### User Changes Mind
|
||||
```
|
||||
Old: "Always use formal tone"
|
||||
New: "Actually, casual is fine"
|
||||
|
||||
Action:
|
||||
1. Archive old pattern with timestamp
|
||||
2. Add new pattern as tentative
|
||||
3. Keep archived for reference ("You previously preferred formal")
|
||||
```
|
||||
|
||||
### Context Ambiguity
|
||||
```
|
||||
User says: "Remember I like X"
|
||||
|
||||
But which namespace?
|
||||
1. Check current context (project? domain?)
|
||||
2. If unclear, ask: "Should this apply globally or just here?"
|
||||
3. Default to most specific active context
|
||||
```
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
# Self-Reflections Log
|
||||
|
||||
Track self-reflections from completed work. Each entry captures what the agent learned from evaluating its own output.
|
||||
|
||||
## Format
|
||||
|
||||
```
|
||||
## [Date] — [Task Type]
|
||||
|
||||
**What I did:** Brief description
|
||||
**Outcome:** What happened (success, partial, failed)
|
||||
**Reflection:** What I noticed about my work
|
||||
**Lesson:** What to do differently next time
|
||||
**Status:** ⏳ candidate | ✅ promoted | 📦 archived
|
||||
```
|
||||
|
||||
## Example Entry
|
||||
|
||||
```
|
||||
## 2026-02-25 — Flutter UI Build
|
||||
|
||||
**What I did:** Built a settings screen with toggle switches
|
||||
**Outcome:** User said "spacing looks off"
|
||||
**Reflection:** I focused on functionality, didn't visually check the result
|
||||
**Lesson:** Always take a screenshot and evaluate visual balance before showing user
|
||||
**Status:** ✅ promoted to domains/flutter.md
|
||||
```
|
||||
|
||||
## Entries
|
||||
|
||||
(New entries appear here)
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
# Scaling Patterns
|
||||
|
||||
## Volume Thresholds
|
||||
|
||||
| Scale | Entries | Strategy |
|
||||
|-------|---------|----------|
|
||||
| Small | <100 | Single memory.md, no namespacing |
|
||||
| Medium | 100-500 | Split into domains/, basic indexing |
|
||||
| Large | 500-2000 | Full namespace hierarchy, aggressive compaction |
|
||||
| Massive | >2000 | Archive yearly, summary-only HOT tier |
|
||||
|
||||
## When to Split
|
||||
|
||||
Create new namespace file when:
|
||||
- Single file exceeds 200 lines
|
||||
- Topic has 10+ distinct corrections
|
||||
- User explicitly separates contexts ("for work...", "in this project...")
|
||||
|
||||
## Compaction Rules
|
||||
|
||||
### Merge Similar Corrections
|
||||
```
|
||||
BEFORE (3 entries):
|
||||
- [02-01] Use tabs not spaces
|
||||
- [02-03] Indent with tabs
|
||||
- [02-05] Tab indentation please
|
||||
|
||||
AFTER (1 entry):
|
||||
- Indentation: tabs (confirmed 3x, 02-01 to 02-05)
|
||||
```
|
||||
|
||||
### Summarize Verbose Patterns
|
||||
```
|
||||
BEFORE:
|
||||
- When writing emails to Marcus, use bullet points, keep under 5 items,
|
||||
no jargon, bottom-line first, he prefers morning sends
|
||||
|
||||
AFTER:
|
||||
- Marcus emails: bullets ≤5, no jargon, BLUF, AM preferred
|
||||
```
|
||||
|
||||
### Archive with Context
|
||||
When moving to COLD:
|
||||
```
|
||||
## Archived 2026-02
|
||||
|
||||
### Project: old-app (inactive since 2025-08)
|
||||
- Used Vue 2 patterns
|
||||
- Preferred Vuex over Pinia
|
||||
- CI on Jenkins (deprecated)
|
||||
|
||||
Reason: Project completed, patterns unlikely to apply
|
||||
```
|
||||
|
||||
## Index Maintenance
|
||||
|
||||
`index.md` tracks all namespaces:
|
||||
```markdown
|
||||
# Memory Index
|
||||
|
||||
## HOT (always loaded)
|
||||
- memory.md: 87 lines, updated 2026-02-15
|
||||
|
||||
## WARM (load on match)
|
||||
- projects/current-app.md: 45 lines
|
||||
- projects/side-project.md: 23 lines
|
||||
- domains/code.md: 112 lines
|
||||
- domains/writing.md: 34 lines
|
||||
|
||||
## COLD (archive)
|
||||
- archive/2025.md: 234 lines
|
||||
- archive/2024.md: 189 lines
|
||||
|
||||
Last compaction: 2026-02-01
|
||||
Next scheduled: 2026-03-01
|
||||
```
|
||||
|
||||
## Multi-Project Patterns
|
||||
|
||||
### Inheritance Chain
|
||||
```
|
||||
global (memory.md)
|
||||
└── domain (domains/code.md)
|
||||
└── project (projects/app.md)
|
||||
```
|
||||
|
||||
### Override Syntax
|
||||
In project file:
|
||||
```markdown
|
||||
## Overrides
|
||||
- indentation: spaces (overrides global tabs)
|
||||
- Reason: Project eslint config requires spaces
|
||||
```
|
||||
|
||||
### Conflict Detection
|
||||
When loading, check for conflicts:
|
||||
1. Build inheritance chain
|
||||
2. Detect contradictions
|
||||
3. Most specific wins
|
||||
4. Log conflict for later review
|
||||
|
||||
## User Type Adaptations
|
||||
|
||||
| User Type | Memory Strategy |
|
||||
|-----------|-----------------|
|
||||
| Power user | Aggressive learning, minimal confirmation |
|
||||
| Casual | Conservative learning, frequent confirmation |
|
||||
| Team shared | Per-user namespaces, shared project space |
|
||||
| Privacy-focused | Local-only, explicit consent per category |
|
||||
|
||||
## Recovery Patterns
|
||||
|
||||
### Context Lost
|
||||
If agent loses context mid-session:
|
||||
1. Re-read memory.md
|
||||
2. Check index.md for relevant namespaces
|
||||
3. Load active project namespace
|
||||
4. Continue with restored patterns
|
||||
|
||||
### Corruption Recovery
|
||||
If memory file corrupted:
|
||||
1. Check archive/ for recent backup
|
||||
2. Rebuild from corrections.md
|
||||
3. Ask user to re-confirm critical preferences
|
||||
4. Log incident for debugging
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
# Setup — Self-Improving Agent
|
||||
|
||||
## First-Time Setup
|
||||
|
||||
### 1. Create Memory Structure
|
||||
|
||||
```bash
|
||||
mkdir -p ~/self-improving/{projects,domains,archive}
|
||||
```
|
||||
|
||||
### 2. Initialize Core Files
|
||||
|
||||
Create `~/self-improving/memory.md` using `memory-template.md`:
|
||||
|
||||
```markdown
|
||||
Copy the structure from `memory-template.md` into `~/self-improving/memory.md`.
|
||||
```
|
||||
|
||||
Memory file baseline:
|
||||
```markdown
|
||||
# Memory (HOT Tier)
|
||||
|
||||
## Preferences
|
||||
|
||||
## Patterns
|
||||
|
||||
## Rules
|
||||
```
|
||||
|
||||
Create `~/self-improving/corrections.md`:
|
||||
```markdown
|
||||
# Corrections Log
|
||||
|
||||
| Date | What I Got Wrong | Correct Answer | Status |
|
||||
|------|-----------------|----------------|--------|
|
||||
```
|
||||
|
||||
Create `~/self-improving/index.md`:
|
||||
```markdown
|
||||
# Memory Index
|
||||
|
||||
| File | Lines | Last Updated |
|
||||
|------|-------|--------------|
|
||||
| memory.md | 0 | — |
|
||||
| corrections.md | 0 | — |
|
||||
```
|
||||
|
||||
### 3. Choose Operating Mode
|
||||
|
||||
Add to your AGENTS.md or workspace config:
|
||||
|
||||
```markdown
|
||||
## Self-Improving Mode
|
||||
|
||||
Current mode: Passive
|
||||
|
||||
Available modes:
|
||||
- Passive: Only learn from explicit corrections
|
||||
- Active: Suggest patterns after 3x repetition
|
||||
- Strict: Require confirmation for every entry
|
||||
```
|
||||
|
||||
### 4. Add SOUL.md Steering
|
||||
|
||||
Add this section to your `SOUL.md`:
|
||||
|
||||
```markdown
|
||||
**Self-Improving**
|
||||
Compounding execution quality is part of the job.
|
||||
Before non-trivial work, load `~/self-improving/memory.md` and only the smallest relevant domain or project files.
|
||||
After corrections, failed attempts, or reusable lessons, write one concise entry to the correct self-improving file immediately.
|
||||
Prefer learned rules when relevant, but keep self-inferred rules revisable.
|
||||
Do not skip retrieval just because the task feels familiar.
|
||||
```
|
||||
|
||||
### 5. Refine AGENTS.md Memory Section (Non-Destructive)
|
||||
|
||||
Update `AGENTS.md` by complementing the existing `## Memory` section. Do not replace the whole section and do not remove existing lines.
|
||||
|
||||
If your `## Memory` block differs from the default template, insert the same additions in equivalent places so existing information is preserved.
|
||||
|
||||
Add this line in the continuity list (next to Daily notes and Long-term):
|
||||
|
||||
```markdown
|
||||
- **Self-improving:** `~/self-improving/` (via `self-improving` skill) — execution-improvement memory (preferences, workflows, style patterns, what improved/worsened outcomes)
|
||||
```
|
||||
|
||||
Right after the sentence "Capture what matters...", add:
|
||||
|
||||
```markdown
|
||||
Use `memory/YYYY-MM-DD.md` and `MEMORY.md` for factual continuity (events, context, decisions).
|
||||
Use `~/self-improving/` for compounding execution quality across tasks.
|
||||
For compounding quality, read `~/self-improving/memory.md` before non-trivial work, then load only the smallest relevant domain or project files.
|
||||
If in doubt, store factual history in `memory/YYYY-MM-DD.md` / `MEMORY.md`, and store reusable performance lessons in `~/self-improving/` (tentative until human validation).
|
||||
```
|
||||
|
||||
Before the "Write It Down" subsection, add:
|
||||
|
||||
```markdown
|
||||
Before any non-trivial task:
|
||||
- Read `~/self-improving/memory.md`
|
||||
- List available files first:
|
||||
```bash
|
||||
for d in ~/self-improving/domains ~/self-improving/projects; do
|
||||
[ -d "$d" ] && find "$d" -maxdepth 1 -type f -name "*.md"
|
||||
done | sort
|
||||
```
|
||||
- Read up to 3 matching files from `~/self-improving/domains/`
|
||||
- If a project is clearly active, also read `~/self-improving/projects/<project>.md`
|
||||
- Do not read unrelated domains "just in case"
|
||||
|
||||
If inferring a new rule, keep it tentative until human validation.
|
||||
```
|
||||
|
||||
Inside the "Write It Down" bullets, refine the behavior (non-destructive):
|
||||
- Keep existing intent, but route execution-improvement content to `~/self-improving/`.
|
||||
- If the exact bullets exist, replace only these lines; if wording differs, apply equivalent edits without removing unrelated guidance.
|
||||
|
||||
Use this target wording:
|
||||
|
||||
```markdown
|
||||
- When someone says "remember this" → if it's factual context/event, update `memory/YYYY-MM-DD.md`; if it's a correction, preference, workflow/style choice, or performance lesson, log it in `~/self-improving/`
|
||||
- Explicit user correction → append to `~/self-improving/corrections.md` immediately
|
||||
- Reusable global rule or preference → append to `~/self-improving/memory.md`
|
||||
- Domain-specific lesson → append to `~/self-improving/domains/<domain>.md`
|
||||
- Project-only override → append to `~/self-improving/projects/<project>.md`
|
||||
- Keep entries short, concrete, and one lesson per bullet; if scope is ambiguous, default to domain rather than global
|
||||
- After a correction or strong reusable lesson, write it before the final response
|
||||
```
|
||||
|
||||
## Verification
|
||||
|
||||
Run "memory stats" to confirm setup:
|
||||
|
||||
```
|
||||
📊 Self-Improving Memory
|
||||
|
||||
🔥 HOT (always loaded):
|
||||
memory.md: 0 entries
|
||||
|
||||
🌡️ WARM (load on demand):
|
||||
projects/: 0 files
|
||||
domains/: 0 files
|
||||
|
||||
❄️ COLD (archived):
|
||||
archive/: 0 files
|
||||
|
||||
⚙️ Mode: Passive
|
||||
```
|
||||
|
||||
## Optional: Heartbeat Integration
|
||||
|
||||
Add to `HEARTBEAT.md` for automatic maintenance:
|
||||
|
||||
```markdown
|
||||
## Self-Improving Check
|
||||
|
||||
- [ ] Review corrections.md for patterns ready to graduate
|
||||
- [ ] Check memory.md line count (should be ≤100)
|
||||
- [ ] Archive patterns unused >90 days
|
||||
```
|
||||
+356
@@ -0,0 +1,356 @@
|
||||
---
|
||||
name: skill-creator
|
||||
description: Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.
|
||||
license: Complete terms in LICENSE.txt
|
||||
---
|
||||
|
||||
# Skill Creator
|
||||
|
||||
This skill provides guidance for creating effective skills.
|
||||
|
||||
## About Skills
|
||||
|
||||
Skills are modular, self-contained packages that extend Claude's capabilities by providing
|
||||
specialized knowledge, workflows, and tools. Think of them as "onboarding guides" for specific
|
||||
domains or tasks—they transform Claude from a general-purpose agent into a specialized agent
|
||||
equipped with procedural knowledge that no model can fully possess.
|
||||
|
||||
### What Skills Provide
|
||||
|
||||
1. Specialized workflows - Multi-step procedures for specific domains
|
||||
2. Tool integrations - Instructions for working with specific file formats or APIs
|
||||
3. Domain expertise - Company-specific knowledge, schemas, business logic
|
||||
4. Bundled resources - Scripts, references, and assets for complex and repetitive tasks
|
||||
|
||||
## Core Principles
|
||||
|
||||
### Concise is Key
|
||||
|
||||
The context window is a public good. Skills share the context window with everything else Claude needs: system prompt, conversation history, other Skills' metadata, and the actual user request.
|
||||
|
||||
**Default assumption: Claude is already very smart.** Only add context Claude doesn't already have. Challenge each piece of information: "Does Claude really need this explanation?" and "Does this paragraph justify its token cost?"
|
||||
|
||||
Prefer concise examples over verbose explanations.
|
||||
|
||||
### Set Appropriate Degrees of Freedom
|
||||
|
||||
Match the level of specificity to the task's fragility and variability:
|
||||
|
||||
**High freedom (text-based instructions)**: Use when multiple approaches are valid, decisions depend on context, or heuristics guide the approach.
|
||||
|
||||
**Medium freedom (pseudocode or scripts with parameters)**: Use when a preferred pattern exists, some variation is acceptable, or configuration affects behavior.
|
||||
|
||||
**Low freedom (specific scripts, few parameters)**: Use when operations are fragile and error-prone, consistency is critical, or a specific sequence must be followed.
|
||||
|
||||
Think of Claude as exploring a path: a narrow bridge with cliffs needs specific guardrails (low freedom), while an open field allows many routes (high freedom).
|
||||
|
||||
### Anatomy of a Skill
|
||||
|
||||
Every skill consists of a required SKILL.md file and optional bundled resources:
|
||||
|
||||
```
|
||||
skill-name/
|
||||
├── SKILL.md (required)
|
||||
│ ├── YAML frontmatter metadata (required)
|
||||
│ │ ├── name: (required)
|
||||
│ │ └── description: (required)
|
||||
│ └── Markdown instructions (required)
|
||||
└── Bundled Resources (optional)
|
||||
├── scripts/ - Executable code (Python/Bash/etc.)
|
||||
├── references/ - Documentation intended to be loaded into context as needed
|
||||
└── assets/ - Files used in output (templates, icons, fonts, etc.)
|
||||
```
|
||||
|
||||
#### SKILL.md (required)
|
||||
|
||||
Every SKILL.md consists of:
|
||||
|
||||
- **Frontmatter** (YAML): Contains `name` and `description` fields. These are the only fields that Claude reads to determine when the skill gets used, thus it is very important to be clear and comprehensive in describing what the skill is, and when it should be used.
|
||||
- **Body** (Markdown): Instructions and guidance for using the skill. Only loaded AFTER the skill triggers (if at all).
|
||||
|
||||
#### Bundled Resources (optional)
|
||||
|
||||
##### Scripts (`scripts/`)
|
||||
|
||||
Executable code (Python/Bash/etc.) for tasks that require deterministic reliability or are repeatedly rewritten.
|
||||
|
||||
- **When to include**: When the same code is being rewritten repeatedly or deterministic reliability is needed
|
||||
- **Example**: `scripts/rotate_pdf.py` for PDF rotation tasks
|
||||
- **Benefits**: Token efficient, deterministic, may be executed without loading into context
|
||||
- **Note**: Scripts may still need to be read by Claude for patching or environment-specific adjustments
|
||||
|
||||
##### References (`references/`)
|
||||
|
||||
Documentation and reference material intended to be loaded as needed into context to inform Claude's process and thinking.
|
||||
|
||||
- **When to include**: For documentation that Claude should reference while working
|
||||
- **Examples**: `references/finance.md` for financial schemas, `references/mnda.md` for company NDA template, `references/policies.md` for company policies, `references/api_docs.md` for API specifications
|
||||
- **Use cases**: Database schemas, API documentation, domain knowledge, company policies, detailed workflow guides
|
||||
- **Benefits**: Keeps SKILL.md lean, loaded only when Claude determines it's needed
|
||||
- **Best practice**: If files are large (>10k words), include grep search patterns in SKILL.md
|
||||
- **Avoid duplication**: Information should live in either SKILL.md or references files, not both. Prefer references files for detailed information unless it's truly core to the skill—this keeps SKILL.md lean while making information discoverable without hogging the context window. Keep only essential procedural instructions and workflow guidance in SKILL.md; move detailed reference material, schemas, and examples to references files.
|
||||
|
||||
##### Assets (`assets/`)
|
||||
|
||||
Files not intended to be loaded into context, but rather used within the output Claude produces.
|
||||
|
||||
- **When to include**: When the skill needs files that will be used in the final output
|
||||
- **Examples**: `assets/logo.png` for brand assets, `assets/slides.pptx` for PowerPoint templates, `assets/frontend-template/` for HTML/React boilerplate, `assets/font.ttf` for typography
|
||||
- **Use cases**: Templates, images, icons, boilerplate code, fonts, sample documents that get copied or modified
|
||||
- **Benefits**: Separates output resources from documentation, enables Claude to use files without loading them into context
|
||||
|
||||
#### What to Not Include in a Skill
|
||||
|
||||
A skill should only contain essential files that directly support its functionality. Do NOT create extraneous documentation or auxiliary files, including:
|
||||
|
||||
- README.md
|
||||
- INSTALLATION_GUIDE.md
|
||||
- QUICK_REFERENCE.md
|
||||
- CHANGELOG.md
|
||||
- etc.
|
||||
|
||||
The skill should only contain the information needed for an AI agent to do the job at hand. It should not contain auxilary context about the process that went into creating it, setup and testing procedures, user-facing documentation, etc. Creating additional documentation files just adds clutter and confusion.
|
||||
|
||||
### Progressive Disclosure Design Principle
|
||||
|
||||
Skills use a three-level loading system to manage context efficiently:
|
||||
|
||||
1. **Metadata (name + description)** - Always in context (~100 words)
|
||||
2. **SKILL.md body** - When skill triggers (<5k words)
|
||||
3. **Bundled resources** - As needed by Claude (Unlimited because scripts can be executed without reading into context window)
|
||||
|
||||
#### Progressive Disclosure Patterns
|
||||
|
||||
Keep SKILL.md body to the essentials and under 500 lines to minimize context bloat. Split content into separate files when approaching this limit. When splitting out content into other files, it is very important to reference them from SKILL.md and describe clearly when to read them, to ensure the reader of the skill knows they exist and when to use them.
|
||||
|
||||
**Key principle:** When a skill supports multiple variations, frameworks, or options, keep only the core workflow and selection guidance in SKILL.md. Move variant-specific details (patterns, examples, configuration) into separate reference files.
|
||||
|
||||
**Pattern 1: High-level guide with references**
|
||||
|
||||
```markdown
|
||||
# PDF Processing
|
||||
|
||||
## Quick start
|
||||
|
||||
Extract text with pdfplumber:
|
||||
[code example]
|
||||
|
||||
## Advanced features
|
||||
|
||||
- **Form filling**: See [FORMS.md](FORMS.md) for complete guide
|
||||
- **API reference**: See [REFERENCE.md](REFERENCE.md) for all methods
|
||||
- **Examples**: See [EXAMPLES.md](EXAMPLES.md) for common patterns
|
||||
```
|
||||
|
||||
Claude loads FORMS.md, REFERENCE.md, or EXAMPLES.md only when needed.
|
||||
|
||||
**Pattern 2: Domain-specific organization**
|
||||
|
||||
For Skills with multiple domains, organize content by domain to avoid loading irrelevant context:
|
||||
|
||||
```
|
||||
bigquery-skill/
|
||||
├── SKILL.md (overview and navigation)
|
||||
└── reference/
|
||||
├── finance.md (revenue, billing metrics)
|
||||
├── sales.md (opportunities, pipeline)
|
||||
├── product.md (API usage, features)
|
||||
└── marketing.md (campaigns, attribution)
|
||||
```
|
||||
|
||||
When a user asks about sales metrics, Claude only reads sales.md.
|
||||
|
||||
Similarly, for skills supporting multiple frameworks or variants, organize by variant:
|
||||
|
||||
```
|
||||
cloud-deploy/
|
||||
├── SKILL.md (workflow + provider selection)
|
||||
└── references/
|
||||
├── aws.md (AWS deployment patterns)
|
||||
├── gcp.md (GCP deployment patterns)
|
||||
└── azure.md (Azure deployment patterns)
|
||||
```
|
||||
|
||||
When the user chooses AWS, Claude only reads aws.md.
|
||||
|
||||
**Pattern 3: Conditional details**
|
||||
|
||||
Show basic content, link to advanced content:
|
||||
|
||||
```markdown
|
||||
# DOCX Processing
|
||||
|
||||
## Creating documents
|
||||
|
||||
Use docx-js for new documents. See [DOCX-JS.md](DOCX-JS.md).
|
||||
|
||||
## Editing documents
|
||||
|
||||
For simple edits, modify the XML directly.
|
||||
|
||||
**For tracked changes**: See [REDLINING.md](REDLINING.md)
|
||||
**For OOXML details**: See [OOXML.md](OOXML.md)
|
||||
```
|
||||
|
||||
Claude reads REDLINING.md or OOXML.md only when the user needs those features.
|
||||
|
||||
**Important guidelines:**
|
||||
|
||||
- **Avoid deeply nested references** - Keep references one level deep from SKILL.md. All reference files should link directly from SKILL.md.
|
||||
- **Structure longer reference files** - For files longer than 100 lines, include a table of contents at the top so Claude can see the full scope when previewing.
|
||||
|
||||
## Skill Creation Process
|
||||
|
||||
Skill creation involves these steps:
|
||||
|
||||
1. Understand the skill with concrete examples
|
||||
2. Plan reusable skill contents (scripts, references, assets)
|
||||
3. Initialize the skill (run init_skill.py)
|
||||
4. Edit the skill (implement resources and write SKILL.md)
|
||||
5. Package the skill (run package_skill.py)
|
||||
6. Iterate based on real usage
|
||||
|
||||
Follow these steps in order, skipping only if there is a clear reason why they are not applicable.
|
||||
|
||||
### Step 1: Understanding the Skill with Concrete Examples
|
||||
|
||||
Skip this step only when the skill's usage patterns are already clearly understood. It remains valuable even when working with an existing skill.
|
||||
|
||||
To create an effective skill, clearly understand concrete examples of how the skill will be used. This understanding can come from either direct user examples or generated examples that are validated with user feedback.
|
||||
|
||||
For example, when building an image-editor skill, relevant questions include:
|
||||
|
||||
- "What functionality should the image-editor skill support? Editing, rotating, anything else?"
|
||||
- "Can you give some examples of how this skill would be used?"
|
||||
- "I can imagine users asking for things like 'Remove the red-eye from this image' or 'Rotate this image'. Are there other ways you imagine this skill being used?"
|
||||
- "What would a user say that should trigger this skill?"
|
||||
|
||||
To avoid overwhelming users, avoid asking too many questions in a single message. Start with the most important questions and follow up as needed for better effectiveness.
|
||||
|
||||
Conclude this step when there is a clear sense of the functionality the skill should support.
|
||||
|
||||
### Step 2: Planning the Reusable Skill Contents
|
||||
|
||||
To turn concrete examples into an effective skill, analyze each example by:
|
||||
|
||||
1. Considering how to execute on the example from scratch
|
||||
2. Identifying what scripts, references, and assets would be helpful when executing these workflows repeatedly
|
||||
|
||||
Example: When building a `pdf-editor` skill to handle queries like "Help me rotate this PDF," the analysis shows:
|
||||
|
||||
1. Rotating a PDF requires re-writing the same code each time
|
||||
2. A `scripts/rotate_pdf.py` script would be helpful to store in the skill
|
||||
|
||||
Example: When designing a `frontend-webapp-builder` skill for queries like "Build me a todo app" or "Build me a dashboard to track my steps," the analysis shows:
|
||||
|
||||
1. Writing a frontend webapp requires the same boilerplate HTML/React each time
|
||||
2. An `assets/hello-world/` template containing the boilerplate HTML/React project files would be helpful to store in the skill
|
||||
|
||||
Example: When building a `big-query` skill to handle queries like "How many users have logged in today?" the analysis shows:
|
||||
|
||||
1. Querying BigQuery requires re-discovering the table schemas and relationships each time
|
||||
2. A `references/schema.md` file documenting the table schemas would be helpful to store in the skill
|
||||
|
||||
To establish the skill's contents, analyze each concrete example to create a list of the reusable resources to include: scripts, references, and assets.
|
||||
|
||||
### Step 3: Initializing the Skill
|
||||
|
||||
At this point, it is time to actually create the skill.
|
||||
|
||||
Skip this step only if the skill being developed already exists, and iteration or packaging is needed. In this case, continue to the next step.
|
||||
|
||||
When creating a new skill from scratch, always run the `init_skill.py` script. The script conveniently generates a new template skill directory that automatically includes everything a skill requires, making the skill creation process much more efficient and reliable.
|
||||
|
||||
Usage:
|
||||
|
||||
```bash
|
||||
scripts/init_skill.py <skill-name> --path <output-directory>
|
||||
```
|
||||
|
||||
The script:
|
||||
|
||||
- Creates the skill directory at the specified path
|
||||
- Generates a SKILL.md template with proper frontmatter and TODO placeholders
|
||||
- Creates example resource directories: `scripts/`, `references/`, and `assets/`
|
||||
- Adds example files in each directory that can be customized or deleted
|
||||
|
||||
After initialization, customize or remove the generated SKILL.md and example files as needed.
|
||||
|
||||
### Step 4: Edit the Skill
|
||||
|
||||
When editing the (newly-generated or existing) skill, remember that the skill is being created for another instance of Claude to use. Include information that would be beneficial and non-obvious to Claude. Consider what procedural knowledge, domain-specific details, or reusable assets would help another Claude instance execute these tasks more effectively.
|
||||
|
||||
#### Learn Proven Design Patterns
|
||||
|
||||
Consult these helpful guides based on your skill's needs:
|
||||
|
||||
- **Multi-step processes**: See references/workflows.md for sequential workflows and conditional logic
|
||||
- **Specific output formats or quality standards**: See references/output-patterns.md for template and example patterns
|
||||
|
||||
These files contain established best practices for effective skill design.
|
||||
|
||||
#### Start with Reusable Skill Contents
|
||||
|
||||
To begin implementation, start with the reusable resources identified above: `scripts/`, `references/`, and `assets/` files. Note that this step may require user input. For example, when implementing a `brand-guidelines` skill, the user may need to provide brand assets or templates to store in `assets/`, or documentation to store in `references/`.
|
||||
|
||||
Added scripts must be tested by actually running them to ensure there are no bugs and that the output matches what is expected. If there are many similar scripts, only a representative sample needs to be tested to ensure confidence that they all work while balancing time to completion.
|
||||
|
||||
Any example files and directories not needed for the skill should be deleted. The initialization script creates example files in `scripts/`, `references/`, and `assets/` to demonstrate structure, but most skills won't need all of them.
|
||||
|
||||
#### Update SKILL.md
|
||||
|
||||
**Writing Guidelines:** Always use imperative/infinitive form.
|
||||
|
||||
##### Frontmatter
|
||||
|
||||
Write the YAML frontmatter with `name` and `description`:
|
||||
|
||||
- `name`: The skill name
|
||||
- `description`: This is the primary triggering mechanism for your skill, and helps Claude understand when to use the skill.
|
||||
- Include both what the Skill does and specific triggers/contexts for when to use it.
|
||||
- Include all "when to use" information here - Not in the body. The body is only loaded after triggering, so "When to Use This Skill" sections in the body are not helpful to Claude.
|
||||
- Example description for a `docx` skill: "Comprehensive document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction. Use when Claude needs to work with professional documents (.docx files) for: (1) Creating new documents, (2) Modifying or editing content, (3) Working with tracked changes, (4) Adding comments, or any other document tasks"
|
||||
|
||||
Do not include any other fields in YAML frontmatter.
|
||||
|
||||
##### Body
|
||||
|
||||
Write instructions for using the skill and its bundled resources.
|
||||
|
||||
### Step 5: Packaging a Skill
|
||||
|
||||
Once development of the skill is complete, it must be packaged into a distributable .skill file that gets shared with the user. The packaging process automatically validates the skill first to ensure it meets all requirements:
|
||||
|
||||
```bash
|
||||
scripts/package_skill.py <path/to/skill-folder>
|
||||
```
|
||||
|
||||
Optional output directory specification:
|
||||
|
||||
```bash
|
||||
scripts/package_skill.py <path/to/skill-folder> ./dist
|
||||
```
|
||||
|
||||
The packaging script will:
|
||||
|
||||
1. **Validate** the skill automatically, checking:
|
||||
|
||||
- YAML frontmatter format and required fields
|
||||
- Skill naming conventions and directory structure
|
||||
- Description completeness and quality
|
||||
- File organization and resource references
|
||||
|
||||
2. **Package** the skill if validation passes, creating a .skill file named after the skill (e.g., `my-skill.skill`) that includes all files and maintains the proper directory structure for distribution. The .skill file is a zip file with a .skill extension.
|
||||
|
||||
If validation fails, the script will report the errors and exit without creating a package. Fix any validation errors and run the packaging command again.
|
||||
|
||||
### Step 6: Iterate
|
||||
|
||||
After testing the skill, users may request improvements. Often this happens right after using the skill, with fresh context of how the skill performed.
|
||||
|
||||
**Iteration workflow:**
|
||||
|
||||
1. Use the skill on real tasks
|
||||
2. Notice struggles or inefficiencies
|
||||
3. Identify how SKILL.md or bundled resources should be updated
|
||||
4. Implement changes and test again
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ownerId": "kn7bw9nd87w0cyvgjj9p46djhx809q9w",
|
||||
"slug": "skill-creator-2",
|
||||
"version": "0.1.0",
|
||||
"publishedAt": 1769830982484
|
||||
}
|
||||
Executable
+64
@@ -0,0 +1,64 @@
|
||||
---
|
||||
name: Word / Docx
|
||||
version: 1.0.1
|
||||
description: Read and generate Word documents with correct structure, styles, and cross-platform compatibility.
|
||||
changelog: Clarified the skill name and added a page layout compatibility note.
|
||||
metadata: {"clawdbot":{"emoji":"📘","os":["linux","darwin","win32"]}}
|
||||
---
|
||||
|
||||
## Structure
|
||||
|
||||
- DOCX is a ZIP containing XML files—`word/document.xml` has main content, `word/styles.xml` has styles
|
||||
- Text splits into runs (`<w:r>`)—each run has uniform formatting; one word may span multiple runs
|
||||
- Paragraphs (`<w:p>`) contain runs—never assume one paragraph = one text block
|
||||
- Sections control page layout—headers/footers, margins, orientation are per-section
|
||||
|
||||
## Styles vs Direct Formatting
|
||||
|
||||
- Styles (Heading 1, Normal) are named and reusable—direct formatting is inline and overrides style
|
||||
- Removing direct formatting reveals underlying style—useful for cleanup
|
||||
- Character styles apply to runs, paragraph styles to paragraphs—they layer together
|
||||
- Linked styles can be both—applying to paragraph or selected text behaves differently
|
||||
|
||||
## Lists & Numbering
|
||||
|
||||
- Numbering is complex: `abstractNum` defines pattern, `num` references it, paragraphs reference `numId`
|
||||
- Restart numbering not automatic—need explicit `<w:numPr>` with restart flag
|
||||
- Bullets and numbers share the numbering system—both use `numId`
|
||||
- Indentation controlled separately from numbering—list can exist without visual indent
|
||||
|
||||
## Headers, Footers, Sections
|
||||
|
||||
- Each section can have different headers/footers—first page, odd, even pages
|
||||
- Section breaks: next page, continuous, even/odd page—affects pagination
|
||||
- Headers/footers stored in separate XML files—referenced by section properties
|
||||
- Page numbers are fields, not static text—update on open or print
|
||||
|
||||
## Track Changes & Comments
|
||||
|
||||
- Track changes stores original and revised in same document—accept/reject to finalize
|
||||
- Deleted text still present with `<w:del>` wrapper—don't assume visible = all content
|
||||
- Comments reference ranges via bookmark IDs—`<w:commentRangeStart>` to `<w:commentRangeEnd>`
|
||||
- Revision IDs track who changed what—metadata persists even after accepting
|
||||
|
||||
## Fields & Dynamic Content
|
||||
|
||||
- Fields have code and cached result—`{ DATE \@ "yyyy-MM-dd" }` vs displayed date
|
||||
- TOC, page numbers, cross-references are fields—update fields to refresh
|
||||
- Hyperlinks can be fields or direct `<w:hyperlink>`—both valid
|
||||
- MERGEFIELD for mail merge—placeholder until merge executes
|
||||
|
||||
## Compatibility
|
||||
|
||||
- Compatibility mode limits features to earlier Word version—check `w:compat` settings
|
||||
- Page size defaults vary by tool and region—set US Letter vs A4 explicitly or pagination and table widths can drift
|
||||
- LibreOffice/Google Docs: complex formatting may shift—test roundtrip
|
||||
- Embedded fonts may not transfer—fallback fonts substitute
|
||||
- DOCM contains macros (security risk); DOC is legacy binary format
|
||||
|
||||
## Common Pitfalls
|
||||
|
||||
- Empty paragraphs for spacing—prefer space before/after in paragraph style
|
||||
- Manual page breaks inside paragraphs—use section breaks for layout control
|
||||
- Images in headers: relationship IDs are per-part—same image needs separate relationship in header
|
||||
- Copy-paste brings source styles—can pollute style gallery with duplicates
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ownerId": "kn73vp5rarc3b14rc7wjcw8f8580t5d1",
|
||||
"slug": "word-docx",
|
||||
"version": "1.0.1",
|
||||
"publishedAt": 1773048519521
|
||||
}
|
||||
Reference in New Issue
Block a user