AGENT SKILL

learn

The agent's cross-session notebook at ~/.kinclaw/learned.md, organized by bundle_id / topic. The kernel reads it at every boot and injects it into the system prompt (when it outgrows the prompt budget you see a topic index plus the newest notes — use action=recall for the rest). action=add (default) — append one lesson after a task: - AX schema quirks (depth needed, weird matchers) - Working keyboard / shell shortcuts that beat ui clicks - Failed approaches + their error codes (so you don't retry next time) - First-launch modal patterns - bundle_id spelling (some apps use lowercase like com.apple.mail) action=recall topic=X — print one section (case-insensitive match) action=list — print the topic index Appends go to a section keyed on `topic` (usually a bundle_id). Creates the section if it doesn't exist; appends bullet lines if it does. No-op if the exact same line already exists (idempotent).

License 许可
Apache-2.0
所属仓库
LocalKinAI/kinclaw
最近更新
2026-11-01
Stars
★ 9
Forks
3

01 前言 Front Matter

args
[ "{{action}}", "{{topic}}", "{{note}}" ]
name
learn
schema
{ "note": { "type": "string", "description": "Single-line lesson learned (add only). Concise. No outer \"- \" (added automatically). Examples — \"AX tree depth ≥ 6 to see number buttons\", \"cmd+N + type more reliable than ui click 'New Note'\", \"AXError -25205 means the element is offscreen / collapsed\".\n" }, "topic": { "type": "string", "description": "Section header to file the note under (add) or look up (recall) — typically a bundle_id like \"com.apple.calculator\", \"com.apple.Notes\", or a generic category like \"Common: focus protection\". Required for add and recall.\n" }, "action": { "type": "string", "description": "add (default) | recall | list. add appends a note; recall prints one topic's section; list prints the topic index.\n" } }
command
[ "sh", "-c", "ACTION=\"${1:-add}\"\nTOPIC=\"$2\"\nNOTE=\"$3\"\nFILE=\"$HOME/.kinclaw/learned.md\"\nmkdir -p \"$HOME/.kinclaw\"\n[ -f \"$FILE\" ] || printf '# KinClaw — learned across sessions\\n\\n' > \"$FILE\"\n\ncase \"$ACTION\" in\n list)\n # Topic index: every ## header with its bullet count.\n awk '/^## /{ if (t!=\"\") printf \"%s (%d)\\n\", t, n; t=substr($0,4); n=0; next }\n /^- /{ n++ }\n END{ if (t!=\"\") printf \"%s (%d)\\n\", t, n }' \"$FILE\"\n exit 0 ;;\n recall)\n [ -z \"$TOPIC\" ] && { echo \"topic required for recall\" >&2; exit 1; }\n OUT=$(awk -v q=\"$(printf '%s' \"$TOPIC\" | tr 'A-Z' 'a-z')\" '\n /^## /{ inhit = index(tolower(substr($0,4)), q) > 0 }\n inhit { print }' \"$FILE\")\n [ -z \"$OUT\" ] && { echo \"no section matching: $TOPIC (try action=list)\"; exit 0; }\n printf '%s\\n' \"$OUT\"\n exit 0 ;;\n add|\"\") ;;\n *) echo \"action must be add | recall | list (got $ACTION)\" >&2; exit 1 ;;\nesac\n\n[ -z \"$TOPIC\" ] && { echo \"topic required\" >&2; exit 1; }\n[ -z \"$NOTE\" ] && { echo \"note required\" >&2; exit 1; }\n\n# Idempotent: if exact line already exists, no-op. The `--` is\n# important — leading \"- \" in $LINE would otherwise get parsed as\n# a grep flag. Same for the section header check below.\nLINE=\"- $NOTE\"\nif grep -Fq -- \"$LINE\" \"$FILE\" 2>/dev/null; then\n echo \"already known: $TOPIC :: $NOTE\"\n exit 0\nfi\n\n# Append to existing section if header exists, else create section.\nHEADER=\"## $TOPIC\"\nif grep -Fqx -- \"$HEADER\" \"$FILE\"; then\n # Insert line right after the section header using awk so order is preserved.\n awk -v hdr=\"$HEADER\" -v line=\"$LINE\" '\n $0 == hdr { print; print line; next }\n { print }\n ' \"$FILE\" > \"$FILE.new\" && mv \"$FILE.new\" \"$FILE\"\nelse\n printf '\\n%s\\n%s\\n' \"$HEADER\" \"$LINE\" >> \"$FILE\"\nfi\necho \"learned: $TOPIC :: $NOTE\"\n", "_" ]
timeout
10
description
The agent's cross-session notebook at ~/.kinclaw/learned.md, organized by bundle_id / topic. The kernel reads it at every boot and injects it into the system prompt (when it outgrows the prompt budget you see a topic index plus the newest notes — use action=recall for the rest). action=add (default) — append one lesson after a task: - AX schema quirks (depth needed, weird matchers) - Working keyboard / shell shortcuts that beat ui clicks - Failed approaches + their error codes (so you don't retry next time) - First-launch modal patterns - bundle_id spelling (some apps use lowercase like com.apple.mail) action=recall topic=X — print one section (case-insensitive match) action=list — print the topic index Appends go to a section keyed on `topic` (usually a bundle_id). Creates the section if it doesn't exist; appends bullet lines if it does. No-op if the exact same line already exists (idempotent).

