codeskill

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

codeskill — AI Project Intelligence System

codeskill — AI项目智能系统

You manage the
.ai/
directory in projects — rules, behaviours, memory, snapshots, sessions, incidents, and learning loops.
你负责管理项目中的
.ai/
目录,涵盖规则、行为模式、记忆、快照、会话、事件记录和学习循环。

Command Routing

命令路由

Parse
$ARGUMENTS
to determine which command to execute:
ARGS = "$ARGUMENTS"

解析
$ARGUMENTS
以确定要执行的命令:
ARGS = "$ARGUMENTS"

If ARGS starts with "init"

若ARGS以"init"开头

Scaffold a new
.ai/
directory in the current project.
  1. Check if
    .ai/
    already exists. If yes, ask user: "
    .ai/
    already exists. Overwrite? (This won't delete logs/memory)"
  2. Detect project type by reading go.mod, package.json, pyproject.toml, etc.
  3. Get the user's GitHub username:
    git config user.name
    and
    git config user.email
  4. Create the directory structure:
    bash
    mkdir -p .ai/{behaviours,skills/{backend,frontend,infra},workflows,guides}
    mkdir -p .ai/{snippets,prompts,memory/{feedback,decisions},templates}
    mkdir -p .ai/{logs/{sessions,activity,incidents},plans/features,tasks,snapshots,handoffs}
  5. Create Tier 0 files:
    • .ai/RULES.md
      — project-specific rules (start with generated code table, code style, commits)
    • .ai/HOTFIXES.md
      — empty with header and instructions
    • .ai/taste.md
      — project taste template with @username placeholders
  6. Create Tier 1 files:
    • .ai/ARCHITECTURE.md
      — if project type detected, scan main dirs and describe structure
    • .ai/STACK.md
      — extract from dependency files (go.mod, package.json, etc.)
    • .ai/PATTERNS.md
      — empty with header
  7. Create domain skill files based on project type:
    • Go project →
      .ai/skills/backend/RULES.md
      ,
      PATTERNS.md
      ,
      SNIPPETS.md
    • Node project →
      .ai/skills/frontend/RULES.md
      ,
      PATTERNS.md
      ,
      SNIPPETS.md
  8. Create INDEX.md files for:
    snippets/
    ,
    prompts/
    ,
    memory/
    ,
    logs/sessions/
    ,
    logs/activity/
    ,
    logs/incidents/
    ,
    plans/
    ,
    snapshots/
  9. Create
    .ai/TASKS.md
    from
    templates/tasks-index.md
    (master checklist)
  10. Create
    .ai/memory/tasks/
    directory and
    .ai/memory/TASKS_LOG.md
    from
    templates/tasks-log.md
  11. Create behaviour files:
    default.md
    ,
    careful.md
    ,
    review.md
    ,
    debug.md
    ,
    scaffold.md
    with
    behaviours/README.md
  12. Copy templates from this skill's
    templates/
    directory into
    .ai/templates/
  13. Create
    .ai/.gitignore
    :
    logs/
    CONTINUATION.md
    memory/decisions/
    tasks/
  14. Run the
    sync
    command to generate CLAUDE.md
  15. Report: "
    .ai/
    initialized. Edit RULES.md and taste.md, then run
    /codeskill sync
    ."

在当前项目中搭建新的
.ai/
目录。
  1. 检查
    .ai/
    是否已存在。若存在,询问用户:"
    .ai/
    已存在。是否覆盖?(此操作不会删除日志/记忆内容)"
  2. 通过读取go.mod、package.json、pyproject.toml等文件检测项目类型。
  3. 获取用户的GitHub用户名:执行
    git config user.name
    git config user.email
  4. 创建目录结构:
    bash
    mkdir -p .ai/{behaviours,skills/{backend,frontend,infra},workflows,guides}
    mkdir -p .ai/{snippets,prompts,memory/{feedback,decisions},templates}
    mkdir -p .ai/{logs/{sessions,activity,incidents},plans/features,tasks,snapshots,handoffs}
  5. 创建Tier 0文件:
    • .ai/RULES.md
      — 项目专属规则(以生成的代码表、代码风格、提交规范开头)
    • .ai/HOTFIXES.md
      — 空文件,包含标题和使用说明
    • .ai/taste.md
      — 项目风格模板,包含@username占位符
  6. 创建Tier 1文件:
    • .ai/ARCHITECTURE.md
      — 若检测到项目类型,扫描主目录并描述结构
    • .ai/STACK.md
      — 从依赖文件(go.mod、package.json等)中提取信息
    • .ai/PATTERNS.md
      — 空文件,包含标题
  7. 根据项目类型创建领域技能文件:
    • Go项目 →
      .ai/skills/backend/RULES.md
      PATTERNS.md
      SNIPPETS.md
    • Node项目 →
      .ai/skills/frontend/RULES.md
      PATTERNS.md
      SNIPPETS.md
  8. 为以下目录创建INDEX.md文件:
    snippets/
    prompts/
    memory/
    logs/sessions/
    logs/activity/
    logs/incidents/
    plans/
    snapshots/
  9. templates/tasks-index.md
    创建
    .ai/TASKS.md
    (主任务清单)
  10. 创建
    .ai/memory/tasks/
    目录,并从
    templates/tasks-log.md
    创建
    .ai/memory/TASKS_LOG.md
  11. 创建行为模式文件:
    default.md
    careful.md
    review.md
    debug.md
    scaffold.md
    ,并附带
    behaviours/README.md
  12. 将本技能
    templates/
    目录中的模板复制到
    .ai/templates/
  13. 创建
    .ai/.gitignore
    logs/
    CONTINUATION.md
    memory/decisions/
    tasks/
  14. 运行
    sync
    命令生成CLAUDE.md
  15. 反馈:"
    .ai/
    初始化完成。请编辑RULES.md和taste.md,然后运行
    /codeskill sync
    。"

If ARGS starts with "sync"

若ARGS以"sync"开头

Regenerate CLAUDE.md from
.ai/
Tier 0 files.
  1. Read these source files (skip any that don't exist):
    • .ai/global/RULES.md
      (if global dir exists)
    • .ai/RULES.md
    • .ai/global/taste.md
      (if global dir exists)
    • .ai/taste.md
    • .ai/HOTFIXES.md
    • .ai/behaviours/default.md
      (or current active behaviour)
  2. Read
    .ai/logs/sessions/INDEX.md
    — get the last session entry for "Where We Left Off"
  3. Read the CLAUDE.md template from this skill's
    templates/claude-md.md
  4. Assemble CLAUDE.md:
    • Header with generation notice
    • "Where We Left Off" section from last session
    • Critical Rules (concatenate global + project RULES.md)
    • Active Hotfixes
    • Taste (global, then project overrides)
    • Active Behaviour
    • Memory Protocol instructions
    • Exploration Protocol instructions
    • Before Starting Work checklist
    • Auto-Behaviour Hints
    • Workflow Index (scan
      .ai/workflows/
      for files)
    • After Session instructions
    • Reference links
  5. Write to project root
    CLAUDE.md
  6. Report: "CLAUDE.md regenerated. Tier 0: ~[X] lines."

.ai/
的Tier 0文件重新生成CLAUDE.md。
  1. 读取以下源文件(跳过不存在的文件):
    • .ai/global/RULES.md
      (若global目录存在)
    • .ai/RULES.md
    • .ai/global/taste.md
      (若global目录存在)
    • .ai/taste.md
    • .ai/HOTFIXES.md
    • .ai/behaviours/default.md
      (或当前激活的行为模式)
  2. 读取
    .ai/logs/sessions/INDEX.md
    — 获取最后一条会话记录作为“上次进度”
  3. 读取本技能
    templates/claude-md.md
    中的CLAUDE.md模板
  4. 组装CLAUDE.md:
    • 包含生成说明的标题
    • 来自最后一次会话的“上次进度”部分
    • 关键规则(合并全局+项目RULES.md内容)
    • 当前激活的热修复
    • 风格偏好(全局设置,后接项目覆盖内容)
    • 当前激活的行为模式
    • 记忆协议说明
    • 探索协议说明
    • 开始工作前的检查清单
    • 自动行为模式提示
    • 工作流索引(扫描
      .ai/workflows/
      中的文件)
    • 会话结束后的操作说明
    • 参考链接
  5. 写入项目根目录的
    CLAUDE.md
  6. 反馈:"CLAUDE.md已重新生成。Tier 0内容约[X]行。"

If ARGS starts with "behaviour"

若ARGS以"behaviour"开头

Switch or list behaviour profiles.
If ARGS is "behaviour list":
  1. Glob
    .ai/behaviours/*.md
    (exclude README.md)
  2. For each, read the frontmatter
    name
    and
    description
  3. Print table: name, description, active?
If ARGS is "behaviour [name]":
  1. Check
    .ai/behaviours/<name>.md
    exists
  2. If not, list available behaviours and ask user to pick
  3. Read the behaviour file
  4. Run
    sync
    to regenerate CLAUDE.md with new active behaviour
  5. Report: "Switched to
    <name>
    mode."

切换或列出行为模式配置文件。
若ARGS为"behaviour list":
  1. 匹配
    .ai/behaviours/*.md
    (排除README.md)
  2. 对每个文件,读取前置元数据中的
    name
    description
  3. 打印表格:名称、描述、是否激活?
若ARGS为"behaviour [name]":
  1. 检查
    .ai/behaviours/<name>.md
    是否存在
  2. 若不存在,列出可用的行为模式并请用户选择
  3. 读取该行为模式文件
  4. 运行
    sync
    以使用新的激活行为模式重新生成CLAUDE.md
  5. 反馈:"已切换至
    <name>
    模式。"

If ARGS starts with "learn"

若ARGS以"learn"开头

Mid-session learning — save AND apply immediately in the current session.
This is the user saying "learn this NOW" — not waiting for session end.
  1. Parse what to learn from ARGS after "learn"
  2. Classify the learning type:
    • Contains "always"/"never" → rule candidate
    • Contains "I prefer"/"I hate"/"I like" → taste candidate
    • Contains code/pattern → snippet/pattern candidate
    • Contains "remember"/"don't forget" → factual memory
    • Otherwise → correction/feedback
  3. Classify scope (project/global_candidate) using standard logic
  4. Check for duplicates in memory/feedback/ and RULES.md
    • If similar exists → update it instead of creating new
  5. Save to
    .ai/memory/feedback/<slug>.md
    with
    trigger: "user explicit (learn this)"
  6. APPLY IMMEDIATELY — add to your working context for the rest of this session:
    • Treat it as highest-priority rule for current conversation
    • Don't wait for session end
  7. Check promotion: Is this the 3rd+ time this correction was saved?
    • If yes → propose adding to RULES.md or taste.md right now
    • If no → report occurrence count
  8. If this looks like a taste update (style/naming/preference):
    • Ask: "Should I update taste.md with this? (It will apply to all future sessions)"
  9. Report: "Learned and applying now: <summary>. Occurrence #<N>."
Undo: If user says "undo the last thing I told you to learn" or "I changed my mind about X":
  1. Find the most recent feedback/ entry from this session (or matching X)
  2. Delete it
  3. Remove from in-session working context
  4. Report: "Removed: <summary>. No longer applying."

会话中即时学习 — 保存并立即在当前会话中应用。
这表示用户要求“立即学习这个” — 无需等到会话结束。
  1. 解析ARGS中"learn"之后的学习内容
  2. 分类学习类型:
    • 包含"always"/"never" → 规则候选
    • 包含"I prefer"/"I hate"/"I like" → 风格偏好候选
    • 包含代码/模式 → 代码片段/模式候选
    • 包含"remember"/"don't forget" → 事实记忆
    • 其他 → 修正/反馈
  3. 使用标准逻辑分类范围(项目/全局候选)
  4. 检查memory/feedback/和RULES.md中是否存在重复内容
    • 若存在相似内容 → 更新已有条目而非创建新条目
  5. 将内容保存至
    .ai/memory/feedback/<slug>.md
    ,并标记
    trigger: "user explicit (learn this)"
  6. 立即应用 — 将其添加到当前会话的工作上下文:
    • 在当前对话中视为最高优先级规则
    • 无需等待会话结束
  7. 检查升级条件:此修正是否已保存3次及以上?
    • 若是 → 提议立即添加到RULES.md或taste.md
    • 若否 → 报告出现次数
  8. 若此更新属于风格偏好(样式/命名/偏好):
    • 询问:"是否要将此更新到taste.md?(将应用于所有未来会话)"
  9. 反馈:"已学习并立即应用:<摘要>。出现次数#<N>。"
撤销:若用户说"undo the last thing I told you to learn"或"I changed my mind about X":
  1. 查找本次会话中最近的feedback/条目(或匹配X的条目)
  2. 删除该条目
  3. 从会话工作上下文中移除
  4. 反馈:"已移除:<摘要>。不再应用。"

If ARGS starts with "session start"

若ARGS以"session start"开头

Load context and report status.
  1. Get user info:
    git config user.name
    ,
    git config user.email
  2. Check for
    CONTINUATION.md
    in project root:
    • If exists: read it, report "Resuming from: [task]", delete the file
  3. Read
    .ai/HOTFIXES.md
    — report active hotfixes count
  4. Read
    .ai/logs/sessions/INDEX.md
    — get last session date
  5. Session diff: run
    git log --oneline --since="<last_session_date>"
    to see what changed
  6. Check snapshot staleness: for each snapshot in
    .ai/snapshots/INDEX.md
    , run
    git diff --name-only <hash> HEAD -- <globs>
  7. Report:
    Session started for @<username>
    Last session: <date> — <goal>
    Since then: <N> commits, <files changed>
    Hotfixes active: <N>
    Snapshots: <N> fresh, <N> stale

加载上下文并报告状态。
  1. 获取用户信息:
    git config user.name
    git config user.email
  2. 检查项目根目录中是否存在
    CONTINUATION.md
    • 若存在:读取内容,反馈"恢复自:[任务]",然后删除该文件
  3. 读取
    .ai/HOTFIXES.md
    — 报告当前激活的热修复数量
  4. 读取
    .ai/logs/sessions/INDEX.md
    — 获取最后一次会话的日期
  5. 会话差异:执行
    git log --oneline --since="<last_session_date>"
    查看变更内容
  6. 检查快照时效性:对于
    .ai/snapshots/INDEX.md
    中的每个快照,执行
    git diff --name-only <hash> HEAD -- <globs>
  7. 反馈:
    已为@<username>启动会话
    上次会话:<日期> — <目标>
    自上次以来:<N>次提交,<N>个文件变更
    当前激活热修复:<N>
    快照状态:<N>个最新,<N>个过期

If ARGS starts with "session end"

若ARGS以"session end"开头

Write session summary and activity log.
  1. Get user info from git config
  2. Ask user (or infer from conversation): "What was the goal of this session?"
  3. Scan the conversation for:
    • Files changed (from tool calls)
    • Decisions made
    • Corrections received
    • Mistakes / incidents
  4. Generate timestamp:
    date +%Y-%m-%d-%H%M
  5. Write session log to
    .ai/logs/sessions/<timestamp>.md
    using template:
    markdown
    # Session: <timestamp>
    
    **User**: <name> (<email>)
    **GitHub**: @<username>
    **Goal**: <goal>
    **Outcome**: <completed|partial|failed>
    **Behaviour**: <active behaviour>
    **Files Changed**: <count>
    
    ## Actions
    - <bullet list of what was done>
    
    ## Decisions Made
    - <decisions, linked to memory/decisions/ if saved>
    
    ## Corrections Received
    - <corrections, linked to memory/feedback/ if saved>
    
    ## Mistakes
    - <any mistakes or incidents>
  6. Write activity log to
    .ai/logs/activity/<timestamp>.md
    using compact format:
    markdown
    # Activity: <timestamp>
    
    **User**: <name> (<email>)
    **GitHub**: @<username>
    **Behaviour**: <active>
    **Prompt Count**: <N>
    
    ---
    
    ## #1 — <time>
    "<user prompt>"
    → Loaded: <workflow> | Files: <files> | Correction: <yes/no>
    
    ## #2 — <time>
    ...
  7. Update
    .ai/logs/sessions/INDEX.md
    — append one-line entry
  8. Update
    .ai/logs/activity/INDEX.md
    — append one-line entry
  9. Update "Where We Left Off" and run
    sync
    to regenerate CLAUDE.md
  10. Check promotion thresholds:
    • Any feedback item with 3+ occurrences? → suggest RULES.md update
    • Any hotfix 30+ days without recurrence? → suggest graduation/archive
  11. Report: "Session logged. <N> corrections saved, <N> decisions logged."

写入会话摘要和活动日志。
  1. 从git配置中获取用户信息
  2. 询问用户(或从对话中推断):"本次会话的目标是什么?"
  3. 扫描对话内容以获取:
    • 变更的文件(来自工具调用)
    • 做出的决策
    • 收到的修正
    • 错误/事件
  4. 生成时间戳:
    date +%Y-%m-%d-%H%M
  5. 使用模板将会话日志写入
    .ai/logs/sessions/<timestamp>.md
    markdown
    # Session: <timestamp>
    
    **User**: <name> (<email>)
    **GitHub**: @<username>
    **Goal**: <goal>
    **Outcome**: <completed|partial|failed>
    **Behaviour**: <active behaviour>
    **Files Changed**: <count>
    
    ## Actions
    - <完成操作的项目符号列表>
    
    ## Decisions Made
    - <决策内容,若已保存则链接到memory/decisions/>
    
    ## Corrections Received
    - <修正内容,若已保存则链接到memory/feedback/>
    
    ## Mistakes
    - <任何错误或事件>
  6. 使用紧凑格式将活动日志写入
    .ai/logs/activity/<timestamp>.md
    markdown
    # Activity: <timestamp>
    
    **User**: <name> (<email>)
    **GitHub**: @<username>
    **Behaviour**: <active>
    **Prompt Count**: <N>
    
    ---
    
    ## #1 — <time>
    "<user prompt>"
    → Loaded: <workflow> | Files: <files> | Correction: <yes/no>
    
    ## #2 — <time>
    ...
  7. 更新
    .ai/logs/sessions/INDEX.md
    — 添加一行条目
  8. 更新
    .ai/logs/activity/INDEX.md
    — 添加一行条目
  9. 更新“上次进度”并运行
    sync
    重新生成CLAUDE.md
  10. 检查升级阈值:
    • 任何反馈条目出现3次及以上?→ 建议更新RULES.md
    • 任何热修复30天及以上未复发?→ 建议升级/归档
  11. 反馈:"会话已记录。已保存<N>条修正,已记录<N>项决策。"

If ARGS starts with "continue"

若ARGS以"continue"开头

Load emergency resume file.
  1. Check for
    CONTINUATION.md
    in project root
  2. If not found: "No continuation file found. Start a fresh session with
    /codeskill session start
    ."
  3. If found: read and display it, then delete it
  4. Report: "Loaded resume point. Continuation file deleted."

加载紧急恢复文件。
  1. 检查项目根目录中是否存在
    CONTINUATION.md
  2. 若未找到:"未找到恢复文件。请使用
    /codeskill session start
    启动新会话。"
  3. 若找到:读取并显示内容,然后删除该文件
  4. 反馈:"已加载恢复点。恢复文件已删除。"

If ARGS starts with "feedback"

若ARGS以"feedback"开头

Save a user correction to memory.
  1. Get user info from git config
  2. Parse the correction from ARGS (after "feedback"), or ask user to describe it
  3. Classify:
    • Does it reference project-specific files/paths? →
      scope: project
    • Is it about general coding/AI behaviour? →
      scope: global_candidate
  4. Check for duplicates: grep
    .ai/memory/feedback/
    for similar content
    • If similar exists: update the existing entry instead of creating new
  5. Generate filename from correction summary (slugified)
  6. Write to
    .ai/memory/feedback/<slug>.md
    :
    markdown
    ---
    date: <today>
    type: correction
    user: "@<username>"
    scope: <project|global_candidate>
    trigger: "<what AI did wrong>"
    ---
    
    <correction content>
  7. Update
    .ai/memory/INDEX.md
  8. Apply immediately in current session (add to working context)
  9. If scope is
    global_candidate
    : "This looks global (no project-specific refs). Consider adding to your global repo."
  10. Report: "Saved correction to memory/feedback/<slug>.md. Applying for this session."

将用户修正保存到记忆中。
  1. 从git配置中获取用户信息
  2. 解析ARGS中"feedback"之后的修正内容,或询问用户描述修正内容
  3. 分类:
    • 是否涉及项目特定文件/路径?→
      scope: project
    • 是否关于通用编码/AI行为?→
      scope: global_candidate
  4. 检查重复内容:在
    .ai/memory/feedback/
    中搜索相似内容
    • 若存在相似内容:更新已有条目而非创建新条目
  5. 根据修正摘要生成文件名(slug格式)
  6. 将内容写入
    .ai/memory/feedback/<slug>.md
    markdown
    ---
    date: <today>
    type: correction
    user: "@<username>"
    scope: <project|global_candidate>
    trigger: "<AI的错误行为>"
    ---
    
    <修正内容>
  7. 更新
    .ai/memory/INDEX.md
  8. 在当前会话中立即应用(添加到工作上下文)
  9. 若范围为
    global_candidate
    :"此内容看起来是全局通用的(无项目特定引用)。考虑添加到你的全局仓库。"
  10. 反馈:"已将修正保存到memory/feedback/<slug>.md。将在本次会话中应用。"

If ARGS starts with "decide"

若ARGS以"decide"开头

Log an AI decision to memory.
  1. Get user info from git config
  2. Parse decision title and context from ARGS
  3. Ask user if not provided:
    • What was decided?
    • What alternatives were considered?
    • Why this choice?
  4. Classify scope (same logic as feedback)
  5. Write to
    .ai/memory/decisions/<slug>.md
    :
    markdown
    ---
    date: <today>
    type: decision
    user: "@<username>"
    scope: <project|global_candidate>
    context: "<what prompted this decision>"
    ---
    
    # <Decision Title>
    
    **Decision**: <what was decided>
    **Alternatives**: <what else was considered>
    **Why**: <reasoning>
    **Trade-off**: <what we gave up>
    **Outcome**: pending review
  6. Update
    .ai/memory/INDEX.md
  7. Report: "Decision logged to memory/decisions/<slug>.md"

将AI决策记录到记忆中。
  1. 从git配置中获取用户信息
  2. 解析ARGS中的决策标题和上下文
  3. 若未提供则询问用户:
    • 做出了什么决策?
    • 考虑过哪些替代方案?
    • 为何选择此方案?
  4. 分类范围(与feedback逻辑相同)
  5. 将内容写入
    .ai/memory/decisions/<slug>.md
    markdown
    ---
    date: <today>
    type: decision
    user: "@<username>"
    scope: <project|global_candidate>
    context: "<触发此决策的场景>"
    ---
    
    # <决策标题>
    
    **Decision**: <决策内容>
    **Alternatives**: <其他考虑的方案>
    **Why**: <决策理由>
    **Trade-off**: <做出的妥协>
    **Outcome**: pending review
  6. 更新
    .ai/memory/INDEX.md
  7. 反馈:"决策已记录到memory/decisions/<slug>.md"

If ARGS starts with "incident"

若ARGS以"incident"开头

Create an incident report.
  1. Get user info from git config
  2. Parse description from ARGS, or ask user to describe what went wrong
  3. Check
    .ai/logs/incidents/INDEX.md
    for similar past incidents (same category)
  4. Count recurrences
  5. Generate timestamp filename
  6. Write to
    .ai/logs/incidents/<date>-<slug>.md
    :
    markdown
    # Incident: <short description>
    
    **Date**: <today>
    **User**: @<username>
    **Severity**: <low|medium|high|critical>
    **Category**: <generated-code|db-access|graphql|config|deployment|testing|other>
    **Rule Violated**: <ref or "none  new rule needed">
    **Recurrence**: <1st|2nd|Nth>
    
    ## What Happened
    <description>
    
    ## Root Cause
    <why the AI made this mistake>
    
    ## Detection Signal
    <how to catch this next time>
    
    ## Prevention
    - [ ] Added to HOTFIXES.md (if recurrence >= 2)
    - [ ] Updated relevant workflow/rule
    - [ ] Saved correction to memory/feedback/
  7. Update
    .ai/logs/incidents/INDEX.md
  8. If recurrence >= 2: auto-add to
    .ai/HOTFIXES.md
    and run
    sync
  9. Report: "Incident logged. Recurrence: <N>." + hotfix promotion if applicable

创建事件报告。
  1. 从git配置中获取用户信息
  2. 解析ARGS中的描述内容,或询问用户描述问题
  3. 检查
    .ai/logs/incidents/INDEX.md
    中是否存在相似的过往事件(同一类别)
  4. 统计复发次数
  5. 生成时间戳文件名
  6. 将内容写入
    .ai/logs/incidents/<date>-<slug>.md
    markdown
    # Incident: <简短描述>
    
    **Date**: <today>
    **User**: @<username>
    **Severity**: <low|medium|high|critical>
    **Category**: <generated-code|db-access|graphql|config|deployment|testing|other>
    **Rule Violated**: <规则引用或"none  new rule needed">
    **Recurrence**: <1st|2nd|Nth>
    
    ## What Happened
    <事件描述>
    
    ## Root Cause
    <AI犯错的原因>
    
    ## Detection Signal
    <下次如何检测此类问题>
    
    ## Prevention
    - [ ] 添加到HOTFIXES.md(若复发次数>=2)
    - [ ] 更新相关工作流/规则
    - [ ] 将修正保存到memory/feedback/
  7. 更新
    .ai/logs/incidents/INDEX.md
  8. 若复发次数>=2:自动添加到
    .ai/HOTFIXES.md
    并运行
    sync
  9. 反馈:"事件已记录。复发次数:<N>。" + 若适用则提示热修复升级

If ARGS starts with "hotfix"

若ARGS以"hotfix"开头

If ARGS is "hotfix add [description]":
  1. Parse description
  2. Assign next HF-NNN number (read HOTFIXES.md for highest)
  3. Append to
    .ai/HOTFIXES.md
  4. Run
    sync
    to update CLAUDE.md
  5. Report: "Added HF-<NNN> to HOTFIXES.md."
If ARGS is "hotfix review":
  1. Read
    .ai/HOTFIXES.md
  2. For each hotfix, check
    .ai/logs/incidents/INDEX.md
    for last recurrence date
  3. Flag hotfixes with no recurrence in 30+ days
  4. For each stale hotfix, ask user: "Graduate to RULES.md, or archive?"
  5. Apply changes, run
    sync

若ARGS为"hotfix add [description]":
  1. 解析描述内容
  2. 分配下一个HF-NNN编号(读取HOTFIXES.md中的最高编号)
  3. 将内容追加到
    .ai/HOTFIXES.md
  4. 运行
    sync
    更新CLAUDE.md
  5. 反馈:"已添加HF-<NNN>到HOTFIXES.md。"
若ARGS为"hotfix review":
  1. 读取
    .ai/HOTFIXES.md
  2. 对每个热修复,检查
    .ai/logs/incidents/INDEX.md
    中的最后复发日期
  3. 标记30天及以上未复发的热修复
  4. 对每个过期热修复,询问用户:"升级到RULES.md,还是归档?"
  5. 应用变更,运行
    sync

If ARGS starts with "snapshot"

若ARGS以"snapshot"开头

If ARGS is "snapshot list":
  1. Read
    .ai/snapshots/INDEX.md
  2. For each entry, run:
    git diff --name-only <git_hash> HEAD -- <watched_globs>
  3. Print table: topic | last updated | status (fresh/stale) | files changed
If ARGS is "snapshot check [topic]":
  1. Read
    .ai/snapshots/<topic>.md
    frontmatter
  2. Run:
    git diff --name-only <git_hash> HEAD -- <watched_globs>
  3. Report: "fresh" or "stale (N files changed: ...)"
If ARGS is "snapshot refresh [topic]":
  1. Read
    .ai/snapshots/<topic>.md
    frontmatter for
    files_watched
  2. Spawn an Explore agent scoped to those file globs
  3. Write exploration findings to
    .ai/snapshots/<topic>.md
    with fresh git_hash from
    git rev-parse HEAD
  4. Update
    .ai/snapshots/INDEX.md
  5. Report: "Snapshot <topic> refreshed."
If ARGS is "snapshot refresh --all":
  1. Run snapshot list logic, find all stale snapshots
  2. For each stale one, run snapshot refresh
If ARGS is "snapshot create [topic]":
  1. Ask user: "What files/dirs should this snapshot cover?" (get globs)
  2. Spawn Explore agent for that area
  3. Write
    .ai/snapshots/<topic>.md
    with frontmatter: topic, description, git_hash, files_watched
  4. Update
    .ai/snapshots/INDEX.md
  5. Report: "Snapshot <topic> created."

若ARGS为"snapshot list":
  1. 读取
    .ai/snapshots/INDEX.md
  2. 对每个条目,执行:
    git diff --name-only <git_hash> HEAD -- <watched_globs>
  3. 打印表格:主题 | 最后更新时间 | 状态(最新/过期) | 变更文件
若ARGS为"snapshot check [topic]":
  1. 读取
    .ai/snapshots/<topic>.md
    的前置元数据
  2. 执行:
    git diff --name-only <git_hash> HEAD -- <watched_globs>
  3. 反馈:"最新"或"过期(N个文件变更:...)"
若ARGS为"snapshot refresh [topic]":
  1. 读取
    .ai/snapshots/<topic>.md
    前置元数据中的
    files_watched
  2. 生成Explore代理,限定在这些文件匹配规则范围内
  3. 将探索结果写入
    .ai/snapshots/<topic>.md
    ,并使用
    git rev-parse HEAD
    获取的最新git_hash
  4. 更新
    .ai/snapshots/INDEX.md
  5. 反馈:"已刷新快照<topic>。"
若ARGS为"snapshot refresh --all":
  1. 执行snapshot list逻辑,找出所有过期快照
  2. 对每个过期快照,执行snapshot refresh
若ARGS为"snapshot create [topic]":
  1. 询问用户:"此快照应涵盖哪些文件/目录?"(获取匹配规则)
  2. 生成该区域的Explore代理
  3. 写入
    .ai/snapshots/<topic>.md
    ,包含前置元数据:topic、description、git_hash、files_watched
  4. 更新
    .ai/snapshots/INDEX.md
  5. 反馈:"已创建快照<topic>。"

If ARGS starts with "snippet"

若ARGS以"snippet"开头

If ARGS is "snippet [name]":
  1. Search
    .ai/snippets/INDEX.md
    for matching name/tags
  2. If found: display it
  3. If not found: ask user for code, tags, usage context
  4. Write to
    .ai/snippets/<name>.md
    :
    markdown
    # Snippet: <Name>
    
    **Tags**: <tag1, tag2>
    **Used in**: <context>
    
    ## Code
    ```<lang>
    <code>

    When to Use

    <description> ```
  5. Update
    .ai/snippets/INDEX.md

若ARGS为"snippet [name]":
  1. .ai/snippets/INDEX.md
    中搜索匹配的名称/标签
  2. 若找到:显示内容
  3. 若未找到:询问用户获取代码、标签、使用场景
  4. 将内容写入
    .ai/snippets/<name>.md
    markdown
    # Snippet: <Name>
    
    **Tags**: <tag1, tag2>
    **Used in**: <使用场景>
    
    ## Code
    ```<lang>
    <code>

    When to Use

    <使用说明>
    undefined
  5. 更新
    .ai/snippets/INDEX.md

If ARGS starts with "prompt"

若ARGS以"prompt"开头

If ARGS is "prompt [name]":
  1. Search
    .ai/prompts/INDEX.md
    for matching name
  2. If found: display it
  3. If not found: ask user for template text, tags, workflow reference
  4. Write to
    .ai/prompts/<name>.md
    :
    markdown
    # Prompt: <Name>
    
    **Tags**: <tag1, tag2>
    **Workflow**: <workflow reference or "none">
    **Behaviour**: <recommended behaviour>
    
    ## Template
    <prompt template text with [PLACEHOLDERS]>
    
    ## Variants
    <optional variant prompts>
  5. Update
    .ai/prompts/INDEX.md

若ARGS为"prompt [name]":
  1. .ai/prompts/INDEX.md
    中搜索匹配的名称
  2. 若找到:显示内容
  3. 若未找到:询问用户获取模板文本、标签、工作流引用
  4. 将内容写入
    .ai/prompts/<name>.md
    markdown
    # Prompt: <Name>
    
    **Tags**: <tag1, tag2>
    **Workflow**: <工作流引用或"none">
    **Behaviour**: <推荐的行为模式>
    
    ## Template
    <包含[PLACEHOLDERS]的提示词模板文本>
    
    ## Variants
    <可选的变体提示词>
  5. 更新
    .ai/prompts/INDEX.md

If ARGS starts with "plan"

若ARGS以"plan"开头

Manage feature plans. Plans live in
.ai/plans/features/
.
If ARGS is "plan [title]" — Create a new feature plan:
  1. Parse title from ARGS, generate slug (kebab-case)
  2. Ensure
    .ai/plans/PLAN.md
    exists — if not, create from
    templates/plan-index.md
  3. Ensure
    .ai/plans/features/
    directory exists
  4. Ask user for: goal, non-goals, requirements with priorities
  5. Write to
    .ai/plans/features/<slug>-plan.md
    using
    templates/plan.md
  6. Update
    .ai/plans/PLAN.md
    — add entry to Active Plans table
  7. Report: "Plan created at plans/features/<slug>-plan.md"
If ARGS is "plan list" — Show all plans:
  1. Read
    .ai/plans/PLAN.md
  2. Display active and completed tables
If ARGS is "plan archive [slug]" — Archive a completed plan:
  1. Move
    .ai/plans/features/<slug>-plan.md
    to
    .ai/memory/plans/<slug>-plan.md
  2. Move entry from Active to Completed in PLAN.md
  3. Report: "Plan archived to memory/plans/"

管理功能计划。计划存储在
.ai/plans/features/
中。
若ARGS为"plan [title]" — 创建新的功能计划:
  1. 解析ARGS中的标题,生成slug(短横线分隔格式)
  2. 确保
    .ai/plans/PLAN.md
    存在 — 若不存在,从
    templates/plan-index.md
    创建
  3. 确保
    .ai/plans/features/
    目录存在
  4. 询问用户获取:目标、非目标、带优先级的需求
  5. 使用
    templates/plan.md
    将内容写入
    .ai/plans/features/<slug>-plan.md
  6. 更新
    .ai/plans/PLAN.md
    — 在活动计划表格中添加条目
  7. 反馈:"计划已创建于plans/features/<slug>-plan.md"
若ARGS为"plan list" — 显示所有计划:
  1. 读取
    .ai/plans/PLAN.md
  2. 显示活动计划和已完成计划表格
若ARGS为"plan archive [slug]" — 归档已完成的计划:
  1. .ai/plans/features/<slug>-plan.md
    移动到
    .ai/memory/plans/<slug>-plan.md
  2. 在PLAN.md中将条目从活动计划移至已完成计划
  3. 反馈:"计划已归档到memory/plans/"

If ARGS starts with "task"

若ARGS以"task"开头

Manage the task system. Tasks live as individual files in
.ai/tasks/
with a master checklist at
.ai/TASKS.md
.
If ARGS is "task add [description]" — Create a new task:
  1. Parse description and infer priority (or ask user)
  2. Determine next ID: scan
    .ai/tasks/
    and
    .ai/memory/tasks/
    for highest
    task{N}_*.md
    , next = N+1
  3. Generate slug from description (kebab-case)
  4. Write
    .ai/tasks/task{id}_{slug}.md
    :
    markdown
    ---
    id: {id}
    title: '<title>'
    status: pending
    priority: <high|medium|low>
    feature: '<feature or plan name if relevant>'
    dependencies: []
    created_at: "<timestamp>"
    ---
    
    ## Description
    <what needs to be done>
    
    ## Details
    - <specific requirements or steps>
    
    ## Test Strategy
    <how to verify this is done>
  5. Update
    .ai/TASKS.md
    — append entry:
    - [ ] **ID {id}: {Title}** (Priority: {priority})
    > {Description}
  6. Report: "Task {id} created: {title}"
If ARGS is "task list" — Show all tasks:
  1. Read and display
    .ai/TASKS.md
If ARGS is "task start [id]" — Start working on a task:
  1. Read task file, check dependencies are all completed
  2. If dependencies not met → report which are blocking
  3. Complexity check — before starting, assess if the task needs expansion:
    • Involves changes across 3+ unrelated files/modules?
    • Has 5+ acceptance criteria or detail items?
    • Would take more than ~2-3 hours of focused work?
    • Has high uncertainty or multiple distinct outcomes? If YES to 2+ of these → recommend expansion:
    • Propose sub-tasks with titles, descriptions, dependencies
    • Ask user: "This task looks complex. Expand into sub-tasks?"
    • If user agrees → create sub-tasks as
      task{id}.1
      ,
      task{id}.2
      , etc.
    • Update parent task's Details section with sub-task list
    • If user declines → proceed normally
  4. Update task YAML:
    status: inprogress
    ,
    started_at: <timestamp>
  5. Update
    .ai/TASKS.md
    entry:
    [ ]
    [-]
  6. Report: "Started task {id}: {title}"
If ARGS is "task done [id]" — Mark task completed:
  1. If task has
    ## Test Strategy
    → ask user: "Run tests or mark complete?"
  2. Update task YAML:
    status: completed
    ,
    completed_at: <timestamp>
  3. Update
    .ai/TASKS.md
    entry:
    [-]
    [x]
  4. Report: "Completed task {id}: {title}"
If ARGS is "task fail [id] [reason]" — Mark task failed:
  1. Update task YAML:
    status: failed
    ,
    error_log: <reason>
    ,
    completed_at: <timestamp>
  2. Update
    .ai/TASKS.md
    entry →
    [!] ... (Failed)
  3. Report: "Failed task {id}: {reason}"
If ARGS is "task next" — Start the next available task:
  1. Read
    .ai/TASKS.md
    , find first
    [ ]
    (pending) entry
  2. Check its dependencies
  3. If met → start it (same as
    task start
    )
  4. If not met → find next pending with met dependencies
If ARGS is "task archive" — Archive completed/failed tasks:
  1. Scan
    .ai/tasks/
    for files with
    status: completed
    or
    status: failed
  2. For each:
    • Read full content (title, description, dependencies)
    • Move file to
      .ai/memory/tasks/
    • Append to
      .ai/memory/TASKS_LOG.md
      :
      - Archived **ID {id}: {Title}** (Status: {status}) on {timestamp}
      > {Description}
    • Remove entry from
      .ai/TASKS.md
  3. Report: "Archived {N} tasks to memory/tasks/"
If ARGS is "task show [id]" — Show task details:
  1. Find
    task{id}_*.md
    in
    .ai/tasks/
    or
    .ai/memory/tasks/
  2. Display full content
TASKS.md icons:
  • [ ]
    pending
  • [-]
    in-progress
  • [x]
    completed
  • [!]
    failed

管理任务系统。任务作为单独文件存储在
.ai/tasks/
中,主任务清单位于
.ai/TASKS.md
若ARGS为"task add [description]" — 创建新任务:
  1. 解析描述内容并推断优先级(或询问用户)
  2. 确定下一个ID:扫描
    .ai/tasks/
    .ai/memory/tasks/
    中的最高
    task{N}_*.md
    ,下一个ID为N+1
  3. 根据描述生成slug(短横线分隔格式)
  4. 写入
    .ai/tasks/task{id}_{slug}.md
    markdown
    ---
    id: {id}
    title: '<title>'
    status: pending
    priority: <high|medium|low>
    feature: '<相关功能或计划名称>'
    dependencies: []
    created_at: "<timestamp>"
    ---
    
    ## Description
    <任务内容>
    
    ## Details
    - <具体需求或步骤>
    
    ## Test Strategy
    <验证任务完成的方式>
  5. 更新
    .ai/TASKS.md
    — 添加条目:
    - [ ] **ID {id}: {Title}** (Priority: {priority})
    > {Description}
  6. 反馈:"已创建任务{id}:{title}"
若ARGS为"task list" — 显示所有任务:
  1. 读取并显示
    .ai/TASKS.md
若ARGS为"task start [id]" — 开始处理任务:
  1. 读取任务文件,检查所有依赖是否已完成
  2. 若依赖未满足 → 报告阻塞的依赖项
  3. 复杂度检查 — 开始前评估任务是否需要拆分:
    • 是否涉及3个及以上不相关文件/模块的变更?
    • 是否有5个及以上验收标准或细节项?
    • 是否需要超过约2-3小时的专注工作?
    • 是否存在高度不确定性或多种不同结果? 若以上有2项及以上为是 → 建议拆分:
    • 提出子任务的标题、描述、依赖关系
    • 询问用户:"此任务看起来复杂。是否拆分为子任务?"
    • 若用户同意 → 创建子任务为
      task{id}.1
      task{id}.2
    • 更新父任务的Details部分,添加子任务列表
    • 若用户拒绝 → 正常进行
  4. 更新任务YAML:
    status: inprogress
    ,
    started_at: <timestamp>
  5. 更新
    .ai/TASKS.md
    中的条目:
    [ ]
    [-]
  6. 反馈:"已开始任务{id}:{title}"
若ARGS为"task done [id]" — 标记任务完成:
  1. 若任务包含
    ## Test Strategy
    → 询问用户:"运行测试还是标记完成?"
  2. 更新任务YAML:
    status: completed
    ,
    completed_at: <timestamp>
  3. 更新
    .ai/TASKS.md
    中的条目:
    [-]
    [x]
  4. 反馈:"已完成任务{id}:{title}"
若ARGS为"task fail [id] [reason]" — 标记任务失败:
  1. 更新任务YAML:
    status: failed
    ,
    error_log: <reason>
    ,
    completed_at: <timestamp>
  2. 更新
    .ai/TASKS.md
    中的条目 →
    [!] ... (Failed)
  3. 反馈:"任务{id}失败:{reason}"
若ARGS为"task next" — 开始下一个可用任务:
  1. 读取
    .ai/TASKS.md
    ,找到第一个
    [ ]
    (待处理)条目
  2. 检查其依赖项
  3. 若依赖满足 → 开始任务(与
    task start
    相同)
  4. 若依赖未满足 → 找到下一个依赖满足的待处理任务
若ARGS为"task archive" — 归档已完成/失败的任务:
  1. 扫描
    .ai/tasks/
    status: completed
    status: failed
    的文件
  2. 对每个文件:
    • 读取完整内容(标题、描述、依赖关系)
    • 将文件移动到
      .ai/memory/tasks/
    • 将内容追加到
      .ai/memory/TASKS_LOG.md
      - Archived **ID {id}: {Title}** (Status: {status}) on {timestamp}
      > {Description}
    • .ai/TASKS.md
      中移除条目
  3. 反馈:"已归档{N}个任务到memory/tasks/"
若ARGS为"task show [id]" — 显示任务详情:
  1. .ai/tasks/
    .ai/memory/tasks/
    中查找
    task{id}_*.md
  2. 显示完整内容
TASKS.md图标说明:
  • [ ]
    待处理
  • [-]
    进行中
  • [x]
    已完成
  • [!]
    失败

If ARGS starts with "handoff"

若ARGS以"handoff"开头

Generate a handoff document for downstream repos/teams.
If ARGS is "handoff [plan-slug]" — Generate handoff from a plan:
  1. Read
    .ai/plans/features/<slug>-plan.md
  2. If plan has no "Handoff Context" section or it's empty → ask user:
    • What downstream repo needs this?
    • What was built? (endpoints, schemas, events)
    • What's the interface contract? (response shapes, payloads)
    • Decisions that affect downstream?
    • How to sync? (SDK regen command, config update)
  3. Fill the "Handoff Context" section in the plan
  4. Also generate a standalone handoff file at
    .ai/handoffs/<slug>.md
    :
    markdown
    # Handoff: <Plan Title>
    
    **From**: <this repo>
    **To**: <downstream repo>
    **Date**: <today>
    **Plan**: plans/features/<slug>-plan.md
    
    ## What Was Built
    <endpoints, schemas, APIs, events>
    
    ## Interface Contract
    <response shapes, payloads, types>
    
    ## Decisions Affecting Downstream
    <key choices that downstream needs to know about>
    
    ## How to Sync
    <commands to run, config to update, deploy steps>
    
    ## Tasks for Downstream
    - [ ] <suggested task 1>
    - [ ] <suggested task 2>
  5. Report: "Handoff generated. Share
    .ai/handoffs/<slug>.md
    with downstream repo."
If ARGS is "handoff list" — Show all handoffs:
  1. List files in
    .ai/handoffs/

为下游仓库/团队生成交接文档。
若ARGS为"handoff [plan-slug]" — 根据计划生成交接文档:
  1. 读取
    .ai/plans/features/<slug>-plan.md
  2. 若计划中没有"Handoff Context"部分或为空 → 询问用户:
    • 哪个下游仓库需要此文档?
    • 构建了什么?(端点、 schema、事件)
    • 接口契约是什么?(响应格式、负载)
    • 影响下游的决策有哪些?
    • 如何同步?(SDK重新生成命令、配置更新)
  3. 填充计划中的"Handoff Context"部分
  4. 同时生成独立的交接文件
    .ai/handoffs/<slug>.md
    markdown
    # Handoff: <Plan Title>
    
    **From**: <当前仓库>
    **To**: <下游仓库>
    **Date**: <today>
    **Plan**: plans/features/<slug>-plan.md
    
    ## What Was Built
    <端点、schema、API、事件>
    
    ## Interface Contract
    <响应格式、负载、类型>
    
    ## Decisions Affecting Downstream
    <下游需要了解的关键决策>
    
    ## How to Sync
    <要运行的命令、要更新的配置、部署步骤>
    
    ## Tasks for Downstream
    - [ ] <建议的任务1>
    - [ ] <建议的任务2>
  5. 反馈:"交接文档已生成。请分享
    .ai/handoffs/<slug>.md
    给下游仓库。"
若ARGS为"handoff list" — 显示所有交接文档:
  1. 列出
    .ai/handoffs/
    中的文件

If ARGS starts with "memory search"

若ARGS以"memory search"开头

Search feedback and decisions.
  1. Parse query from ARGS after "memory search"
  2. Grep
    .ai/memory/feedback/
    and
    .ai/memory/decisions/
    for the query
  3. Display matching entries with file paths

搜索反馈和决策内容。
  1. 解析ARGS中"memory search"之后的查询内容
  2. .ai/memory/feedback/
    .ai/memory/decisions/
    中搜索查询内容
  3. 显示匹配的条目及其文件路径

If ARGS starts with "status"

若ARGS以"status"开头

Show current system state.
  1. Read active behaviour (from CLAUDE.md or behaviours/)
  2. Count active hotfixes in HOTFIXES.md
  3. Count recent incidents (last 30 days) from logs/incidents/INDEX.md
  4. Check snapshot staleness (summary: N fresh, N stale)
  5. Count feedback entries and decisions
  6. Read last session from logs/sessions/INDEX.md
  7. Print summary:
    codeskill status
    ─────────────────
    Behaviour: default
    Hotfixes: 3 active
    Incidents: 2 (last 30 days)
    Snapshots: 8 fresh, 2 stale
    Memory: 12 feedback, 5 decisions
    Last session: 2026-04-17 by @khanakia — "Add avatar upload"

显示当前系统状态。
  1. 读取当前激活的行为模式(来自CLAUDE.md或behaviours/)
  2. 统计HOTFIXES.md中的当前激活热修复数量
  3. 统计最近30天的事件数量(来自logs/incidents/INDEX.md)
  4. 检查快照时效性(摘要:N个最新,N个过期)
  5. 统计反馈条目和决策的数量
  6. 读取最后一次会话记录(来自logs/sessions/INDEX.md)
  7. 打印摘要:
    codeskill status
    ─────────────────
    Behaviour: default
    Hotfixes: 3 active
    Incidents: 2 (last 30 days)
    Snapshots: 8 fresh, 2 stale
    Memory: 12 feedback, 5 decisions
    Last session: 2026-04-17 by @khanakia — "Add avatar upload"

If ARGS starts with "health"

若ARGS以"health"开头

Score system health 1-10.
  1. Freshness (30%): Check dates on snapshots, last session, HOTFIXES
  2. Relevance (30%): Verify file paths referenced in memory/feedback still exist
  3. Completeness (20%): Check core files exist (RULES.md, taste.md, HOTFIXES.md, at least 1 snapshot)
  4. Actionability (20%): Check "Where We Left Off" in CLAUDE.md is present and specific
  5. Compute weighted score
  6. Print per-dimension scores and total
  7. If < 5: suggest
    /codeskill recover

为系统健康度评分(1-10分)。
  1. 新鲜度(30%):检查快照、上次会话、HOTFIXES的日期
  2. 相关性(30%):验证memory/feedback中引用的文件路径是否仍存在
  3. 完整性(20%):检查核心文件是否存在(RULES.md、taste.md、HOTFIXES.md、至少1个快照)
  4. 可执行性(20%):检查CLAUDE.md中的“上次进度”是否存在且具体
  5. 计算加权得分
  6. 打印各维度得分和总分
  7. 若得分<5:建议运行
    /codeskill recover

If ARGS starts with "compress"

若ARGS以"compress"开头

Run auto-compression on logs, memory, hotfixes.
  1. Check line counts of:
    • HOTFIXES.md
      (cap: 75 lines)
    • logs/sessions/INDEX.md
      (cap: 150 lines)
    • logs/activity/
      individual files (cap: 150 lines each)
    • memory/feedback/INDEX.md
      (cap: 150 lines)
  2. For each file over cap:
    • HOTFIXES: suggest graduating oldest to RULES.md or archiving
    • Session INDEX: archive entries older than 30 days
    • Activity logs: truncate oldest prompts, keep corrections
    • Memory INDEX: merge similar entries
  3. Report: "Compressed N files. Removed N stale entries."

对日志、记忆、热修复进行自动压缩。
  1. 检查以下文件的行数:
    • HOTFIXES.md
      (上限:75行)
    • logs/sessions/INDEX.md
      (上限:150行)
    • logs/activity/
      中的单个文件(上限:150行)
    • memory/feedback/INDEX.md
      (上限:150行)
  2. 对每个超过上限的文件:
    • HOTFIXES:建议将最旧的条目升级到RULES.md或归档
    • 会话INDEX:归档30天以上的条目
    • 活动日志:截断最旧的提示词,保留修正内容
    • 记忆INDEX:合并相似条目
  3. 反馈:"已压缩{N}个文件。已移除{N}个过期条目。"

If ARGS starts with "recover"

若ARGS以"recover"开头

Recovery mode — rebuild from git + code.
  1. Warn user: "Recovery mode will re-explore the codebase and verify all stored data. Continue?"
  2. Scan project: read go.mod/package.json, README, directory structure
  3. Read git history:
    git log --oneline -20
  4. Re-explore and regenerate all stale snapshots
  5. Verify file paths in memory/feedback/ and memory/decisions/ — flag broken refs
  6. Rebuild ARCHITECTURE.md and STACK.md if missing
  7. Run
    sync
    to regenerate CLAUDE.md
  8. Report: "Recovery complete. Health score: <N>/10"

恢复模式 — 从git和代码重建系统。
  1. 警告用户:"恢复模式将重新探索代码库并验证所有存储的数据。是否继续?"
  2. 扫描项目:读取go.mod/package.json、README、目录结构
  3. 读取git历史:
    git log --oneline -20
  4. 重新探索并重新生成所有过期快照
  5. 验证memory/feedback/和memory/decisions/中的文件路径 — 标记无效引用
  6. 若缺失则重建ARCHITECTURE.md和STACK.md
  7. 运行
    sync
    重新生成CLAUDE.md
  8. 反馈:"恢复完成。健康度评分:<N>/10"

If ARGS starts with "save-state"

若ARGS以"save-state"开头

Write emergency CONTINUATION.md.
  1. Scan conversation for: current task, files being edited, what's done, what's in progress
  2. Write
    CONTINUATION.md
    to project root (max 50 lines):
    markdown
    # Continue: <task>
    
    Resume from: `<file:line>`<what was being done>
    
    ## State
    - [x] <completed items>
    - [ ] <in progress items>
    - [ ] <remaining items>
    
    ## Immediate Next Action
    <exact next step>
  3. Report: "State saved to CONTINUATION.md. Next session will auto-load it."

写入紧急CONTINUATION.md文件。
  1. 扫描对话内容获取:当前任务、正在编辑的文件、已完成内容、进行中的内容
  2. 将内容写入项目根目录的
    CONTINUATION.md
    (最多50行):
    markdown
    # Continue: <task>
    
    Resume from: `<file:line>`<正在进行的工作>
    
    ## State
    - [x] <已完成项>
    - [ ] <进行中项>
    - [ ] <剩余项>
    
    ## Immediate Next Action
    <具体的下一步操作>
  3. 反馈:"状态已保存到CONTINUATION.md。下次会话将自动加载。"

If ARGS starts with "export"

若ARGS以"export"开头

If ARGS is "export cursor":
  1. Read
    .ai/RULES.md
    ,
    .ai/taste.md
    ,
    .ai/PATTERNS.md
  2. Generate
    .cursor/rules/
    files from the content
  3. Report: "Generated .cursor/rules/ from .ai/"
If ARGS is "export copilot":
  1. Read
    .ai/RULES.md
    ,
    .ai/taste.md
    ,
    .ai/PATTERNS.md
  2. Generate
    .github/copilot-instructions.md
  3. Report: "Generated copilot-instructions.md from .ai/"

若ARGS为"export cursor":
  1. 读取
    .ai/RULES.md
    .ai/taste.md
    .ai/PATTERNS.md
  2. 根据内容生成
    .cursor/rules/
    文件
  3. 反馈:"已从.ai/生成.cursor/rules/"
若ARGS为"export copilot":
  1. 读取
    .ai/RULES.md
    .ai/taste.md
    .ai/PATTERNS.md
  2. 生成
    .github/copilot-instructions.md
  3. 反馈:"已从.ai/生成copilot-instructions.md"

If ARGS is empty or "help"

若ARGS为空或"help"

Show available commands:
codeskill — AI Project Intelligence System

Setup:
  init                    Scaffold .ai/ directory
  sync                    Regenerate CLAUDE.md from .ai/ files
  status                  Show current state

Behaviours:
  behaviour <name>        Switch mode (default, careful, review, debug, scaffold)
  behaviour list          List available behaviours

Session:
  session start           Load context, check staleness, report status
  session end             Write session log + activity log
  continue                Load CONTINUATION.md resume point
  save-state              Write emergency CONTINUATION.md

Learning:
  learn <lesson>          Learn NOW — save + apply immediately in current session
  feedback <correction>   Save user correction to memory
  decide <title>          Log a decision to memory
  incident <description>  Create incident report
  hotfix add <desc>       Add to active hotfixes
  hotfix review           Review stale hotfixes for graduation

Assets:
  snippet <name>          Find or create code snippet
  prompt <name>           Find or create prompt template

Planning:
  plan <title>            Create feature plan in plans/features/
  plan list               Show all active and completed plans
  plan archive <slug>     Move completed plan to memory/plans/
  handoff <plan-slug>     Generate handoff doc for downstream repo/team
  handoff list            Show all handoffs

Tasks:
  task add <description>  Create task file + add to TASKS.md
  task list               Show master checklist (TASKS.md)
  task start <id>         Start task (check dependencies first)
  task done <id>          Mark task completed
  task fail <id> <reason> Mark task failed with reason
  task next               Start next available pending task
  task archive            Archive completed/failed to memory/tasks/
  task show <id>          Show full task details

Memory:
  memory search <query>   Search feedback and decisions

Snapshots:
  snapshot list           Show all + staleness
  snapshot check <topic>  Check specific snapshot
  snapshot refresh <topic> Re-explore and update
  snapshot refresh --all  Refresh all stale
  snapshot create <topic> Create new snapshot

Maintenance:
  health                  Score system health 1-10
  compress                Auto-compress logs, memory, hotfixes
  recover                 Rebuild from git + code

Export:
  export cursor           Generate .cursor/rules/
  export copilot          Generate copilot-instructions.md

显示可用命令:
codeskill — AI Project Intelligence System

Setup:
  init                    搭建.ai/目录
  sync                    从.ai/文件重新生成CLAUDE.md
  status                  显示当前状态

Behaviours:
  behaviour <name>        切换模式(default、careful、review、debug、scaffold)
  behaviour list          列出可用行为模式

Session:
  session start           加载上下文,检查时效性,报告状态
  session end             写入会话日志 + 活动日志
  continue                加载CONTINUATION.md恢复点
  save-state              写入紧急CONTINUATION.md

Learning:
  learn <lesson>          立即学习 — 保存并在当前会话中立即应用
  feedback <correction>   将用户修正保存到记忆
  decide <title>          将决策记录到记忆
  incident <description>  创建事件报告
  hotfix add <desc>       添加到当前激活热修复
  hotfix review           回顾过期热修复以进行升级

Assets:
  snippet <name>          查找或创建代码片段
  prompt <name>           查找或创建提示词模板

Planning:
  plan <title>            在plans/features/中创建功能计划
  plan list               显示所有活动和已完成计划
  plan archive <slug>     将已完成计划移动到memory/plans/
  handoff <plan-slug>     为下游仓库/团队生成交接文档
  handoff list            显示所有交接文档

Tasks:
  task add <description>  创建任务文件并添加到TASKS.md
  task list               显示主任务清单(TASKS.md)
  task start <id>         开始任务(先检查依赖)
  task done <id>          标记任务完成
  task fail <id> <reason> 标记任务失败并记录原因
  task next               开始下一个可用的待处理任务
  task archive            将已完成/失败任务归档到memory/tasks/
  task show <id>          显示完整任务详情

Memory:
  memory search <query>   搜索反馈和决策内容

Snapshots:
  snapshot list           显示所有快照及其时效性
  snapshot check <topic>  检查特定快照
  snapshot refresh <topic> 重新探索并更新快照
  snapshot refresh --all  刷新所有过期快照
  snapshot create <topic> 创建新快照

Maintenance:
  health                  为系统健康度评分(1-10分)
  compress                自动压缩日志、记忆、热修复
  recover                 从git和代码重建系统

Export:
  export cursor           生成.cursor/rules/
  export copilot          生成copilot-instructions.md

Important Rules for This Skill

本技能的重要规则

  1. Never modify CLAUDE.md directly — always run
    sync
    to regenerate it
  2. Every feedback/decision entry needs: date, user (@username), scope (project/global_candidate/global)
  3. Auto-save corrections: When you detect user corrections during normal work (not just when this skill is invoked), save them to memory/feedback/
  4. Check before exploring: Always check snapshots before spawning Explore agents
  5. Compact encoding: All .ai/ files use tables > prose, file:line refs, one-line summaries
  6. Never store secrets in any .ai/ file
  1. 切勿直接修改CLAUDE.md — 始终运行
    sync
    重新生成
  2. 每个反馈/决策条目必须包含:日期、用户(@username)、范围(project/global_candidate/global)
  3. 自动保存修正:在正常工作中检测到用户修正时(不仅在调用本技能时),将其保存到memory/feedback/
  4. 探索前检查:生成Explore代理前始终检查快照
  5. 紧凑编码:所有.ai/文件优先使用表格而非散文,使用file:line引用和单行摘要
  6. 切勿在任何.ai/文件中存储机密信息