extract

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Extract Skill

提取Skill

Typically runs automatically via SessionStart hook.
Process pending learning extractions from previous sessions.
通常通过SessionStart钩子自动运行。
处理之前会话中待完成的经验提取任务。

How It Works

工作原理

The SessionStart hook runs:
bash
ao extract
This checks for queued extractions and outputs prompts for Claude to process.
SessionStart钩子会执行:
bash
ao extract
这会检查队列中的待提取任务,并输出提示信息供Claude处理。

Manual Execution

手动执行

Given
/extract
:
输入
/extract
后:

Step 1: Check for Pending Extractions

步骤1:检查待处理的提取任务

bash
ao extract 2>/dev/null
Or check the pending queue:
bash
cat .agents/ao/pending.jsonl 2>/dev/null | head -5
bash
ao extract 2>/dev/null
或者检查待处理队列:
bash
cat .agents/ao/pending.jsonl 2>/dev/null | head -5

Step 2: Process Each Pending Item

步骤2:处理每个待处理项

For each queued session:
  1. Read the session summary
  2. Extract actionable learnings
  3. Write to
    .agents/learnings/
对于队列中的每个会话:
  1. 读取会话摘要
  2. 提取可落地的经验总结
  3. 写入到
    .agents/learnings/
    目录

Step 3: Write Learnings

步骤3:写入经验总结

Write to:
.agents/learnings/YYYY-MM-DD-<session-id>.md
markdown
undefined
写入路径:
.agents/learnings/YYYY-MM-DD-<session-id>.md
markdown
undefined

Learning: <Short Title>

Learning: <简短标题>

ID: L1 Category: <debugging|architecture|process|testing|security> Confidence: <high|medium|low>
ID: L1 Category: <debugging|architecture|process|testing|security> Confidence: <high|medium|low>

What We Learned

我们的收获

<1-2 sentences describing the insight>
<1-2句话描述洞察内容>

Why It Matters

重要性

<1 sentence on impact/value>
<1句话说明影响/价值>

Source

来源

Session: <session-id>
undefined
Session: <session-id>
undefined

Step 3.5: Validate Learnings

步骤3.5:验证经验总结

After writing learning files, validate each has required fields:
  1. Scan newly written files:
bash
ls -t .agents/learnings/YYYY-MM-DD-*.md 2>/dev/null | head -5
  1. For each file, check required fields:
    • Heading: File must start with
      # Learning: <title>
      (non-empty title)
    • Category: Must contain
      **Category**: <value>
      where value is one of:
      debugging
      ,
      architecture
      ,
      process
      ,
      testing
      ,
      security
    • Confidence: Must contain
      **Confidence**: <value>
      where value is one of:
      high
      ,
      medium
      ,
      low
    • Content: Must contain a
      ## What We Learned
      section with at least one non-empty line after the heading
  2. Report validation results:
    • For each valid learning: "✓ <filename>: valid"
    • For each invalid learning: "⚠ <filename>: missing <field>" (list each missing field)
  3. Do NOT delete or retry invalid learnings. Log the warning and proceed. Invalid learnings are still better than no learnings — the warning helps identify extraction quality issues over time.
写入经验总结文件后,验证每个文件是否包含必填字段:
  1. 扫描新写入的文件:
bash
ls -t .agents/learnings/YYYY-MM-DD-*.md 2>/dev/null | head -5
  1. 对每个文件,检查必填字段:
    • 标题: 文件必须以
      # Learning: <标题>
      开头(标题不能为空)
    • 分类: 必须包含
      **Category**: <值>
      ,其中值为以下之一:
      debugging
      architecture
      process
      testing
      security
    • 置信度: 必须包含
      **Confidence**: <值>
      ,其中值为以下之一:
      high
      medium
      low
    • 内容: 必须包含
      ## 我们的收获
      章节,且标题后至少有一行非空内容
  2. 报告验证结果:
    • 对于每个有效的经验总结:"✓ <文件名>: 有效"
    • 对于每个无效的经验总结:"⚠ <文件名>: 缺失<字段>"(列出每个缺失的字段)
  3. 不要删除或重试无效的经验总结。 记录警告并继续执行。无效的经验总结总比没有好——警告有助于长期识别提取质量问题。

Step 4: Clear the Queue

步骤4:清空队列

bash
ao extract --clear 2>/dev/null
bash
ao extract --clear 2>/dev/null

Step 5: Report Completion

步骤5:报告完成情况

Tell the user:
  • Number of learnings extracted
  • Key insights
  • Location of learning files
告知用户:
  • 提取的经验总结数量
  • 关键洞察内容
  • 经验总结文件的存储位置

The Knowledge Loop

知识循环

Session N ends:
  → ao forge --last-session --queue
  → Session queued in pending.jsonl

Session N+1 starts:
  → ao extract (this skill)
  → Claude processes the queue
  → Writes to .agents/learnings/
  → Validates required fields
  → Loop closed
会话N结束:
  → ao forge --last-session --queue
  → 会话被加入pending.jsonl队列

会话N+1开始:
  → ao extract(本Skill)
  → Claude处理队列
  → 写入.agents/learnings/目录
  → 验证必填字段
  → 循环完成

Key Rules

核心规则

  • Runs automatically - usually via hook
  • Process the queue - don't leave extractions pending
  • Be specific - actionable learnings, not vague observations
  • Close the loop - extraction completes the knowledge cycle
  • 自动运行 - 通常通过钩子触发
  • 处理队列 - 不要让提取任务处于待处理状态
  • 具体明确 - 提取可落地的经验总结,而非模糊的观察
  • 闭环管理 - 提取完成整个知识循环