03 SKILL.md 正文

learn — append to the cross-session notebook

KinClaw's persistence layer for Genesis Protocol. Every successful task or hard-won failure is an opportunity to make next session smarter. This skill is the standardized way to write into ~/.kinclaw/learned.md — kernel auto-loads that file at boot and injects it into the agent's system prompt. (Until v1.18 this skill wrote to ~/.localkin/learned.md while the kernel read ~/.kinclaw/ — the kernel still reads the old file so nothing written there is lost.)

Idempotent

Calling learn with the same topic + note twice is a no-op. Safe to spam without polluting the notebook.

Examples

learn topic=com.apple.calculator note="AX tree depth ≥ 6 to see number buttons"
learn topic=com.apple.Notes note="cmd+N more reliable than ui click 'New Note'"
learn topic=com.apple.reminders note="ui click description='Add Reminder' fails with AXError -25205; use cmd+N + type"
learn topic="Common: focus protection" note="osascript activate from Terminal-driven KinClaw rarely takes frontmost"
learn action=list
learn action=recall topic=com.apple.Notes

Why a SKILL.md and not native

Pure shell + awk. No Go state. The notebook lives at a known path that the kernel already reads — this skill is just an idempotent append helper. Nothing here belongs in the kernel.

04 同仓库更多 Skills

LocalKinAI
LocalKinAI/kinclaw

web

Universal web tool — fetches and interacts with web pages through real Chromium (Playwright). Renders JavaScript, follows redirects, handles cookies, bypasses many anti-scrape stubs that block plain `web_fetch`. Each call launches a fresh browser, executes the requested flow, closes. ~2-3s cold start; no persistent state. Use INSTEAD of `web_fetch` when: - Target is a JS-heavy SPA (prices via XHR, lazy content) - `web_fetch` returned an anti-scrape placeholder (Zhihu's "click here" stub, JD's chrome-only HTML) - You need to interact (click, fill input) before extracting Common patterns: fetch rendered text: url=X wait for content then read: url=X wait_for=".price" extract specific element: url=X selector=".product-list" click and read result: url=X click=".search-button" fill form, then read: url=X click="input[name=q]" type_text="kinclaw" fill + Enter (React forms): url=X click="input" type_text="hi" press_enter=true wait_for=".reply" screenshot the page: url=X screenshot=true (returns image:// marker) run JS and get result: url=X js="document.title" First-time setup (one-time per machine, ~500MB Chromium download): pip install playwright playwright install chromium

文档处理测试与质量
★ 9
LocalKinAI
LocalKinAI/kinclaw

weather

Current conditions plus a three-day forecast (today / tomorrow / day after) for a place, in metric, from wttr.in. No API key. Use this for any weather question — including "明天" and "后天" — before reaching for web search.

★ 9
LocalKinAI
LocalKinAI/kinclaw

tts

Synthesize speech from text and play it through the macOS speakers. Talks to a local LocalKin Service Audio Server (default :8001 / Kokoro). When `record` is running with audio=true, the spoken audio is captured into the recording — use this in place of `shell say` for high-quality multilingual narration in demo videos. Set the TTS_ENDPOINT env var to point at a different server.

图像与多媒体Skill与智能体开发
★ 9
LocalKinAI
LocalKinAI/kinclaw

translate

Translate text between languages using the system's translate command

★ 9
LocalKinAI
LocalKinAI/kinclaw

summarize

Summarize a file's contents into key bullet points

资料检索与研究
★ 9
LocalKinAI
LocalKinAI/kinclaw

stt

Transcribe an audio file (wav/mp3/mp4/m4a) into text via a local LocalKin Service Audio Server (default :8000 / SenseVoice). Pair with `record action=start mic=true` to turn a recorded mic track into text. Set STT_ENDPOINT env var to point at a different server.

图像与多媒体
★ 9