AgentSkillsCN

promote

将频繁的学习成果提炼为规则

SKILL.md
--- frontmatter
name: promote
description: Promote frequent learnings to rules
disable-model-invocation: true

Scan files in ~/.claude/cache/learnings/ and suggest promotion candidates to rules.

Important: Project-specific learnings (project != general) are NOT eligible. Only general knowledge can be promoted.

Promotion Criteria

Must satisfy ALL of:

  1. Frequency: frequency >= 3 (encountered 3+ times)
  2. Maturity: first_seen is 14+ days ago (not a one-week fluke)
  3. Recency: last_seen is within 90 days (still relevant)
  4. Generality: project: general only
  5. Status: status: active only
  6. Importance: Ignoring it would lead to bugs, incidents, or inefficiency

Promotion Destination

~/.claude/rules/learnings/{name}.md

Create folder if it doesn't exist.

Conversion on Promotion

Convert learning (specific case) to rule (generalized guideline).

Conversion Example

Original learning:

code
# Ktor RLS Transaction Issue

## Problem
RLS policy not working inside Ktor transaction

## Cause
set_config() was executed outside transaction scope

## Solution
Call set_config() immediately after transaction starts

Promoted rule:

code
# PostgreSQL RLS with Ktor

## Rule
When using transactions in Ktor, call `set_config()` for RLS
at the beginning of the transaction block.

## Reason
If `set_config()`'s 3rd argument is `true` (transaction-local),
executing it outside a transaction will not apply RLS.

## Correct Pattern
```kotlin
transaction {
    exec("SELECT set_config('app.current_user_id', ?, true)", listOf(userId))
    // RLS is active for subsequent queries
}
```

## Wrong Pattern
```kotlin
exec("SELECT set_config('app.current_user_id', ?, true)", listOf(userId))
transaction {
    // RLS not applied!
}
```

Execution Steps

  1. Scan all files in ~/.claude/cache/learnings/
  2. List files meeting promotion criteria
  3. Present proposed rule for each candidate
  4. After user confirmation: a. Create in ~/.claude/rules/learnings/ b. Delete the original learning file

Output Format

Promotion Candidates

Filefreqfirst_seenlast_seenReason
xxx.md32024-12-012025-01-20[reason]

Skipped

FileSkip Reason
yyy.mdFrequency too low (2)
zzz.mdToo recent (first_seen < 14 days)
aaa.mdStale (last_seen > 90 days)
bbb.mdProject-specific
ccc.mdArchived