skills/canon/skills/analyze-patterns/SKILL.md
Pattern mining and proposal generation for Canon's learning loop. Analyzes codebase patterns, review history, build execution data, and conventions to produce structured improvement proposals. Covers manual analysis and auto-trigger modes. Loaded by the learner agent.
npx skillsauth add micherra/canon analyze-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill defines the full procedural contract for Canon's learning loop. Load it when you are the learner agent performing pattern analysis. The agent body's read-only constraint is absolute and inherited by this skill — you NEVER modify principles, conventions, or project code.
You receive from the orchestrator:
principle-health, codebase-patterns, convention-lifecycle, process-health, agent-effectiveness).canon/learning.jsonl) if it exists — check for suppressed suggestionsagent-effectiveness dimension, which is the PRIMARY dimension for auto-trigger modeLoad the current state of Canon in this project:
${CLAUDE_PLUGIN_ROOT}/references/principle-loading.md, use list_principles MCP tool for the metadata-only index. Record each principle's id, severity, scope, and tags..canon/CONVENTIONS.md if it exists — these are the project's current conventions..canon/learning.jsonl if it exists — these are previous suggestions. Check for:
"action": "dismissed" — do NOT re-suggest these"action": "suggested" appearing 3+ times — flag as persistent.canon/LEARNING-REPORT.md with a header containing the date and scope summary. Use this format:# Canon Learning Report
Generated: {ISO date}
Dimensions: {comma-separated list of requested dimensions}
Status: in-progress
---
This ensures the file exists even if the agent hits its turn limit during analysis.
Run dimensions in order of data availability. Skip dimensions without sufficient data and note it in the report. After completing each dimension's analysis, immediately append its findings section to .canon/LEARNING-REPORT.md before moving to the next dimension. This ensures partial results are persisted if the turn limit is reached mid-analysis. Run agent-effectiveness AFTER process-health — it benefits from the flow-level patterns already identified by process-health analysis.
Dimension ordering depends on trigger mode:
agent-effectiveness FIRST — it is the primary dimension in this mode. Run process-health after, only if sufficient flow history exists (>= 5 flow runs). The flow history needed by process-health may not yet exist for a fresh build.process-health before agent-effectiveness — agent-effectiveness benefits from the flow-level patterns already identified by process-health analysis.Data sufficiency thresholds:
get_drift_report)get_history MCP tool; supplement with get_build_history for trend analysis across many builds)For each dimension:
${CLAUDE_PLUGIN_ROOT}/references/learner-dimensions.md.Run each requested dimension per the specs in ${CLAUDE_PLUGIN_ROOT}/references/learner-dimensions.md. That file contains:
get_patterns or get_decisions MCP tools — use get_drift_report for principle-health and live Grep/Glob for codebase-patterns)Skip dimensions without sufficient data (thresholds are in the reference file).
Enhance the existing .canon/LEARNING-REPORT.md by appending summary sections and updating the header metadata:
## Recurring Suggestions section listing any suggestions that appeared 3+ times in the learning log.## No Action Needed section listing any skipped dimensions and their reason (insufficient data or not requested).Status: in-progress line in the header to Status: complete and add a final suggestion count: Suggestions: {N}.This step enhances the existing file — it does NOT rewrite it from scratch. All dimension sections written in Step 2 are preserved.
After finalizing the report, append a structured entry to .canon/learning.jsonl using the schema in ${CLAUDE_PLUGIN_ROOT}/references/learner-dimensions.md.
When spawned in auto-trigger mode (you receive transcript paths rather than dimension flags), write structured proposals instead of the learning report.
Create the directory .canon/proposed-learnings/{timestamp}/ where {timestamp} is the current ISO timestamp with colons replaced by hyphens (e.g., 2026-04-08T15-30-00Z).
For each suggestion, write a separate markdown file: {nn}-{slug}.md (e.g., 01-add-error-boundary-convention.md).
Each proposal file follows this format:
---
proposal_id: "{timestamp}-{nn}"
type: "new-convention" | "severity-change" | "principle-revision" | "convention-graduation" | "stale-removal"
confidence: 0.0-1.0
target: "{principle-id or convention text}"
---
## Observation
{What pattern was observed, with quantified evidence}
## Proposed Change
{Exact text to add, modify, or remove}
## Evidence
{Transcript excerpts, file counts, review data that support this}
- Source: {transcript path or data source}
- Metric: {specific number}
## Impact
{What improves if this change is adopted}
Write constraint: Only write files to .canon/proposed-learnings/. Do not write to any other directory. Do not modify .canon/LEARNING-REPORT.md or .canon/learning.jsonl in auto-trigger mode.
After writing all proposals, output a final summary line in this exact format as the LAST line of your response:
CANON_LEARN_NOTIFICATION: Canon learned {N} patterns from recent flows. Run /canon:review-learnings to review.
Where {N} is the number of proposal files written. If no proposals were generated (no actionable patterns found), output:
CANON_LEARN_NOTIFICATION: Canon analyzed recent flows but found no new patterns to propose.
This line is machine-readable — the orchestrator parses it to display a user notification.
| Mode | Write targets | Forbidden |
|------|--------------|-----------|
| Manual (natural language intent) | .canon/LEARNING-REPORT.md, .canon/learning.jsonl | .canon/proposed-learnings/ |
| Auto-trigger (transcript paths received) | .canon/proposed-learnings/{timestamp}/ | .canon/LEARNING-REPORT.md, .canon/learning.jsonl |
Auto-trigger vs manual mode detection: You are in auto-trigger mode when the orchestrator provides transcript paths in your context instead of dimension flags. When spawned via natural language intent (e.g., "analyze codebase patterns"), dimension flags are explicit (--principle-health, --codebase-patterns, etc.) and you are in manual mode.
development
Requirements sharpening for build requests. Classifies request fuzziness into tiers (trivial, clear, fuzzy) and applies proportionate PM effort -- from pass-through to full creative divergence. Produces a sharpened-request artifact for architect hand-off. Used by the PM orchestrator.
data-ai
Procedural how-to for inter-wave handoff coordination: analyze execution reports, push back on weak verdicts, draft next-wave prompts.
development
Principle, convention, and agent-rule authoring. Covers creation, editing, and applying accepted learner proposals. Handles interview, examples, conflict detection, format validation, and save. Loaded by the writer agent.
testing
Mechanical runbook synthesis from canonical step vocabulary. Composes a step-by-step runbook from the design using only canonical step IDs. Validates step composition, enforces mandatory tail, and emits per-signal confidence. Used by the architect agent.