用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/duc01226/EasyPlatform --skill learn命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | learn |
| description | [Utilities] Use when you need to teach Claude lessons that persist across sessions. |
| disable-model-invocation | false |
Codex compatibility note:
- Invoke repository skills with
$skill-namein Codex; this mirrored copy rewrites legacy Claude/skill-namereferences.- Task tracker mandate: BEFORE executing any workflow or skill step, create/update task tracking for all steps and keep it synchronized as progress changes.
- User-question prompts mean to ask the user directly in Codex.
- Ignore Claude-specific mode-switch instructions when they appear.
- Strict execution contract: when a user explicitly invokes a skill, execute that skill protocol as written.
- Subagent authorization: when a skill is user-invoked or AI-detected and its protocol requires subagents, that skill activation authorizes use of the required
spawn_agentsubagent(s) for that task.- Do not skip, reorder, or merge protocol steps unless the user explicitly approves the deviation first.
- For workflow skills, execute each listed child-skill step explicitly and report step-by-step evidence.
- If a required step/tool cannot run in this environment, stop and ask the user before adapting.
Codex uses static project-reference loading instead of runtime-injected project docs. When coding, planning, debugging, testing, or reviewing, open project docs explicitly using this routing.
Always read:
docs/project-config.json (project-specific paths, commands, modules, and workflow/test settings)docs/project-reference/docs-index-reference.md (routes to the full docs/project-reference/* catalog)docs/project-reference/lessons.md (always-on guardrails and anti-patterns)Missing/stale context route: If docs/project-config.json, the docs index, lessons.md, CLAUDE.md, AGENTS.md, or any task-required reference doc is missing or stale, auto-run $project-init or the narrow setup route ($project-config, $docs-init, $scan-all, $scan --target=<key>, $claude-md-init) before ordinary project-specific work. If Codex mirrors or AGENTS.md are missing/stale, ask the user to run $sync-codex; do not auto-run it.
Situation-based docs:
backend-patterns-reference.md, domain-entities-reference.md, project-structure-reference.mdfrontend-patterns-reference.md, scss-styling-guide.md, design-system/README.mddocs/specs/ pathing, or TC format: feature-spec-reference.md, spec-system-reference.md, spec-principles.mdworkflow-spec-test-code-cycle-reference.md plus the spec docs abovespec-system-reference.md and source Feature Specs under docs/specs/integration-test-reference.mde2e-test-reference.mdcode-review-rules.md plus domain docs above based on changed filesDo not read all docs blindly. Start from docs-index-reference.md, then open only relevant files for the task.
Goal: Teach Claude lessons that persist across sessions by saving to the most relevant reference doc.
Workflow:
Learn Review + $why-review)$prompt-enhance on modified file(s) to optimize AI attention anchoringKey Rules:
docs/project-reference/lessons.mdBe skeptical. Apply critical thinking, sequential thinking. Every claim needs traced proof, confidence percentages (Idea should be more than 80%).
$learn always use the validation framework fluent API instead of throwing ValidationException
$learn never call external APIs in command handlers - use Entity Event Handlers
$learn prefer async/await over .then() chains
$learn list
$learn remove 3
$learn clear
Each docs/project-reference/ file is auto-initialized by session-init-docs.cjs hook and populated by /scan-* skills. Understanding their roles is critical for correct routing: routing is static — read the doc whose Read Trigger matches your task.
| File | Role & Content | Read Trigger (static) | Scan Skill |
|---|---|---|---|
project-structure-reference.md | Architecture, directory tree, tech stack, module registry, service map | New area / architecture work | $scan --target=project-structure |
backend-patterns-reference.md | Backend/hook patterns: CJS modules, CQRS, repositories, validation, message bus, background jobs | Editing backend / CQRS / API files | $scan --target=backend-patterns |
seed-test-data-reference.md | Seed/dev-data patterns: environment gate, idempotency loop, DI scope safety, command-dispatch | Seeder / DataSeeder file edits | $scan --target=seed-test-data |
frontend-patterns-reference.md | Frontend patterns: components, state mgmt, API services, styling conventions, directives | Editing frontend / UI files | $scan --target=frontend-patterns |
integration-test-reference.md | Test architecture: base classes, fixtures, helpers, service-specific setup, test runners | Integration test file edits | $scan --target=integration-tests |
feature-spec-reference.md | Feature doc templates, app-to-service mapping, doc structure conventions | Authoring / reading feature specs | $scan --target=feature-spec |
code-review-rules.md | Review rules, conventions, anti-patterns, decision trees, checklists | Any review skill activation | $scan --target=code-review-rules |
lessons.md | General lessons — fallback catch-all. Read on EVERY task (per project-reference-docs gate) | Every task | Managed by $learn |
scss-styling-guide.md | SCSS/CSS: BEM methodology, mixins, variables, theming, responsive patterns | Styling / SCSS file edits | $scan --target=scss-styling |
design-system/README.md | Design system: tokens overview, component inventory, app-to-doc mapping |
Key insight: lessons.md and code-review-rules.md are the highest-recurrence routing targets — read them on every relevant task. Place high-recurrence lessons where the matching Read Trigger guarantees a future session opens them.
| Gate | Question | Pass | Fail → Action |
|---|---|---|---|
| Recurrence | "Would this mistake recur in a future session WITHOUT this reminder?" | Yes → continue | No → skip $learn; mistake is situational |
| Auto-fix | "Could $code-review, $code-simplifier, $security-review, or $lint catch this automatically?" | No → continue | Yes → skip $learn; update the review skill instead |
Both gates must pass. A lesson review skills already catch adds noise without value. A one-off situational mistake won't be prevented by a persisted rule.
Route to the most relevant file based on lesson content:
| If lesson is about... | Route to | Section hint |
|---|---|---|
| Code review rules, anti-patterns, review checklists, YAGNI/KISS/DRY, naming conventions, review process | docs/project-reference/code-review-rules.md | Add to most relevant section (anti-patterns, rules, checklists) |
| Backend/hook patterns: modules, CQRS, repositories, entities, validation, message bus, background jobs, migrations, configured persistence | docs/project-reference/backend-patterns-reference.md | Add to relevant section or Anti-Patterns section |
| Frontend patterns: components, state stores, forms, API services, styling conventions, directives, pipes | docs/project-reference/frontend-patterns-reference.md | Add to relevant section or Anti-Patterns section |
| Integration/unit tests: test base classes, fixtures, test helpers, test patterns, assertions, test runners | docs/project-reference/integration-test-reference.md | Add to relevant section |
| E2E tests: Playwright, Cypress, Selenium, page objects, E2E config, browser automation, visual regression | docs/project-reference/e2e-test-reference.md | Add to relevant section |
| Domain entities, data models, DTOs, aggregates, entity relationships, cross-service data sync, ER diagrams | docs/project-reference/domain-entities-reference.md | Add to Entity Catalog or Relationships section |
| Project structure, directory organization, module boundaries, tech stack choices, service architecture | docs/project-reference/project-structure-reference.md | Add to relevant architecture section |
| SCSS/CSS styling, BEM methodology, mixins, variables, theming, responsive design, CSS conventions | docs/project-reference/scss-styling-guide.md | Add to relevant styling section |
| Design system, design tokens, component library, UI kit conventions, Figma-to-code patterns | docs/project-reference/design-system/README.md | Add to relevant design section |
| Feature documentation, doc templates, doc structure conventions, app-to-service doc mapping | docs/project-reference/feature-spec-reference.md | Add to relevant conventions section |
| Documentation indexing, doc organization, doc-to-code relationships, doc lookup patterns |
Before saving any lesson, critically evaluate whether a doc update alone is sufficient or a deeper prevention mechanism is needed:
| Prevention Layer | When to use | Example |
|---|---|---|
| Doc update only | One-off awareness, rare edge case, team convention | "Always use fluent validation API" → docs/project-reference/backend-patterns-reference.md |
Prompt rule (development-rules.md) | Rule that ALL agents must follow on every task | "Grep after bulk edits" → .claude/docs/development-rules.md |
Static protocol lesson (sync-inline-versions.md) | Universal AI mistake, high recurrence, silent failure, any project | "Re-read files after context compaction" → .claude/skills/shared/sync-inline-versions.md |
Hook (.claude/hooks/) | Automated enforcement, must never be forgotten | "Dedup markers must match" → lib/dedup-constants.cjs + consistency test |
Test (.claude/hooks/tests/) | Regression prevention, verifiable invariant | "All hooks import from shared module" → test in test-all-hooks.cjs |
Skill update (.claude/skills/) | Workflow step that should always include this check | "Review changes must check doc staleness" → skill SKILL.md update |
Decision flow:
development-rules.md so all agents see it$plan instead of just saving.After generalizing a lesson, evaluate whether it qualifies as a Static Protocol Lesson in .claude/skills/shared/sync-inline-versions.md. Static protocol lessons are baked into CLAUDE.md, mirrored into AGENTS.md, and synced to Codex carriers through project-init/sync tooling.
Qualification criteria (ALL must be true):
Static Protocol Lessons — Universal AI mistake prevention rules baked into static carriers. Stored in
.claude/skills/shared/sync-inline-versions.mdunder theai-mistake-preventionandai-mistake-prevention:fullSYNC blocks. Each must be universal, high-recurrence, and silent-failure. READ.claude/skills/shared/sync-inline-versions.mdto check for duplicates before adding.
If qualified: Recommend "Doc + Static Protocol Lesson" option. On user approval, append the lesson as a new bullet to the relevant shared SYNC blocks, then run the project-init / sync pipeline so CLAUDE.md, AGENTS.md, and Codex carriers regenerate from the shared source.
If NOT qualified: Explain why (e.g., "Too project-specific", "Already covered by existing Static Protocol Lesson about X", "Low recurrence — only happens in rare edge cases"). Proceed with doc-only or prompt-rule option.
CORE PROTOCOL — do not skip: A
$learnrequest always arrives as a SPECIFIC case ("don't migrate via the bus and spam Elasticsearch"). Saving it verbatim is the default failure mode. You MUST transform specific → generic BEFORE writing: name the underlying class of mistake, drop the incident's nouns, and write a rule that fires across many future cases ("migrations write the DB directly, never via message bus — applies to all migrations"). If you cannot state the lesson without naming this ticket's files/services/tools, it is NOT generic yet — climb one more abstraction level. When in doubt, save the MORE generic version; a too-specific lesson is dead weight injected on every prompt.
Every lesson MUST be root-cause level and generic across any codebase. Apply this 3-step extraction before saving:
Step 1 — Name the FAILURE MODE, not the symptom:
The failure mode is the reasoning or assumption that broke — not what the output looked like.
| Symptom (BAD — reject this) | Failure mode (GOOD — save this) |
|---|---|
| "Used wrong enum value" | "Generated code using an assumed API without verifying it exists in source" |
| "Wrong namespace/import" | "Assumed project setup from convention without reading project-specific config files first" |
| "Happy-path test failed in CI" | "Wrote assertions without tracing what runtime infrastructure the code path requires" |
| "Set properties that don't exist" | "Assumed all types in a hierarchy share the same interface without reading the base class" |
| "Always read file X before Y" | "Assumed execution context without reading the owning layer's contract — fixed at symptom site instead of cause" |
Step 2 — Verify generality:
Does this failure mode apply to ≥3 different contexts or codebases? If only one file or one specific case → go up one abstraction level. A good lesson prevents an entire class of mistakes.
Step 3 — Write as a universal rule:
Anti-pattern examples:
lib/dedup-constants.cjs for marker strings" → project-specific path.claude/docs/hooks/README.md after deleting hooks" → project-specific fileRun these 2 tasks at the end of every $learn operation:
Task 1 — Learn Review (value + generality + recurrence):
docs/project-reference/lessons.md (injected on every prompt), apply stricter bar: high impact + high recurrence only.Task 2 — Run $why-review (adversarial challenge):
$why-review to challenge whether this lesson deserves persistent memory.$code-review, $code-simplifier, $security-review, $lint, hook/test) are insufficient.$learn.docs/{file}. Confirm? [Y/n]"For docs/project-reference/lessons.md (general lessons):
- [YYYY-MM-DD] <lesson text>
For pattern/rules files (code-review-rules, backend-patterns, frontend-patterns, integration-test):
docs/project-reference/lessons.md)docs/project-reference/lessons.md is a static project-reference carrier read during project work. Token budget must be controlled.
Hard limit: 10000 characters (~3333 tokens). Check BEFORE saving any new lesson.
Workflow when adding to docs/project-reference/lessons.md:
wc -c docs/project-reference/lessons.md)Budget Trim process:
Condensing rules:
"Patterns like X break Y syntax" → just state the ruleDoes NOT apply to: Other routing targets (backend-patterns-reference.md, code-review-rules.md, etc.) — those files have their own size and are injected contextually, not on every prompt.
$learn <text> — Route and append lesson to the best-fit file (check budget if target is lessons.md)$learn list — Read and display lessons from ALL 12 target files (show file grouping + char count for lessons.md)$learn remove <N> — Remove lesson from docs/project-reference/lessons.md by line number$learn clear — Clear all lessons from docs/project-reference/lessons.md only (confirm first)$learn trim — Manually trigger Budget Trim on docs/project-reference/lessons.mdWhen Claude detects correction phrases in conversation (e.g., "always use X", "remember this", "never do Y", "from now on"), this skill auto-activates. When auto-inferred (not explicit $learn), confirm with the user before saving: "Save this as a lesson? [Y/n]"
Lessons and pattern references are read statically, per the project-reference-docs gate in CLAUDE.md:
docs/project-reference/lessons.md — read on every task (the gate always includes it).backend-patterns-reference.md, code-review-rules.md, etc.) — read by their matching trigger (see the Reference Doc Catalog table above).Because the routing is static prose, hookless harnesses (Codex) load the same lessons and patterns as Claude Code.
After saving a lesson to any target file, run $prompt-enhance on the modified file(s) to optimize AI attention anchoring and token quality.
When to run:
What it does:
How to invoke:
$prompt-enhance docs/project-reference/<modified-file>.md
Skip conditions (do NOT run prompt-enhance if):
lessons.md AND the file is under 1500 chars (too small to benefit)[IMPORTANT] Use task tracking to break ALL work into small tasks BEFORE starting — including tasks for each file read. This prevents context loss from long files. For simple tasks, AI MUST ATTENTION ask user whether to skip.
Mandatory end tasks are ALWAYS (in order):
- "Run Learn Review (lesson value + generality + recurrence gate)."
- "Run
$why-reviewto challenge whether the lesson is worth persistent memory."- "Run
$prompt-enhance <modified-file>to optimize lesson content for AI attention anchoring."Do NOT mark the skill complete until all 3 tasks run.
AI Mistake Prevention — Failure modes to avoid on every task:
Re-read files after context changes. Context compaction, resume, or long-running work can make memory stale; verify current files before acting. Verify generated content against source evidence. AI hallucinates APIs, names, claims, and document facts. Check the relevant source before documenting or referencing. Check downstream references before deleting or renaming. Removing an artifact can stale docs, generated mirrors, configs, and callers; map references first. Trace the full impact chain after edits. Changing a definition can miss derived outputs and consumers. Follow the affected chain before declaring done. Verify ALL affected outputs, not just the first. One green check is not all green checks; validate every output surface the change can affect. Assume existing values are intentional — ask WHY before changing. Before changing a constant, limit, flag, wording, or pattern, read nearby context and history. Surface ambiguity before acting — don't pick silently. Multiple valid interpretations require an explicit question or stated assumption with risk. Keep shared guidance role-relevant. Universal guidance must help every receiving skill or agent; code-specific obligations belong only in code-specific protocols.
Critical Thinking Mindset — Apply critical thinking, sequential thinking. Every claim needs traced proof, confidence >80% to act. Anti-hallucination: Never present guess as fact — cite sources for every claim, admit uncertainty freely, self-check output for errors, cross-reference independently, stay skeptical of own confidence — certainty without evidence root of all hallucination.
MUST ATTENTION apply critical + sequential thinking — every claim needs appropriate traced evidence (file:line for repo/code claims; source URL or artifact section for research, product, content, and docs claims); confidence >80% to act, <60% DO NOT recommend. Anti-hallucination: never present guess as fact, admit uncertainty freely, cross-reference independently, stay skeptical of own confidence.
MUST ATTENTION apply AI mistake prevention — verify generated content against evidence, trace downstream references before deleting or renaming, verify all affected outputs, re-read files after context loss, and surface ambiguity before acting.
IMPORTANT MUST ATTENTION GENERALIZE FIRST — extract the generic, many-cases rule; NEVER persist the specific incident as written. Strip all ticket/file/service/tool names before saving.
MUST ATTENTION Protocols in force (concise digest of the SYNC/shared blocks this skill carries — full bodies above are canonical):
IMPORTANT MUST ATTENTION run Triage Gate FIRST — if recurrence is low OR review skills can catch it, skip $learn entirely
IMPORTANT MUST ATTENTION check Reference Doc Catalog to find the best target file — NOT always lessons.md
IMPORTANT MUST ATTENTION mandatory end tasks are ALWAYS: Learn Review → $why-review → $prompt-enhance <modified-file> (in order)
IMPORTANT MUST ATTENTION break work into small todo tasks using task tracking BEFORE starting
IMPORTANT MUST ATTENTION prefer auto-injected files for high-recurrence lessons (higher visibility)
[TASK-PLANNING] Before acting, analyze task scope and systematically break it into small todo tasks and sub-tasks using task tracking.
Source: .claude/.ck.json + .claude/skills/shared/sync-inline-versions.md (:full blocks) + .claude/scripts/lib/hookless-prompt-protocol.cjs
Generic portability boundary: Reusable skills and protocol text stay project-neutral; project-specific conventions are discovered from docs/project-config.json and docs/project-reference/. Apply shared AI-SDD from shared/sdd-artifact-contract.md. Read docs/project-config.json and docs/project-reference/docs-index-reference.md, then open the project reference docs named there. For spec, test-case, behavior-change, public-contract, or docs/specs/ work, route through the local spec docs named by the docs index: feature-spec-reference.md, spec-system-reference.md, spec-principles.md, and workflow-spec-test-code-cycle-reference.md when specs/tests/code must stay synchronized. If either file or a required reference doc is missing or stale, auto-run $project-init (or the narrow lower-level route such as $project-config, $docs-init, $scan-all, or $scan --target=<key>) before ordinary project-specific work. Any supported AI tool may execute when this shared context and local docs are available.
$start-workflow <workflowId>; for a selected skill, invoke that skill; for a custom workflow, sequence custom steps directly; for direct execution, proceed with the task.Source: .claude/skills/shared/sync-inline-versions.md
AI-SDD Artifact Contract — Shared spec-driven development rules stay portable and source-owned.
- Keep reusable AI-SDD principles in
.claude; put repository-specific paths, commands, owners, products, and formats in project config/reference docs.- Preserve cycle:
spec -> plan -> tasks -> implement -> verify -> update spec/docs.- Trace every requirement or invariant through decision, task, TC/test, source evidence, and docs/spec update.
- Treat code-to-spec extraction as reference-only until accepted by the canonical spec owner.
- Any supported AI tool may plan, implement, review, or verify with synced context; using multiple tools is optional.
- Update
.claudesource first, then sync generated mirrors; do not manually edit.agents,.codex, orAGENTS.md. — why: mirrors are generated artifacts; hand-edits are overwritten on the next sync- If
docs/project-config.json, root instruction files, or a required project-reference doc is missing or stale, auto-run$project-initor the narrow lower-level route before ordinary project-specific work.Active reference:
shared/sdd-artifact-contract.mdin the active skills root.
shared/sdd-artifact-contract.md; keep reusable AI-SDD in .claude and local rules in project docs..claude source before syncing generated mirrors; do not manually edit .agents, .codex, or AGENTS.md.$project-init or the narrow setup route automatically.
[TASK-PLANNING] [MANDATORY] BEFORE executing any workflow or skill step, create/update task tracking for all planned steps, then keep it synchronized as each step starts/completes.Break work into small tasks (task tracking) before starting. Add final task: "Analyze AI mistakes & lessons learned".
Extract lessons — ROOT CAUSE ONLY, not symptom fixes:
$learn.$code-review/$code-simplifier/$security-review/$lint catch this?" — Yes → improve review skill instead.$learn.
[CRITICAL-THINKING-MINDSET] Apply critical thinking, sequential thinking. Every claim needs traced proof, confidence >80% to act.
Anti-hallucination principle: Never present guess as fact — cite sources for every claim, admit uncertainty freely, self-check output for errors, cross-reference independently, stay skeptical of own confidence — certainty without evidence root of all hallucination.
AI Attention principle (Primacy-Recency): Put the 3 most critical rules at both top and bottom of long prompts/protocols so instruction adherence survives long context windows.
Goal-driven execution: Define success criteria first, loop until verified, and stop only when observable checks pass.
Tests verify intent: Tests must protect business rules/invariants and fail when the protected intent breaks, not only mirror current behavior.| Design / UI file edits |
$scan --target=design-system |
e2e-test-reference.md | E2E test patterns: framework, page objects, config, best practices | E2E file edits | $scan --target=e2e-tests |
domain-entities-reference.md | Domain entities, data models, DTOs, aggregate boundaries, ER diagrams, cross-service sync | Backend / frontend domain work | $scan --target=domain-entities |
docs-index-reference.md | Documentation tree, file counts, doc relationships, keyword-to-doc lookup | Doc lookup / navigation | $scan --target=docs-index |
docs/project-reference/docs-index-reference.md |
| Add to relevant section |
| General lessons, workflow tips, tooling, AI behavior, project conventions, anything not matching above | docs/project-reference/lessons.md | Append as dated list entry |
$start-workflow <workflowId>. NEVER answer or write code before checking. Skip = protocol violation.