learned-patterns

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Learned Patterns Management

已学习模式管理

Manage the auto-learning pattern library. View, list, archive, and adjust confidence.
管理自动学习模式库。查看、列出、归档并调整置信度。

Summary

概述

Goal: View, list, archive, boost, or penalize learned patterns in the auto-learning pattern library.
  • List patterns:
    node scripts/list-patterns.cjs [category] [--low|--high]
  • View details:
    node scripts/view-pattern.cjs <id>
  • Adjust confidence:
    node scripts/adjust-confidence.cjs <id> boost|penalize
    (+10% / -15%)
  • Archive:
    node scripts/archive-pattern.cjs <id> [reason]
  • Stats:
    node scripts/pattern-stats.cjs
Key Principles:
  • Patterns auto-decay after 30 days unused; below 20% confidence = auto-archived
  • Lifecycle: Detection (40-80%) -> Confirmation -> Injection -> Feedback Loop -> Decay
  • Max 5 patterns injected per context (~400 tokens)
目标: 查看、列出、归档、提升或降低自动学习模式库中的已学习模式。
  • 列出模式:
    node scripts/list-patterns.cjs [category] [--low|--high]
  • 查看详情:
    node scripts/view-pattern.cjs <id>
  • 调整置信度:
    node scripts/adjust-confidence.cjs <id> boost|penalize
    (+10% / -15%)
  • 归档:
    node scripts/archive-pattern.cjs <id> [reason]
  • 统计信息:
    node scripts/pattern-stats.cjs
核心原则:
  • 未使用的模式会在30天后自动衰减;置信度低于20%时会自动归档
  • 生命周期:检测(40-80%)→ 确认 → 注入 → 反馈循环 → 衰减
  • 每个上下文最多注入5个模式(约400个tokens)

Quick Commands

快速命令

/learned-patterns                    # List all active patterns
/learned-patterns list [category]    # List patterns (optionally filtered)
/learned-patterns list --low|--high  # Filter by confidence
/learned-patterns view <id>          # View pattern details
/learned-patterns archive <id>       # Archive a pattern
/learned-patterns boost <id>         # Increase confidence (+10%)
/learned-patterns penalize <id>      # Decrease confidence (-15%)
/learned-patterns stats              # Show pattern statistics
/learned-patterns                    # 列出所有活跃模式
/learned-patterns list [category]    # 列出模式(可选择过滤)
/learned-patterns list --low|--high  # 按置信度过滤
/learned-patterns view <id>          # 查看模式详情
/learned-patterns archive <id>       # 归档模式
/learned-patterns boost <id>         # 提升置信度(+10%)
/learned-patterns penalize <id>      # 降低置信度(-15%)
/learned-patterns stats              # 显示模式统计信息

Script Execution

脚本执行

ActionScript
List
node .claude/skills/learned-patterns/scripts/list-patterns.cjs [category] [--low|--high]
View
node .claude/skills/learned-patterns/scripts/view-pattern.cjs <id>
Archive
node .claude/skills/learned-patterns/scripts/archive-pattern.cjs <id> [reason]
Boost/Penalize
node .claude/skills/learned-patterns/scripts/adjust-confidence.cjs <id> boost|penalize
Stats
node .claude/skills/learned-patterns/scripts/pattern-stats.cjs
操作脚本
列出
node .claude/skills/learned-patterns/scripts/list-patterns.cjs [category] [--low|--high]
查看
node .claude/skills/learned-patterns/scripts/view-pattern.cjs <id>
归档
node .claude/skills/learned-patterns/scripts/archive-pattern.cjs <id> [reason]
提升/降低置信度
node .claude/skills/learned-patterns/scripts/adjust-confidence.cjs <id> boost|penalize
统计信息
node .claude/skills/learned-patterns/scripts/pattern-stats.cjs

Pattern Lifecycle

模式生命周期

DETECTION (UserPromptSubmit)
  └── Confidence: 40% (implicit) or 80% (explicit /learn)

CONFIRMATION
  └── User confirms → saved | User rejects → discarded

INJECTION (SessionStart/PreToolUse)
  └── Relevant patterns injected (max 5, ~400 tokens)

FEEDBACK LOOP
  └── Followed → +5% | Ignored → -10%

DECAY & PRUNING
  └── 30 days unused → decay | Below 20% → auto-archived
检测(UserPromptSubmit)
  └── 置信度:40%(隐式)或80%(显式/learn)

确认
  └── 用户确认 → 保存 | 用户拒绝 → 丢弃

注入(SessionStart/PreToolUse)
  └── 注入相关模式(最多5个,约400个tokens)

反馈循环
  └── 被遵循 → +5% | 被忽略 → -10%

衰减与清理
  └── 30天未使用 → 衰减 | 低于20% → 自动归档

Confidence Thresholds

置信度阈值

RangeBehavior
80-100%Always injected when relevant
50-79%Injected with context match
30-49%Injected only on strong match
20-29%Candidate for review
< 20%Auto-archived
范围行为
80-100%相关时始终注入
50-79%匹配上下文时注入
30-49%仅强匹配时注入
20-29%待审核候选
< 20%自动归档

Pattern Schema

模式 Schema

yaml
id: pat_abc123
category: backend
type: anti-pattern | best-practice | preference | convention
trigger:
  keywords: [validation, exception]
  file_patterns: ["*CommandHandler.cs"]
content:
  wrong: "throw new ValidationException()"
  right: "return PlatformValidationResult.Invalid()"
  rationale: "Framework uses result pattern, not exceptions"
metadata:
  source: explicit-teaching | user-correction
  confidence: 0.75
  first_seen: 2025-01-10
  occurrences: 3
  confirmations: 2
  conflicts: 0
yaml
id: pat_abc123
category: backend
type: anti-pattern | best-practice | preference | convention
trigger:
  keywords: [validation, exception]
  file_patterns: ["*CommandHandler.cs"]
content:
  wrong: "throw new ValidationException()"
  right: "return PlatformValidationResult.Invalid()"
  rationale: "Framework uses result pattern, not exceptions"
metadata:
  source: explicit-teaching | user-correction
  confidence: 0.75
  first_seen: 2025-01-10
  occurrences: 3
  confirmations: 2
  conflicts: 0

Troubleshooting

故障排除

  • Not injecting: Check confidence, file pattern match, archived status
  • Too many injecting: Archive irrelevant patterns, review
    --low
    confidence list
  • Conflicts with docs: Pattern auto-blocked; update docs or archive pattern
  • 未注入: 检查置信度、文件模式匹配、归档状态
  • 注入过多: 归档无关模式,查看
    --low
    置信度列表
  • 与文档冲突: 模式会被自动屏蔽;更新文档或归档模式

Related

相关功能

  • /learn
    - Teach a new pattern
  • /code-patterns
    - View static code patterns documentation
  • /learn
    - 教授新模式
  • /code-patterns
    - 查看静态代码模式文档

IMPORTANT Task Planning Notes

重要任务规划说明

  • Always plan and break many small todo tasks
  • Always add a final review todo task to review the works done at the end to find any fix or enhancement needed
  • 始终规划并拆分多个小型待办任务
  • 始终添加最终审核待办任务,在结束时检查已完成的工作,找出需要修复或优化的地方