@skill-graph/cli 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +247 -0
- package/LICENSE +200 -0
- package/NOTICE +62 -0
- package/README.md +398 -0
- package/SKILL_GRAPH.md +443 -0
- package/bin/skill-graph.js +374 -0
- package/docs/ADOPTION.md +117 -0
- package/docs/CONFORMANCE.md +66 -0
- package/docs/PRIMER.md +384 -0
- package/docs/QUICKSTART-30MIN.md +333 -0
- package/docs/ROUTING-METRICS.md +120 -0
- package/docs/SKILL-MD-FORMAT-COMPATIBILITY.md +127 -0
- package/docs/SKILL_AUDIT_CHECKLIST.md +199 -0
- package/docs/SKILL_AUDIT_LOOP.md +195 -0
- package/docs/SKILL_METADATA_PROTOCOL.md +609 -0
- package/docs/_archived/marketplace-publication-priority-2026-05-18.md +239 -0
- package/docs/adr/0001-predicate-set.md +69 -0
- package/docs/adr/0002-json-ld-context.md +82 -0
- package/docs/adr/0003-ontoclean-rigidity-tags.md +65 -0
- package/docs/adr/0004-persistent-identifiers.md +74 -0
- package/docs/adr/0005-freshness-consolidation.md +70 -0
- package/docs/adr/0006-revise-predicate-rename.md +105 -0
- package/docs/adr/0007-audit-loop-cadence.md +99 -0
- package/docs/adr/0008-skill-surface-split-and-curation-policy.md +93 -0
- package/docs/category-consumers.md +168 -0
- package/docs/concept-map.md +194 -0
- package/docs/diagrams/drift-states.mmd +21 -0
- package/docs/diagrams/manifest-pipeline.mmd +25 -0
- package/docs/diagrams/routing-harness.mmd +41 -0
- package/docs/diagrams/starter-graph.mmd +53 -0
- package/docs/field-decision-guide.md +315 -0
- package/docs/field-rationale.md +211 -0
- package/docs/field-reference.generated.md +624 -0
- package/docs/field-reference.md +1426 -0
- package/docs/glossary.md +190 -0
- package/docs/head-noun-glossary.md +63 -0
- package/docs/images/audit-phases.png +0 -0
- package/docs/images/drift-states.png +0 -0
- package/docs/images/graded-mode.png +0 -0
- package/docs/images/manifest-pipeline.png +0 -0
- package/docs/images/routing-harness.png +0 -0
- package/docs/images/skill-anatomy.png +0 -0
- package/docs/images/starter-graph.png +0 -0
- package/docs/images/system-model.png +0 -0
- package/docs/integrations/github-actions.md +155 -0
- package/docs/manifest-field-mapping.md +443 -0
- package/docs/marketplace-publication-queue.generated.md +240 -0
- package/docs/marketplace-release-agent-prompt.md +82 -0
- package/docs/marketplace-skill-candidate-list.md +272 -0
- package/docs/marketplace-syndication.md +222 -0
- package/docs/migration-sample-review.md +155 -0
- package/docs/migrations/v4-to-v5.md +168 -0
- package/docs/migrations/v5-to-v6.md +221 -0
- package/docs/name-exceptions.yaml +37 -0
- package/docs/plans/marketplace-p1-public-migration-plan.md +41 -0
- package/docs/plans/multi-root-workspace.md +148 -0
- package/docs/plans/scripts-roadmap.md +107 -0
- package/docs/plans/v4-schema-bump.md +160 -0
- package/docs/plans/wave-2-extraction.md +122 -0
- package/docs/positioning-vs-marketplaces.md +175 -0
- package/docs/proposals/skill-audit-loop-positioning.md +160 -0
- package/docs/quality-doctrine.md +138 -0
- package/docs/recommended-skills.md +150 -0
- package/docs/research/skill-comprehension-eval-research.md +1830 -0
- package/docs/research/skill-retrieval-evidence.md +66 -0
- package/docs/skill-metadata-protocol.md +471 -0
- package/docs/skills-sh-maintainer-cleanup-request.md +80 -0
- package/examples/audits/a11y/findings.md +52 -0
- package/examples/audits/a11y/scorecard.md +21 -0
- package/examples/audits/a11y/verdict.md +44 -0
- package/examples/audits/debugging/findings.md +59 -0
- package/examples/audits/debugging/scorecard.md +22 -0
- package/examples/audits/debugging/verdict.md +33 -0
- package/examples/audits/documentation/findings.md +59 -0
- package/examples/audits/documentation/scorecard.md +22 -0
- package/examples/audits/documentation/verdict.md +33 -0
- package/examples/evals/a11y.json +140 -0
- package/examples/evals/api-design.json +52 -0
- package/examples/evals/code-review.json +52 -0
- package/examples/evals/data-modeling.json +52 -0
- package/examples/evals/database-migration.json +52 -0
- package/examples/evals/debugging.json +118 -0
- package/examples/evals/dependency-architecture.json +52 -0
- package/examples/evals/design-system-architecture.json +52 -0
- package/examples/evals/error-tracking.json +52 -0
- package/examples/evals/event-contract-design.json +52 -0
- package/examples/evals/form-ux-architecture.json +52 -0
- package/examples/evals/framework-fit-analysis.json +52 -0
- package/examples/evals/graph-audit.json +139 -0
- package/examples/evals/information-architecture.json +52 -0
- package/examples/evals/interaction-feedback.json +52 -0
- package/examples/evals/interaction-patterns.json +52 -0
- package/examples/evals/layout-composition.json +52 -0
- package/examples/evals/lint-overlay.json +117 -0
- package/examples/evals/microcopy.json +52 -0
- package/examples/evals/observability-modeling.json +52 -0
- package/examples/evals/pattern-recognition.json +96 -0
- package/examples/evals/performance-engineering.json +52 -0
- package/examples/evals/refactor.json +128 -0
- package/examples/evals/semiotics.json +52 -0
- package/examples/evals/skill-infrastructure.json +96 -0
- package/examples/evals/skill-router.json +140 -0
- package/examples/evals/skill-router.routing.json +113 -0
- package/examples/evals/system-interface-contracts.json +52 -0
- package/examples/evals/task-analysis.json +52 -0
- package/examples/evals/testing-strategy.json +118 -0
- package/examples/evals/type-safety.json +249 -0
- package/examples/evals/visual-design-foundations.json +52 -0
- package/examples/evals/webhook-integration.json +52 -0
- package/examples/exports/a11y.skill-md.md +80 -0
- package/examples/exports/debugging.skill-md.md +80 -0
- package/examples/exports/refactor.skill-md.md +78 -0
- package/examples/exports/testing-strategy.skill-md.md +81 -0
- package/examples/projects/markdown-static-site/README.md +115 -0
- package/examples/projects/markdown-static-site/skills/content-source-router/SKILL.md +131 -0
- package/examples/projects/markdown-static-site/skills/image-optimization-pipeline-config/SKILL.md +132 -0
- package/examples/projects/markdown-static-site/skills/link-rot-detection/SKILL.md +103 -0
- package/examples/projects/markdown-static-site/skills/markdown-post-frontmatter-validation/SKILL.md +133 -0
- package/examples/projects/markdown-static-site/skills/migrate-posts-to-v2-frontmatter/SKILL.md +140 -0
- package/examples/projects/saas-stripe-postgres/README.md +208 -0
- package/examples/projects/saas-stripe-postgres/db/migrations/0004_canonicalize_orders.sql +37 -0
- package/examples/projects/saas-stripe-postgres/db/schema.sql +112 -0
- package/examples/projects/saas-stripe-postgres/skills/migrate-orders-to-canonical-schema/SKILL.md +149 -0
- package/examples/projects/saas-stripe-postgres/skills/nextjs-server-action-validation/SKILL.md +154 -0
- package/examples/projects/saas-stripe-postgres/skills/payment-provider-router/SKILL.md +153 -0
- package/examples/projects/saas-stripe-postgres/skills/postgres-rls-pattern/SKILL.md +163 -0
- package/examples/projects/saas-stripe-postgres/skills/stripe-webhook-signature-verification/SKILL.md +137 -0
- package/examples/protocol/skill-metadata-template.md +301 -0
- package/examples/protocol/skills.manifest.sample.json +13245 -0
- package/examples/skill-metadata-template.md +317 -0
- package/examples/skills.manifest.sample.json +13519 -0
- package/examples/tests/v3-1-skos-fixture/SKILL.md +93 -0
- package/marketplace/README.md +17 -0
- package/marketplace/skills/a11y/SKILL.md +66 -0
- package/marketplace/skills/acid-fundamentals/SKILL.md +106 -0
- package/marketplace/skills/agent-engineering/SKILL.md +386 -0
- package/marketplace/skills/agent-eval-design/SKILL.md +55 -0
- package/marketplace/skills/ai-native-development/SKILL.md +294 -0
- package/marketplace/skills/api-design/SKILL.md +60 -0
- package/marketplace/skills/architecture-decision-records/SKILL.md +55 -0
- package/marketplace/skills/background-jobs/SKILL.md +265 -0
- package/marketplace/skills/bounded-context-mapping/SKILL.md +55 -0
- package/marketplace/skills/cap-theorem-tradeoffs/SKILL.md +127 -0
- package/marketplace/skills/client-server-boundary/SKILL.md +187 -0
- package/marketplace/skills/code-review/SKILL.md +120 -0
- package/marketplace/skills/color-system-design/SKILL.md +43 -0
- package/marketplace/skills/component-architecture/SKILL.md +126 -0
- package/marketplace/skills/compression/SKILL.md +112 -0
- package/marketplace/skills/conceptual-modeling/SKILL.md +181 -0
- package/marketplace/skills/connection-pooling/SKILL.md +105 -0
- package/marketplace/skills/constraint-awareness/SKILL.md +287 -0
- package/marketplace/skills/content-monitor/SKILL.md +209 -0
- package/marketplace/skills/context-engineering/SKILL.md +320 -0
- package/marketplace/skills/context-graph/SKILL.md +174 -0
- package/marketplace/skills/context-management/SKILL.md +174 -0
- package/marketplace/skills/context-window/SKILL.md +239 -0
- package/marketplace/skills/contract-testing/SKILL.md +120 -0
- package/marketplace/skills/cron-scheduling/SKILL.md +223 -0
- package/marketplace/skills/dark-mode-implementation/SKILL.md +47 -0
- package/marketplace/skills/data-modeling/SKILL.md +59 -0
- package/marketplace/skills/data-modeling-fundamentals/SKILL.md +117 -0
- package/marketplace/skills/database-migration/SKILL.md +429 -0
- package/marketplace/skills/debugging/SKILL.md +67 -0
- package/marketplace/skills/dependency-architecture/SKILL.md +58 -0
- package/marketplace/skills/design-module-composition/SKILL.md +43 -0
- package/marketplace/skills/design-system-architecture/SKILL.md +61 -0
- package/marketplace/skills/design-thinking/SKILL.md +44 -0
- package/marketplace/skills/diagnosis/SKILL.md +296 -0
- package/marketplace/skills/diff-analysis/SKILL.md +188 -0
- package/marketplace/skills/e2e-test-design/SKILL.md +113 -0
- package/marketplace/skills/entity-relationship-modeling/SKILL.md +218 -0
- package/marketplace/skills/epistemic-grounding/SKILL.md +112 -0
- package/marketplace/skills/error-boundary/SKILL.md +235 -0
- package/marketplace/skills/error-tracking/SKILL.md +261 -0
- package/marketplace/skills/eval-driven-development/SKILL.md +147 -0
- package/marketplace/skills/evaluation/SKILL.md +113 -0
- package/marketplace/skills/event-contract-design/SKILL.md +60 -0
- package/marketplace/skills/event-storming/SKILL.md +56 -0
- package/marketplace/skills/form-ux-architecture/SKILL.md +60 -0
- package/marketplace/skills/framework-fit-analysis/SKILL.md +59 -0
- package/marketplace/skills/frontend-architecture/SKILL.md +43 -0
- package/marketplace/skills/generative-ui/SKILL.md +118 -0
- package/marketplace/skills/graph-audit/SKILL.md +81 -0
- package/marketplace/skills/guardrails/SKILL.md +118 -0
- package/marketplace/skills/hooks-patterns/SKILL.md +185 -0
- package/marketplace/skills/http-semantics/SKILL.md +136 -0
- package/marketplace/skills/ideation/SKILL.md +41 -0
- package/marketplace/skills/indexing-strategy/SKILL.md +108 -0
- package/marketplace/skills/information-architecture/SKILL.md +59 -0
- package/marketplace/skills/integration-test-design/SKILL.md +111 -0
- package/marketplace/skills/intent-recognition/SKILL.md +136 -0
- package/marketplace/skills/interaction-feedback/SKILL.md +59 -0
- package/marketplace/skills/interaction-patterns/SKILL.md +59 -0
- package/marketplace/skills/journey-mapping/SKILL.md +41 -0
- package/marketplace/skills/keywords/SKILL.md +213 -0
- package/marketplace/skills/knowledge-modeling/SKILL.md +232 -0
- package/marketplace/skills/layout-composition/SKILL.md +59 -0
- package/marketplace/skills/linguistics/SKILL.md +429 -0
- package/marketplace/skills/lint-overlay/SKILL.md +76 -0
- package/marketplace/skills/mental-models/SKILL.md +126 -0
- package/marketplace/skills/merge-queue/SKILL.md +94 -0
- package/marketplace/skills/methodology/SKILL.md +317 -0
- package/marketplace/skills/microcopy/SKILL.md +232 -0
- package/marketplace/skills/middleware-patterns/SKILL.md +363 -0
- package/marketplace/skills/mobile-responsive-ux/SKILL.md +287 -0
- package/marketplace/skills/mutation-testing/SKILL.md +112 -0
- package/marketplace/skills/naming-conventions/SKILL.md +112 -0
- package/marketplace/skills/observability-modeling/SKILL.md +59 -0
- package/marketplace/skills/ontology-modeling/SKILL.md +67 -0
- package/marketplace/skills/owasp-security/SKILL.md +153 -0
- package/marketplace/skills/pattern-recognition/SKILL.md +472 -0
- package/marketplace/skills/performance-budgets/SKILL.md +185 -0
- package/marketplace/skills/performance-engineering/SKILL.md +58 -0
- package/marketplace/skills/performance-testing/SKILL.md +125 -0
- package/marketplace/skills/printify/SKILL.md +42 -0
- package/marketplace/skills/prioritization/SKILL.md +118 -0
- package/marketplace/skills/problem-framing/SKILL.md +41 -0
- package/marketplace/skills/problem-locating-solving/SKILL.md +203 -0
- package/marketplace/skills/project-knowledge-extraction/SKILL.md +54 -0
- package/marketplace/skills/prompt-craft/SKILL.md +134 -0
- package/marketplace/skills/prompt-injection-defense/SKILL.md +132 -0
- package/marketplace/skills/property-based-testing/SKILL.md +100 -0
- package/marketplace/skills/prototyping/SKILL.md +43 -0
- package/marketplace/skills/query-optimization/SKILL.md +144 -0
- package/marketplace/skills/real-time-updates/SKILL.md +324 -0
- package/marketplace/skills/ref-patterns/SKILL.md +284 -0
- package/marketplace/skills/refactor/SKILL.md +65 -0
- package/marketplace/skills/rendering-models/SKILL.md +142 -0
- package/marketplace/skills/replication-patterns/SKILL.md +110 -0
- package/marketplace/skills/research-synthesis/SKILL.md +41 -0
- package/marketplace/skills/route-handler-design/SKILL.md +347 -0
- package/marketplace/skills/schema-evolution/SKILL.md +140 -0
- package/marketplace/skills/security-fundamentals/SKILL.md +139 -0
- package/marketplace/skills/semantic-center/SKILL.md +194 -0
- package/marketplace/skills/semantic-relations/SKILL.md +250 -0
- package/marketplace/skills/semantics/SKILL.md +366 -0
- package/marketplace/skills/semiotics/SKILL.md +230 -0
- package/marketplace/skills/seo-strategy/SKILL.md +260 -0
- package/marketplace/skills/server-actions-design/SKILL.md +243 -0
- package/marketplace/skills/server-components-design/SKILL.md +190 -0
- package/marketplace/skills/sharding-strategy/SKILL.md +123 -0
- package/marketplace/skills/shopify/SKILL.md +42 -0
- package/marketplace/skills/skill-infrastructure/SKILL.md +320 -0
- package/marketplace/skills/skill-router/SKILL.md +71 -0
- package/marketplace/skills/skill-scaffold/SKILL.md +105 -0
- package/marketplace/skills/snapshot-testing/SKILL.md +120 -0
- package/marketplace/skills/spec-driven-development/SKILL.md +148 -0
- package/marketplace/skills/state-machine-modeling/SKILL.md +56 -0
- package/marketplace/skills/state-management/SKILL.md +134 -0
- package/marketplace/skills/streaming-architecture/SKILL.md +194 -0
- package/marketplace/skills/summarization/SKILL.md +156 -0
- package/marketplace/skills/suspense-patterns/SKILL.md +265 -0
- package/marketplace/skills/system-interface-contracts/SKILL.md +59 -0
- package/marketplace/skills/task-analysis/SKILL.md +201 -0
- package/marketplace/skills/taxonomy-design/SKILL.md +66 -0
- package/marketplace/skills/test-coverage-strategy/SKILL.md +108 -0
- package/marketplace/skills/test-doubles-design/SKILL.md +98 -0
- package/marketplace/skills/test-driven-development/SKILL.md +96 -0
- package/marketplace/skills/testing-strategy/SKILL.md +67 -0
- package/marketplace/skills/theme-system-design/SKILL.md +43 -0
- package/marketplace/skills/tool-call-flow/SKILL.md +229 -0
- package/marketplace/skills/tool-call-strategy/SKILL.md +292 -0
- package/marketplace/skills/transaction-isolation/SKILL.md +98 -0
- package/marketplace/skills/type-safety/SKILL.md +177 -0
- package/marketplace/skills/typography-system/SKILL.md +43 -0
- package/marketplace/skills/usability-testing/SKILL.md +43 -0
- package/marketplace/skills/user-research/SKILL.md +43 -0
- package/marketplace/skills/vercel-composition-patterns/SKILL.md +157 -0
- package/marketplace/skills/version-control/SKILL.md +233 -0
- package/marketplace/skills/visual-design-foundations/SKILL.md +59 -0
- package/marketplace/skills/visual-hierarchy/SKILL.md +43 -0
- package/marketplace/skills/webhook-integration/SKILL.md +331 -0
- package/marketplace/skills/writing-humanizer/SKILL.md +380 -0
- package/package.json +67 -0
- package/schemas/manifest.schema.json +811 -0
- package/schemas/manifest.v2.schema.json +164 -0
- package/schemas/manifest.v3.schema.json +758 -0
- package/schemas/manifest.v4.schema.json +755 -0
- package/schemas/manifest.v5.schema.json +755 -0
- package/schemas/manifest.v6.schema.json +811 -0
- package/schemas/skill.context.jsonld +279 -0
- package/schemas/skill.schema.json +919 -0
- package/schemas/skill.v2.schema.json +201 -0
- package/schemas/skill.v3.schema.json +827 -0
- package/schemas/skill.v4.schema.json +822 -0
- package/schemas/skill.v5.schema.json +830 -0
- package/schemas/skill.v6.schema.json +946 -0
- package/schemas/vocabulary/keywords.json +180 -0
- package/schemas/vocabulary/workspace_tags.json +23 -0
- package/scripts/__tests__/migrate-skill-v2-to-v3.test.js +161 -0
- package/scripts/__tests__/migrate-skill-v3-to-v4.test.js +158 -0
- package/scripts/__tests__/test-export-parser-drift.js +149 -0
- package/scripts/__tests__/test-marketplace-export.js +114 -0
- package/scripts/__tests__/test-router-paths.js +82 -0
- package/scripts/__tests__/test-stability-promotion.js +244 -0
- package/scripts/__tests__/test-v3-1-alias-contract.js +109 -0
- package/scripts/__tests__/test-v3-1-skos-runtime.js +116 -0
- package/scripts/backfill-schema-version.js +198 -0
- package/scripts/build-field-reference.js +160 -0
- package/scripts/build-retrieval-baseline.js +511 -0
- package/scripts/check-markdown-links.js +211 -0
- package/scripts/check-protocol-consistency.js +979 -0
- package/scripts/export-marketplace-skills.js +610 -0
- package/scripts/export-skill.js +374 -0
- package/scripts/generate-manifest.js +787 -0
- package/scripts/lib/alias-contract.js +83 -0
- package/scripts/lib/audit-prompt-builder.js +771 -0
- package/scripts/lib/mock-grader.js +134 -0
- package/scripts/lib/parse-frontmatter.js +429 -0
- package/scripts/lib/roots.js +119 -0
- package/scripts/lint/check-archetype-sections.js +185 -0
- package/scripts/lint/check-category-enum.js +83 -0
- package/scripts/lint/check-routing-eval.js +146 -0
- package/scripts/lint/check-routing-quality.js +211 -0
- package/scripts/lint/check-stability-promotion.js +220 -0
- package/scripts/lint/format-code-frame.js +206 -0
- package/scripts/marketplace-install.js +125 -0
- package/scripts/migrate-category-to-enum.js +169 -0
- package/scripts/migrate-skill-v2-to-v3.js +424 -0
- package/scripts/migrate-skill-v3-to-v4.js +200 -0
- package/scripts/migrate-skill-v5-to-v6.js +304 -0
- package/scripts/restructure-by-category.js +85 -0
- package/scripts/seed-publication-classification.js +282 -0
- package/scripts/skill-audit.js +893 -0
- package/scripts/skill-graph-drift.js +483 -0
- package/scripts/skill-graph-route.js +766 -0
- package/scripts/skill-graph-routing-eval.js +393 -0
- package/scripts/skill-lint.js +1317 -0
- package/scripts/skill-overlap.js +213 -0
- package/scripts/verify-skill-md-export.js +201 -0
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pattern-recognition
|
|
3
|
+
description: "Use when auditing for recurring issues, clustering errors, detecting drift from conventions, or when an agent keeps fixing symptoms instead of root causes. Covers the Observe -> Cluster -> Name -> Codify -> Detect -> Prevent loop, grep-based audits, normalize-then-hash error clustering, board-health patterns, design-token and heading drift, domain-encoding patterns, eval-as-pattern-tests, 5 Whys, pattern lifecycle states, and drift traps. Do NOT use for one-off bug localization without recurrence, or for designing the classification system itself; this skill detects violations of conventions that already exist."
|
|
4
|
+
license: MIT
|
|
5
|
+
compatibility: "Language- and stack-agnostic. The recognition loop, clustering method, eval pipeline, and 5-Whys ladder apply to any codebase; the grep patterns and example detection rules are illustrative — substitute the equivalents of your stack."
|
|
6
|
+
allowed-tools: Read Grep
|
|
7
|
+
metadata:
|
|
8
|
+
metadata: "{\"schema_version\":6,\"version\":\"1.1.0\",\"type\":\"capability\",\"category\":\"foundations\",\"domain\":\"foundations/cognition\",\"scope\":\"portable\",\"owner\":\"skill-graph-maintainer\",\"freshness\":\"2026-05-16\",\"drift_check\":\"{\\\\\\\"last_verified\\\\\\\":\\\\\\\"2026-05-16\\\\\\\"}\",\"eval_artifacts\":\"planned\",\"eval_state\":\"unverified\",\"routing_eval\":\"absent\",\"comprehension_state\":\"present\",\"stability\":\"experimental\",\"keywords\":\"[\\\\\\\"recurring code pattern detection\\\\\\\",\\\\\\\"anti-pattern audit\\\\\\\",\\\\\\\"convention drift detection\\\\\\\",\\\\\\\"error cluster triage\\\\\\\",\\\\\\\"normalize-then-hash error grouping\\\\\\\",\\\\\\\"five-whys root cause ladder\\\\\\\",\\\\\\\"eval as pattern test\\\\\\\",\\\\\\\"heading hierarchy violation\\\\\\\",\\\\\\\"design token drift\\\\\\\",\\\\\\\"null-vs-zero domain encoding\\\\\\\",\\\\\\\"integer encoding for monetary amounts\\\\\\\",\\\\\\\"source-rank trust hierarchy\\\\\\\",\\\\\\\"stale detection rule pruning\\\\\\\",\\\\\\\"migrated convention dual detection\\\\\\\",\\\\\\\"pattern lifecycle states\\\\\\\",\\\\\\\"false-positive exclusion discipline\\\\\\\",\\\\\\\"three-instance threshold codify\\\\\\\",\\\\\\\"symptom loop fix churn\\\\\\\"]\",\"examples\":\"[\\\\\\\"I keep seeing the same null-pointer crash in three different files — what's the systemic fix?\\\\\\\",\\\\\\\"audit this codebase for hardcoded colors instead of design tokens\\\\\\\",\\\\\\\"cluster the errors from this session log into root-cause buckets\\\\\\\",\\\\\\\"I've fixed this bug five times in five different places — how do I codify a detection rule?\\\\\\\",\\\\\\\"the agent keeps treating null and zero as the same thing in financial calculations — flag the pattern class\\\\\\\",\\\\\\\"every PR introduces a new convention violation — what's the lint rule that would prevent it?\\\\\\\",\\\\\\\"the same Linear ticket keeps reappearing under different titles — how do I deduplicate?\\\\\\\"]\",\"anti_examples\":\"[\\\\\\\"review this code for semantic correctness\\\\\\\",\\\\\\\"find where the user-auth helper is defined\\\\\\\",\\\\\\\"design a MECE classification taxonomy for our error catalogue\\\\\\\",\\\\\\\"investigate why this single failing test is breaking\\\\\\\",\\\\\\\"trigger an alert when CPU exceeds 80% for 5 minutes\\\\\\\",\\\\\\\"rewrite this function to be cleaner\\\\\\\"]\",\"relations\":\"{\\\\\\\"boundary\\\\\\\":[{\\\\\\\"skill\\\\\\\":\\\\\\\"debugging\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"debugging fixes one specific bug; pattern-recognition identifies the recurring class behind many bugs and proposes a structural fix that prevents the whole class — same recurring-bug prompt routes to debugging for the immediate fix and to pattern-recognition for the systemic rule\\\\\\\"},{\\\\\\\"skill\\\\\\\":\\\\\\\"code-review\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"code-review judges quality of a specific change at PR scope; pattern-recognition systematically detects recurring structural issues across the entire codebase — same 'recurring violation in PRs' prompt routes to code-review for blocking that PR and to pattern-recognition for adding a lint rule\\\\\\\"}],\\\\\\\"related\\\\\\\":[\\\\\\\"refactor\\\\\\\",\\\\\\\"naming-conventions\\\\\\\",\\\\\\\"lint-overlay\\\\\\\",\\\\\\\"diagnosis\\\\\\\"],\\\\\\\"verify_with\\\\\\\":[\\\\\\\"context-graph\\\\\\\",\\\\\\\"graph-audit\\\\\\\",\\\\\\\"tool-call-strategy\\\\\\\"]}\",\"portability\":\"{\\\\\\\"readiness\\\\\\\":\\\\\\\"scripted\\\\\\\",\\\\\\\"targets\\\\\\\":[\\\\\\\"skill-md\\\\\\\"]}\",\"lifecycle\":\"{\\\\\\\"stale_after_days\\\\\\\":365,\\\\\\\"review_cadence\\\\\\\":\\\\\\\"quarterly\\\\\\\"}\",\"mental_model\":\"|\",\"purpose\":\"|\",\"boundary\":\"|\",\"analogy\":\"Pattern recognition is to a codebase what epidemiology is to a city's public health — a doctor (debugging) treats one patient with one infection; the epidemiologist (this skill) notices that fourteen patients across three hospitals all have the same infection, traces it back to a contaminated water source (root cause), names the outbreak, prescribes a public-health intervention (lint rule, type constraint, architectural fix) that prevents the next thousand cases, and updates the surveillance protocol so the next outbreak is caught at three cases instead of fourteen.\",\"misconception\":\"|\",\"concept\":\"{\\\\\\\"definition\\\\\\\":\\\\\\\"Pattern recognition is the cognitive and methodological discipline of identifying recurring structures across instances — separating signal from noise, naming the structure once detected, and elevating it into durable, transmissible knowledge. Drawing from Gestalt perception (Wertheimer 1923), expert intuition research (Klein 1998, Chase & Simon 1973), and the software-pattern tradition (Alexander 1977, Gamma et al. 1994), it treats pattern as a class noun: a regularity worth naming because it explains many observations through one structure.\\\\\\\",\\\\\\\"mental_model\\\\\\\":\\\\\\\"|\\\\\\\",\\\\\\\"purpose\\\\\\\":\\\\\\\"|\\\\\\\",\\\\\\\"boundary\\\\\\\":\\\\\\\"|\\\\\\\",\\\\\\\"taxonomy\\\\\\\":\\\\\\\"|\\\\\\\",\\\\\\\"analogy\\\\\\\":\\\\\\\"|\\\\\\\",\\\\\\\"misconception\\\\\\\":\\\\\\\"|\\\\\\\"}\",\"skill_graph_source_repo\":\"https://github.com/jacob-balslev/skill-graph\",\"skill_graph_protocol\":\"Skill Metadata Protocol v5\",\"skill_graph_project\":\"Skill Graph\",\"skill_graph_canonical_skill\":\"skills/pattern-recognition/SKILL.md\",\"skill_graph_export_description\":\"shortened for Agent Skills 1024-character description limit; canonical source keeps the full routing contract\",\"skill_graph_canonical_description_length\":\"1041\"}"
|
|
9
|
+
skill_graph_source_repo: "https://github.com/jacob-balslev/skill-graph"
|
|
10
|
+
skill_graph_protocol: Skill Metadata Protocol v4
|
|
11
|
+
skill_graph_project: Skill Graph
|
|
12
|
+
skill_graph_canonical_skill: skills/pattern-recognition/SKILL.md
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# Pattern Recognition
|
|
16
|
+
|
|
17
|
+
## Coverage
|
|
18
|
+
|
|
19
|
+
The methodology for identifying recurring structures across code, errors, board state, design systems, and domain data — then acting on them systematically rather than symptom-by-symptom. Names the six-step recognition loop (Observe → Cluster → Name → Codify → Detect → Prevent) with an optional Refine stage and the discipline at each stage. Catalogues code pattern classes (naming violations, duplication, anti-patterns, convention drift, missing guards, stale patterns) with detection methods and false-positive risks. Specifies the grep-based audit pattern as a six-step sequence (define → scan → count → sample → classify → triage) and the three-pass audit strategy (discovery → refinement → verification). Documents error-pattern clustering via normalize-then-hash extraction with ten error categories and severity-by-frequency triage rules. Names nine board-health patterns (stale in-progress, column overflow, WIP overflow, duplicate suspect, orphan in-progress, etc.) and the structural prevention each implies. Covers design pattern recognition (heading hierarchy contract violations, design token drift, triple-encoding requirement, component boundary violations) and domain-encoding patterns (null-vs-zero distinction, integer encoding for monetary amounts, magnitude-conversion at display boundary, source-rank trust hierarchy). Defines the eval-as-pattern-test pipeline and a 5-Whys ladder for root cause vs symptom analysis. Closes with pattern lifecycle states (Active / Fixed / Stale / Migrated), cross-session pattern persistence, a verification checklist, and six named drift traps (pareidolia, false clustering, stale patterns, over-abstraction, ignoring context, fixing at the wrong level).
|
|
20
|
+
|
|
21
|
+
## Philosophy
|
|
22
|
+
|
|
23
|
+
Agents that operate symptom-by-symptom burn tokens without building leverage. An agent that recognizes patterns can propose systemic fixes, write automated detection rules, and prevent entire classes of bugs from recurring. This skill teaches the methodology — not just what to look for, but how to elevate a single finding into a durable detection and prevention mechanism.
|
|
24
|
+
|
|
25
|
+
The core discipline: **require three instances before codifying a pattern**. One is a bug. Two is a coincidence. Three is a pattern worth naming and automating. In a high-velocity agentic environment, manual review scales poorly — pattern recognition lets agents "see" the codebase as a system of rules rather than a collection of files. The premature codification of a pattern after one or two instances creates false rules that block valid code; the failure to codify after the third instance leaves the team to keep paying the same review cost on every future commit.
|
|
26
|
+
|
|
27
|
+
## 1. The Pattern Recognition Loop
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
Observe → Cluster → Name → Codify → Detect → Prevent
|
|
31
|
+
↓ ↓ ↓ ↓ ↓ ↓
|
|
32
|
+
See it Group Give it Write Automate Make it
|
|
33
|
+
3x+ similar a name a rule checking impossible
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
An optional **Refine** stage closes the loop: monitor the effectiveness of the fix and update the codified rule if false positives emerge or the pattern mutates.
|
|
37
|
+
|
|
38
|
+
### Discipline at each stage
|
|
39
|
+
|
|
40
|
+
- **Observe:** Do not claim a pattern after one instance. One = bug. Two = coincidence. Three = pattern. Premature codification creates false rules that block valid code.
|
|
41
|
+
- **Cluster:** Group similar instances and verify they share a root cause. Similar *symptoms* may have different roots — a null pointer and a type error both cause crashes, but fixing null checking does not fix the type error. Group by symptom first, then verify each member shares a root.
|
|
42
|
+
- **Name:** Give the pattern a name short enough to grep for (3–5 words). A pattern named "bad cost handling" is unsearchable. "null-vs-zero cost confusion" is greppable, discussable, and findable in evals. If you cannot name it concisely, it is too vague to be actionable.
|
|
43
|
+
- **Codify:** Document the pattern in a skill section, a rules file, or a lint rule so it can be searched, discussed, and taught to other agents. Include the detection method (grep pattern, file check, or manual review trigger).
|
|
44
|
+
- **Detect:** Automate detection via eval, lint rule, board-health check, or file watcher. Detection should be on-by-default and produce a signal (warn, fail, or task creation) when the pattern is found — not dependent on human memory.
|
|
45
|
+
- **Prevent:** Restructure the system so the pattern becomes impossible. Examples: a type-system constraint that prevents the null-pointer pattern, a hook that enforces the session-closeout protocol before session end, a lint rule that blocks the pattern from merging, or an architectural change that eliminates the root cause entirely. Structural prevention is the goal when the cost is proportionate; not all patterns reach this stage.
|
|
46
|
+
|
|
47
|
+
## 2. Code Pattern Detection
|
|
48
|
+
|
|
49
|
+
### Pattern classes and detection methods
|
|
50
|
+
|
|
51
|
+
| Pattern class | Examples | Detection method | False-positive risk |
|
|
52
|
+
|--------------|---------|-----------------|-------------------|
|
|
53
|
+
| **Naming violations** | Generic names (`data`, `result`, `temp`, `foo`, `item`), wrong prefix, snake_case in camelCase context | Grep for common bad names; manual review | Low |
|
|
54
|
+
| **Duplication** | Same logic in 3+ places, repeated imports, copy-pasted error handlers and types | Grep for repeated code blocks; tools like `jscpd` | Medium — similar code may be intentional |
|
|
55
|
+
| **Anti-patterns** | String interpolation in SQL, `any` type usage, `console.log` in production, `await` inside `forEach` | Grep for known bad patterns; type-checker strict mode | Low to medium |
|
|
56
|
+
| **Convention drift** | Hardcoded hex instead of design tokens, raw `px` instead of spacing scale, import from wrong path | Grep for raw values and non-standard imports | Medium — intentional deviations exist |
|
|
57
|
+
| **Missing guards** | `DELETE` without `WHERE`, mutation without auth, missing tenant-scope filter, missing null check before `.length` | Grep for unguarded operations; read surrounding context | Medium — guards may be higher in call stack |
|
|
58
|
+
| **Stale patterns** | Old import paths, deprecated API usage, an old prefix that has been renamed, removed abstraction still referenced | Grep for known-deprecated patterns; check git blame | Low |
|
|
59
|
+
|
|
60
|
+
### The grep-based audit pattern
|
|
61
|
+
|
|
62
|
+
For any code pattern, the detection method follows this sequence:
|
|
63
|
+
|
|
64
|
+
1. **Define** the pattern as a regex specific enough to minimize false positives, with scope (which files, which languages).
|
|
65
|
+
2. **Run** the scan with appropriate `include` / `exclude` filters.
|
|
66
|
+
3. **Count** matches first — `output_mode: "count"` or `| wc -l` gives scale before committing to review. >20 matches = significant systemic issue.
|
|
67
|
+
4. **Sample** matches — `output_mode: "content"` with `head_limit: 10` confirms the pattern is real.
|
|
68
|
+
5. **Classify** — true positive (genuine violation) vs false positive (intentional or contextual).
|
|
69
|
+
6. **Triage** — fix trivial matches in one commit, create a tracker issue for architectural fixes, or add a lint rule for prevention.
|
|
70
|
+
7. **Verify prevention** — if you add a lint rule, confirm it catches the pattern in a test commit before shipping.
|
|
71
|
+
|
|
72
|
+
### The 3-pass audit strategy
|
|
73
|
+
|
|
74
|
+
1. **Discovery pass:** broad, case-insensitive grep to find potential candidates.
|
|
75
|
+
2. **Refinement pass:** regex lookaheads/lookbehinds or `-v` exclusions to remove known intentional patterns (vendor code, token files, fixtures).
|
|
76
|
+
3. **Verification pass:** read 3–5 random samples manually to confirm true-positive status before acting on the whole set.
|
|
77
|
+
|
|
78
|
+
### Example: detecting hardcoded colors
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Find hardcoded hex in component styles (excluding token sources)
|
|
82
|
+
grep -rE '#[0-9a-fA-F]{3,8}' src/ \
|
|
83
|
+
--include='*.scss' --include='*.module.scss' \
|
|
84
|
+
| grep -v '_design-tokens.scss' \
|
|
85
|
+
| grep -v '_foundation.scss' \
|
|
86
|
+
| head -20
|
|
87
|
+
|
|
88
|
+
# Each match: file:line → replace with var(--color-*) token from your token-source file
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Example: detecting stale ticket-prefix references
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# After renaming a project's ticket prefix from OLD- to NEW-, any OLD- reference is stale
|
|
95
|
+
grep -rE "OLD-[0-9]+" . --include='*.md' --include='*.ts' --include='*.js'
|
|
96
|
+
# → Replace OLD-XXXX with NEW-XXXX
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Example: detecting unguarded mutations
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# DELETE without WHERE — data-safety violation
|
|
103
|
+
grep -rE 'DELETE FROM' . --include='*.ts' --include='*.sql' | grep -v 'WHERE'
|
|
104
|
+
|
|
105
|
+
# UPDATE without tenant-scope filter — multi-tenant isolation violation (requires manual review)
|
|
106
|
+
grep -rE 'UPDATE.*SET' src/ --include='*.ts' | head -20
|
|
107
|
+
# For each match: verify the tenant-id filter is in the WHERE clause
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### False-positive discipline
|
|
111
|
+
|
|
112
|
+
Not every grep match is a violation. Before filing or fixing:
|
|
113
|
+
|
|
114
|
+
- Check if the match is inside a test fixture (intentional by definition).
|
|
115
|
+
- Check if the match is inside a comment documenting the old pattern (informational, not active).
|
|
116
|
+
- Check if the file is explicitly excluded from the convention (e.g., a token file is allowed to contain hex literals).
|
|
117
|
+
- Check if there is an inline exemption comment (`// @intentional: <reason>`).
|
|
118
|
+
|
|
119
|
+
**Document false-positive exclusion rules in the grep pattern itself, not just in memory.** A rule that only exists in your head will be rediscovered and re-debated by the next agent.
|
|
120
|
+
|
|
121
|
+
## 3. Error Pattern Clustering
|
|
122
|
+
|
|
123
|
+
A deterministic error-extraction phase (no model involved, no hallucination risk) clusters session-log errors into actionable categories.
|
|
124
|
+
|
|
125
|
+
### Error categories and responses
|
|
126
|
+
|
|
127
|
+
| Category | Detection signature | Severity | Auto-response |
|
|
128
|
+
|----------|-------------------|----------|---------------|
|
|
129
|
+
| **Tool failure** | Tool call returned error status ≠ 0 | Medium | Check tool availability, retry with backoff |
|
|
130
|
+
| **Tool loop** | Same tool called 3× with same params | High | Stop, analyze parameters, pivot strategy |
|
|
131
|
+
| **Type error** | `error` contains a type-checker code (e.g., `TS` + number) or "not assignable to type" | Medium | Fix types, check imports, check recent schema changes |
|
|
132
|
+
| **Runtime crash** | `error` contains "Uncaught" or stack trace | High | Debug with stack trace; may indicate missing validation |
|
|
133
|
+
| **Stall / timeout** | No tool output for >5 minutes | High | Check for infinite loop, resource exhaustion, blocked I/O |
|
|
134
|
+
| **Permission denied** | `error` contains "denied", "permission", "forbidden" | Medium | Check hook configuration; verify authorization; adjust scope |
|
|
135
|
+
| **Permission tripwire** | Permission denied on a protected resource (env files, credential files, `.git/`) | High | Do NOT retry; explain the security constraint to the user |
|
|
136
|
+
| **Context exhaustion** | Session ends mid-task or model reports context full | High | Previous session should have run a closeout protocol; check continuation signal; split task |
|
|
137
|
+
| **Configuration error** | `error` about missing env var, bad flag, or invalid config | Medium | Verify environment; check flags and settings; update config |
|
|
138
|
+
| **Ghost context** | Agent references files from a prior session | Medium | Run `ls` to verify existence; update memory |
|
|
139
|
+
|
|
140
|
+
### Clustering method
|
|
141
|
+
|
|
142
|
+
1. **Extract** error messages from the session log (deterministic — no model involved).
|
|
143
|
+
2. **Normalize** each error: strip timestamps, file paths, line numbers, variable names, session IDs.
|
|
144
|
+
3. **Hash** the normalized message to group identical errors into buckets.
|
|
145
|
+
4. **Count** occurrences per hash → frequency is the primary severity signal (5+ = systemic issue).
|
|
146
|
+
5. **Deduplicate** against existing tracker issues via Levenshtein similarity → prevent duplicate tickets for the same error class.
|
|
147
|
+
6. **Classify** each bucket: real pattern vs one-off instance; edge cases require manual review.
|
|
148
|
+
|
|
149
|
+
**Key insight:** normalizing before hashing is what makes clustering work. Two errors that look different because one says `line 47` and the other says `line 52` are the same error. Strip the specifics first.
|
|
150
|
+
|
|
151
|
+
### When clusters point to root causes
|
|
152
|
+
|
|
153
|
+
A cluster of 8 "Cannot read property of undefined" errors normalized to the same code path means there is one missing null guard, not 8 bugs. Fix the guard once; the cluster disappears. If the errors normalize to 3 different code paths, there are 3 root causes — do not collapse them into one ticket.
|
|
154
|
+
|
|
155
|
+
### When to file a tracker issue from an error pattern
|
|
156
|
+
|
|
157
|
+
- **Frequency ≥5 in one session** OR **≥3 across recent sessions** → file a bug task.
|
|
158
|
+
- **Blocking task completion** → file immediately regardless of frequency.
|
|
159
|
+
- **Prevents the agent from proceeding** → escalate to an infrastructure task.
|
|
160
|
+
- **Root cause is addressable** (missing feature, not "agent made a mistake") → prioritize for implementation.
|
|
161
|
+
- If the root cause is agent logic, defer to post-mortem; do not task the infrastructure.
|
|
162
|
+
|
|
163
|
+
## 4. Board-Health Patterns
|
|
164
|
+
|
|
165
|
+
A board-health checker can detect nine board-level patterns. Each implies a process fix, not just an alert.
|
|
166
|
+
|
|
167
|
+
| Pattern | Threshold | Severity | Auto-Fix |
|
|
168
|
+
|---------|-----------|----------|----------|
|
|
169
|
+
| **Stale In Progress** | >3 days no update | Warning | Move to Ready + comment |
|
|
170
|
+
| **Stale Needs Planning** | >14 days | Info | Archive |
|
|
171
|
+
| **Column overflow** | >column limit | Warning | Alert only |
|
|
172
|
+
| **Resolved blocker** | Blocking task is Done (dependency deadlock) | Warning | Comment (clear dependency) |
|
|
173
|
+
| **Priority drift** | P1/P2 in Ready >5 days | Warning | Alert only |
|
|
174
|
+
| **WIP overflow** | >N In Progress per agent | Critical | Alert only |
|
|
175
|
+
| **Missing priority** | No priority set | Info | Alert only |
|
|
176
|
+
| **Duplicate suspect** | >85% title similarity (Levenshtein) | Warning | Alert + link |
|
|
177
|
+
| **Orphan In Progress** | No assignee | Warning | Alert only |
|
|
178
|
+
|
|
179
|
+
### Using patterns for prevention
|
|
180
|
+
|
|
181
|
+
Each pattern implies a structural fix:
|
|
182
|
+
|
|
183
|
+
| Pattern | Prevention |
|
|
184
|
+
|---------|-----------|
|
|
185
|
+
| **Stale In Progress** | Agents must run a session-closeout protocol before ending a session — make it a mandatory hook |
|
|
186
|
+
| **WIP overflow** | The dispatcher must cap concurrent claims per agent; set a hard `WIP_LIMIT` in env |
|
|
187
|
+
| **Duplicate suspect** | Task creators must search the tracker before creating; add a pre-create search gate |
|
|
188
|
+
| **Missing priority** | Task templates must include a required priority field |
|
|
189
|
+
| **Orphan In Progress** | Claiming a task must set the assignee atomically — no claim without assignment |
|
|
190
|
+
| **Priority drift** | High-priority tasks should have clear owners; the dispatcher should prioritize them |
|
|
191
|
+
| **Column overflow** | Process needs a triage gate or WIP limit; adjust column policy |
|
|
192
|
+
|
|
193
|
+
### Pattern interaction: WIP overflow + stale in-progress
|
|
194
|
+
|
|
195
|
+
These two patterns frequently co-occur: WIP overflow happens because agents claim tasks and then stall, creating stale in-progress tasks. The root cause is not "too many tasks claimed" but "tasks are claimed without a completion guarantee." The fix is a closeout protocol that forces resolution (Done or Blocked) before a new task can be claimed.
|
|
196
|
+
|
|
197
|
+
**Triage action, not just reporting:** when a pattern is detected, move stale tasks to Ready, flag duplicates for merge, and ping the owner of dependency deadlocks.
|
|
198
|
+
|
|
199
|
+
## 5. Design Pattern Recognition
|
|
200
|
+
|
|
201
|
+
### Heading hierarchy contract violations
|
|
202
|
+
|
|
203
|
+
A heading hierarchy contract defines (typically) six semantic levels mapped to typography tokens with a strict component → level map. Pattern detection:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
# Components defining their own font-size (violation of the contract)
|
|
207
|
+
grep -r "font-size:" src/ --include='*.module.scss' \
|
|
208
|
+
| grep -v '_foundation.scss' | head -20
|
|
209
|
+
|
|
210
|
+
# Components with hardcoded font-weight (should use heading token)
|
|
211
|
+
grep -r "font-weight:" src/components --include='*.scss' | head -20
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**Rule:** no component may define `font-size`, `font-weight`, or `font-family` for headings. Use the foundation heading tokens or semantic HTML (`<h1>`–`<h6>`) with foundation styles. If a title needs different styling, the heading hierarchy is wrong — fix the hierarchy in the token source, not the component.
|
|
215
|
+
|
|
216
|
+
### Triple-encoding verification
|
|
217
|
+
|
|
218
|
+
Status meaning in any UI should be "triple encoded": **color + icon + text**.
|
|
219
|
+
|
|
220
|
+
- **Violation:** a badge that uses green color but no checkmark icon, or an icon with no accompanying text label.
|
|
221
|
+
- **Detection:** check component props for `icon` and `variant` alignment; run an accessibility audit for color-only signals.
|
|
222
|
+
- **Why:** color-only encoding fails for colorblind users and monochrome rendering.
|
|
223
|
+
|
|
224
|
+
### Design token drift patterns
|
|
225
|
+
|
|
226
|
+
| Pattern | Detection | Rule |
|
|
227
|
+
|---------|-----------|------|
|
|
228
|
+
| Hardcoded colors | `grep -r "color:" --include='*.scss' \| grep -v "var(--"` | Use CSS custom properties from your token source |
|
|
229
|
+
| Raw pixel spacing off-grid | `grep -rE "margin:\|padding:" --include='*.scss' \| grep -E "[0-9]{2,}px"` | Use the spacing scale: 4, 8, 12, 16, 24, 32, ... |
|
|
230
|
+
| Hardcoded hex in component | `grep "#[0-9a-fA-F]" --include='*.module.scss'` | Hex belongs in the token source, not components |
|
|
231
|
+
| Missing dark mode | Check for the `[data-theme="dark"]` variant for each color variable | Every semantic color needs a `.light` and `.dark` variant |
|
|
232
|
+
| Inline styles in JSX | `grep "style={{" --include='*.tsx'` | Use CSS modules or class names |
|
|
233
|
+
|
|
234
|
+
### Component pattern violations — enforcement
|
|
235
|
+
|
|
236
|
+
Document the contract in a design guide and enforce via:
|
|
237
|
+
|
|
238
|
+
- ESLint / Stylelint rules that catch hardcoded values.
|
|
239
|
+
- A design-review checklist for PRs.
|
|
240
|
+
- Evals that test design compliance.
|
|
241
|
+
- A heading-audit script for semantic-hierarchy checks.
|
|
242
|
+
|
|
243
|
+
### Why design-pattern detection is high-leverage
|
|
244
|
+
|
|
245
|
+
A single hardcoded color in one component is a one-line fix. But the same hardcoded color appearing in 15 components means a developer practice is broken — adding a new component will likely introduce color 16. The fix at the root-cause level is: (a) a lint rule that fails CI on hardcoded colors, and (b) a design-review gate before merge. Fixing 15 instances without the lint rule means instance 16 will appear next sprint.
|
|
246
|
+
|
|
247
|
+
## 6. Domain-Encoding Patterns
|
|
248
|
+
|
|
249
|
+
Every domain has encoding conventions that, when misread, produce silent incorrect calculations — the most dangerous class of bug because the output looks valid. Monetary amounts are the classic example, but the same principles apply to any domain primitive (timestamps, percentages, dimensions, weights, currency codes).
|
|
250
|
+
|
|
251
|
+
| Principle | What it means | Common mistake | Consequence |
|
|
252
|
+
|---------|-------------|----------------|-------------|
|
|
253
|
+
| **Null vs zero distinction** | `null` means "we don't know"; `0` means "we know and it's zero" | Treating `null` as `0` | Overstated outcomes (e.g., fake zero cost → fake 100% margin) |
|
|
254
|
+
| **Integer encoding for monetary amounts** | Store amounts as integer minor units (cents, satoshis) to prevent floating-point drift (`0.1 + 0.2 ≠ 0.3`) | Dividing by 100 mid-calculation | Floating-point precision loss accumulating across operations |
|
|
255
|
+
| **Magnitude conversion at the display boundary only** | Conversion from minor units to major units (cents → dollars) happens once, in formatters, never in business logic | Hidden `/100` deep in a calculation chain | Magnitude bugs and precision loss |
|
|
256
|
+
| **Source-rank trust hierarchy** | Each data field has a rank: verified > calculated > estimated > defaulted | Treating estimated/defaulted values as authoritative | Overconfidence in unverified data |
|
|
257
|
+
| **Customer-facing vs internal totals** | Same number can mean two different things depending on perspective (e.g., shipping charged to customer ≠ shipping cost paid to fulfillment) | Confusing the two | Double-counting or sign error |
|
|
258
|
+
| **Division-by-zero guard** | A safe-percent helper returns `null` (or a sentinel) when the denominator is zero, never `NaN` or accidentally `0%` | Displaying `NaN` or silently returning `0%` | Misleading analytics |
|
|
259
|
+
|
|
260
|
+
### Domain-encoding pattern detection
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
# Premature minor → major conversion (may lose precision mid-chain)
|
|
264
|
+
grep -r "/ 100" src/ --include='*.ts' \
|
|
265
|
+
| grep -E 'cents|price|cost|total'
|
|
266
|
+
|
|
267
|
+
# Confusion between zero and null in domain fields
|
|
268
|
+
grep -r "amountCents === 0" src/ --include='*.ts' | head -10
|
|
269
|
+
# → verify the logic correctly distinguishes "unknown" from "zero"
|
|
270
|
+
|
|
271
|
+
# toFixed on minor units (wrong magnitude)
|
|
272
|
+
grep -r "toFixed" src/ --include='*.ts' | grep -v '/ 100'
|
|
273
|
+
|
|
274
|
+
# Missing minor → major formatting at the UI boundary
|
|
275
|
+
grep -rE "\{.*_cents\}" src/components/ | grep -v 'formatMoney'
|
|
276
|
+
|
|
277
|
+
# Unguarded division that could NaN
|
|
278
|
+
grep -r "safe-percent\|safeRatio\|safeDiv" src/ --include='*.ts' | wc -l
|
|
279
|
+
# → if the count is low, there may be unsafe divisions elsewhere
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### The null-vs-zero trap
|
|
283
|
+
|
|
284
|
+
This is a high-frequency domain-encoding pattern violation in any codebase that handles partial data. The invariant: `null` means "we don't know," `0` means "we know and it's zero." Code that treats them identically will either:
|
|
285
|
+
|
|
286
|
+
- Report a successful outcome when it is actually unknown (null cost → fake zero cost → fake 100% margin).
|
|
287
|
+
- Hide genuine zero-value cases as unknowns.
|
|
288
|
+
|
|
289
|
+
Always write explicit checks:
|
|
290
|
+
|
|
291
|
+
```ts
|
|
292
|
+
if (amountCents === null) return null; // unknown, not zero
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
The lesson generalizes beyond money: a `lastSeenAt` of `null` ≠ "seen at epoch zero"; an unknown shipping weight ≠ a zero-weight package; a missing `assignedTo` ≠ "assigned to no one on purpose." Build the null-vs-zero distinction into the type system at the boundary, and propagate it through the calculation chain.
|
|
296
|
+
|
|
297
|
+
## 7. The Eval-as-Pattern-Test Approach
|
|
298
|
+
|
|
299
|
+
Every recognized pattern should become a testable eval. This is how patterns survive beyond the session that discovered them — agents in future sessions can verify they detect the pattern reliably under new inputs.
|
|
300
|
+
|
|
301
|
+
```json
|
|
302
|
+
{
|
|
303
|
+
"id": 1,
|
|
304
|
+
"name": "heading-hierarchy-violation-detection",
|
|
305
|
+
"prompt": "Review this SCSS for design token compliance:\n.chart-title { font-size: 16px; color: #333; font-weight: 600; }",
|
|
306
|
+
"expected_output": "Identifies #333 and font-size: 16px as token violations",
|
|
307
|
+
"expectations": [
|
|
308
|
+
"Flags #333 as hardcoded color — should use a color token",
|
|
309
|
+
"Flags font-size: 16px as raw value — should use a heading token or semantic <h3>",
|
|
310
|
+
"Does NOT flag font-weight: 600 if it matches the heading-h3 spec",
|
|
311
|
+
"Does NOT flag colors inside the token source files"
|
|
312
|
+
],
|
|
313
|
+
"model": "any frontier model"
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### Pattern → eval pipeline
|
|
318
|
+
|
|
319
|
+
1. **Detect** the pattern manually in a session (this document, codebase scan, or error clustering).
|
|
320
|
+
2. **Write** a skill section documenting the pattern, detection method, and fix.
|
|
321
|
+
3. **Capture** the offending code snippet to `evals/fixtures/`.
|
|
322
|
+
4. **Create** an eval in `evals/patterns.json` that tests detection with known inputs and expected outputs.
|
|
323
|
+
5. **Run** the eval to verify agents can detect it reliably in zero-shot review.
|
|
324
|
+
6. **Automate** detection in CI (lint rule, grep gate, or board-health check).
|
|
325
|
+
7. **Verify** the automated check catches the pattern in a test commit before shipping.
|
|
326
|
+
8. **Document** the pattern in the relevant canonical doc (design guide, security policy, data-handling spec).
|
|
327
|
+
|
|
328
|
+
### Why the eval step is non-optional
|
|
329
|
+
|
|
330
|
+
A skill section documents a pattern for human readers. An eval tests whether an agent can apply the pattern reliably under new inputs. Without the eval, a skill section about "null-vs-zero confusion" may be read and then misapplied on the next input — the agent learned the name but not the detection logic. The eval closes that gap.
|
|
331
|
+
|
|
332
|
+
## 8. Root Cause vs Symptom Recognition
|
|
333
|
+
|
|
334
|
+
Agents that fix symptoms create the illusion of progress while the root cause generates new instances. Pattern recognition locates the level at which a fix propagates to all instances.
|
|
335
|
+
|
|
336
|
+
| Symptom | Root cause pattern | Symptom fix | Root cause fix |
|
|
337
|
+
|---------|-------------------|-------------|----------------|
|
|
338
|
+
| Function crashes on null input | Missing null guard on parameter | Add null check | Non-null type narrowing at the boundary |
|
|
339
|
+
| Same bug in 3 files | Duplicated logic across files | Fix each file | Extract shared utility; replace callsites |
|
|
340
|
+
| Hardcoded hex colors everywhere | No design token available or lint rule | Replace hex one by one | Add token to the token source + CI lint rule |
|
|
341
|
+
| Users report "permission denied" weekly | Missing tenant-scope filter in query `WHERE` | Fix the query | Enforce a tenant-scope rule at the query layer; use a scoped-query helper |
|
|
342
|
+
| Tasks go stale in In Progress | Agents don't run the session-closeout protocol | Manually move tasks | A session-end hook enforces closeout |
|
|
343
|
+
| Type errors on every merge | Missing integration test | Fix case-by-case | Add cross-module type test in CI |
|
|
344
|
+
| Same design violation in every PR | No automated check | Review PRs manually | ESLint / Stylelint rule + design-review eval |
|
|
345
|
+
| Numeric display shows NaN | Safe-percent helper not used at display | Add `\|\| 0` at callsite | Enforce the safe-percent wrapper at all display boundaries via lint |
|
|
346
|
+
|
|
347
|
+
### The 5-Whys for agents
|
|
348
|
+
|
|
349
|
+
Work down to the level where a fix prevents all future instances, not just the current one.
|
|
350
|
+
|
|
351
|
+
**Example: repeated null-check bug**
|
|
352
|
+
|
|
353
|
+
1. **Why** does this calculation crash? → `amountCents` is null, no guard exists.
|
|
354
|
+
2. **Why** is the guard missing? → The function assumes the amount is always recorded.
|
|
355
|
+
3. **Why** does it assume that? → No type constraint enforces nullable amounts.
|
|
356
|
+
4. **Why** no type constraint? → The function accepts `number` instead of `number | null`.
|
|
357
|
+
5. **Why** the wrong type? → The type was copied from an older schema before the field became nullable.
|
|
358
|
+
|
|
359
|
+
**Fix at level 5:** update the type signature to `amountCents: number | null`, add a comment explaining the null semantics, run type-check across all callers. This prevents the bug for all future callers, not just the one that crashed today.
|
|
360
|
+
|
|
361
|
+
Fixing at level 1 (add `|| 0`) silently converts "unknown" to "zero assumed" — the wrong fix that creates a new category of silent error. Always aim for level 4–5 when possible. Levels 1–2 are debugging; levels 4–5 are process improvement.
|
|
362
|
+
|
|
363
|
+
## 9. Pattern Lifecycle Management
|
|
364
|
+
|
|
365
|
+
Patterns are not permanent truths. They require maintenance.
|
|
366
|
+
|
|
367
|
+
### Pattern states
|
|
368
|
+
|
|
369
|
+
| State | Meaning | Action |
|
|
370
|
+
|-------|---------|--------|
|
|
371
|
+
| **Active** | Still occurring; detection rule running | Enforce, measure frequency |
|
|
372
|
+
| **Fixed** | Root cause resolved; new instances impossible | Verify with grep; archive if clean |
|
|
373
|
+
| **Stale** | Pattern was fixed but detection rule still runs | Prune detection rule; note in skill |
|
|
374
|
+
| **Migrated** | Pattern replaced by a different convention | Update detection to flag old AND new violations |
|
|
375
|
+
|
|
376
|
+
### Pruning stale detection rules
|
|
377
|
+
|
|
378
|
+
A detection rule for a pattern that no longer exists creates false positives and alert fatigue. After a root-cause fix ships:
|
|
379
|
+
|
|
380
|
+
1. Run the grep / lint rule: if zero matches, the pattern is gone.
|
|
381
|
+
2. Archive the detection rule with a note: "Fixed in commit XXXXXXXX — null-vs-zero domain-value type was corrected."
|
|
382
|
+
3. Keep the skill section (documents WHY the fix was needed) but mark detection as `[archived]`.
|
|
383
|
+
|
|
384
|
+
### Migrated patterns require dual detection
|
|
385
|
+
|
|
386
|
+
When a convention changes (e.g., the ticket prefix is renamed from `OLD-` to `NEW-`), the detection rule must flag:
|
|
387
|
+
|
|
388
|
+
- **Old pattern:** still-existing `OLD-` references (violations to fix).
|
|
389
|
+
- **New pattern:** any new `OLD-` references introduced after migration (regressions to prevent).
|
|
390
|
+
|
|
391
|
+
A single grep covers both: `OLD-[0-9]+` catches all instances regardless of when they were written.
|
|
392
|
+
|
|
393
|
+
### Detection decay
|
|
394
|
+
|
|
395
|
+
A detection rule added today may not catch future variants of the same pattern. Periodically verify that your detection rules still catch the pattern *class*, not just the specific instances you fixed. Rules age; patterns mutate.
|
|
396
|
+
|
|
397
|
+
## 10. Cross-Session Pattern Persistence
|
|
398
|
+
|
|
399
|
+
Patterns span multiple sessions. Track them so discovery is not repeated:
|
|
400
|
+
|
|
401
|
+
- **Memory file:** save significant patterns to a file like `memory/pattern-<name>.md` with detection method and prevention status.
|
|
402
|
+
- **Tracker tasks:** file bugs for high-frequency patterns; link tasks to the pattern for traceability.
|
|
403
|
+
- **Lint / eval:** add automated checks so future agents detect the pattern without rediscovery.
|
|
404
|
+
- **Canonical docs:** update the design guide, security policy, or data-handling spec to document the pattern and its rule.
|
|
405
|
+
|
|
406
|
+
If you detect a pattern that was supposedly fixed, investigate:
|
|
407
|
+
|
|
408
|
+
- Is the fix incomplete? (Some instances still exist.)
|
|
409
|
+
- Did a new instance slip through the detection rule? (Rule is incomplete.)
|
|
410
|
+
- Was the prevention mechanism removed? (Regression in process or codebase.)
|
|
411
|
+
|
|
412
|
+
## Verification
|
|
413
|
+
|
|
414
|
+
Before codifying a pattern, confirm:
|
|
415
|
+
|
|
416
|
+
- [ ] **Observed at least 3 times?** One is a bug, two is a coincidence. Three is a pattern.
|
|
417
|
+
- [ ] **Same root cause across instances?** Similar symptoms ≠ pattern if roots differ.
|
|
418
|
+
- [ ] **Can name it in 3–5 words?** "Hardcoded color instead of token" ✓ vs "design issue" ✗.
|
|
419
|
+
- [ ] **Can write a detection rule?** A grep pattern, lint rule, or board-health check exists or can be added.
|
|
420
|
+
- [ ] **Root cause identified, not just symptom?** 5-Whys applied; the fix prevents recurrence.
|
|
421
|
+
- [ ] **Pattern documented?** Skill section, rules file, design rule, or security/data-handling policy doc.
|
|
422
|
+
- [ ] **False-positive exclusions documented?** Test files, token files, legacy-exempt areas — inline in the grep pattern.
|
|
423
|
+
- [ ] **Detection automated?** Lint runs on CI, eval runs on pilot, or check is in the board-health pipeline.
|
|
424
|
+
- [ ] **Eval created for high-frequency patterns?** Agents verify detection under new inputs.
|
|
425
|
+
- [ ] **Prevention possible?** Architecture change, type-system guard, or process hook can make the pattern impossible.
|
|
426
|
+
- [ ] **Checked the inverse?** Places where the pattern *should* be applied but isn't (e.g., guards missing at new callsites).
|
|
427
|
+
|
|
428
|
+
## Drift Traps
|
|
429
|
+
|
|
430
|
+
1. **Pattern inflation (pareidolia)** — Not everything is a pattern. Require 3+ instances before codifying. A single bug is a bug; calling it a pattern adds false urgency and misleads future agents. Seeing patterns where only random noise exists wastes effort.
|
|
431
|
+
|
|
432
|
+
2. **False clustering** — Similar symptoms often have different root causes. A cluster of "null reference" errors may have 3 different call sites with 3 different missing guards. Verify each cluster member shares a root before proposing a unified fix.
|
|
433
|
+
|
|
434
|
+
3. **Stale patterns** — Patterns that were fixed but whose detection rules remain. A grep that always returns zero matches is noise and creates alert fatigue. Prune periodically; see §9.
|
|
435
|
+
|
|
436
|
+
4. **Over-abstraction** — Creating a framework or lint plugin to detect one pattern. Detection should be proportional to frequency. One pattern = grep rule. Three patterns = lint plugin. A complex wrapper that is harder to maintain than the duplication itself is its own anti-pattern.
|
|
437
|
+
|
|
438
|
+
5. **Ignoring context** — A pattern in test code may be intentional by design (e.g., testing null handling, hardcoded fixture values). A pattern in a token source file is by definition the source of truth. A pattern in a config file may be valid (comments that look like code). Context determines whether a match is a violation.
|
|
439
|
+
|
|
440
|
+
6. **Fixing at the wrong level (symptom loop)** — See §8. Fixing symptoms without the 5-Whys produces fix churn. Measure whether the cluster shrinks after the fix; if not, you fixed a symptom. Repeatedly addressing the 1st Why without ever reaching the 5th Why is the most expensive form of pattern work.
|
|
441
|
+
|
|
442
|
+
### When NOT to declare a pattern
|
|
443
|
+
|
|
444
|
+
- **Single instance** — fix the bug; do not create a framework for it.
|
|
445
|
+
- **Legitimate deviation** — some code intentionally violates a rule. Document the reason inline (e.g., `// @intentional: dynamic SQL interpolation required because...`).
|
|
446
|
+
- **Tool limitation** — if you cannot write a detection rule because the tool is limited, either fix the tool or document the limitation.
|
|
447
|
+
- **Unclear root cause** — if you see similar symptoms but cannot determine a shared root cause, classify as "investigate further" not "pattern found".
|
|
448
|
+
|
|
449
|
+
## Do NOT Use When
|
|
450
|
+
|
|
451
|
+
| Instead, use | Why |
|
|
452
|
+
|---|---|
|
|
453
|
+
| `code-review` | Reviewing a specific PR for semantic logic and quality. Code-review owns the per-change judgment; pattern-recognition owns the cross-codebase recurrence analysis. |
|
|
454
|
+
| `debugging` | Fixing one specific failing case — single-instance bug localization and resolution. Debugging owns the immediate fix; pattern-recognition owns the systemic rule that prevents the class from recurring. |
|
|
455
|
+
| `diagnosis` | Triaging an unknown software failure into a problem class before debugging begins. Diagnosis owns the per-incident triage; pattern-recognition owns the cross-incident class analysis. |
|
|
456
|
+
| `refactor` | Restructuring code once a pattern is identified. Refactor enacts the change; pattern-recognition decides what needs changing. |
|
|
457
|
+
| `naming-conventions` | Establishing or auditing the naming rules themselves. Naming-conventions owns the rules; pattern-recognition detects violations of those rules. |
|
|
458
|
+
| `lint-overlay` | Adding the lint rule that automates pattern detection. Lint-overlay owns the rule machinery; pattern-recognition decides which patterns warrant a rule. |
|
|
459
|
+
| `graph-audit` | Performing dependency and structural audits across the codebase graph. Graph-audit owns the structural perspective; pattern-recognition owns the recurring-violation perspective. |
|
|
460
|
+
| `tool-call-strategy` | Deciding which tool (Grep / Glob / Read) to reach for during a scan. Tool-call-strategy owns the tool selection; pattern-recognition owns the analysis of what the tools find. |
|
|
461
|
+
|
|
462
|
+
## Key Sources
|
|
463
|
+
|
|
464
|
+
- Alexander, C., Ishikawa, S., & Silverstein, M. (1977). *A Pattern Language: Towns, Buildings, Construction*. Oxford University Press. The original use of "pattern" as a term of art in design; 253 patterns connecting urban planning to room layout. The framing — *context + problem + solution + relations to other patterns* — became the template every later pattern catalogue adopted.
|
|
465
|
+
- Gamma, E., Helm, R., Johnson, R., & Vlissides, J. (1994). *Design Patterns: Elements of Reusable Object-Oriented Software*. Addison-Wesley. The "Gang of Four" catalogue: 23 patterns in creational, structural, and behavioral categories. Established the discipline of pattern documentation in software.
|
|
466
|
+
- Klein, G. (1998). *Sources of Power: How People Make Decisions*. MIT Press. The recognition-primed decision model: expert decision-making as pattern recognition against a learned library of cases. Empirical evidence from firefighters, NICU nurses, and military commanders.
|
|
467
|
+
- Chase, W. G., & Simon, H. A. (1973). "Perception in Chess." *Cognitive Psychology*, 4(1), 55-81. The foundational chunking study: chess masters perceive board positions as small numbers of meaningful patterns; novices see individual pieces. The mechanism behind all expertise.
|
|
468
|
+
- Miller, G. A. (1956). "The Magical Number Seven, Plus or Minus Two." *Psychological Review*, 63(2), 81-97. The original chunking paper; working-memory limits and the role of pattern recognition in expanding effective capacity.
|
|
469
|
+
- Fowler, M. (2002). *Patterns of Enterprise Application Architecture*. Addison-Wesley. Software patterns at the application-architecture level; complements the Gang of Four with patterns for data access, web presentation, and distributed concerns.
|
|
470
|
+
- Hohpe, G., & Woolf, B. (2003). *Enterprise Integration Patterns*. Addison-Wesley. Messaging patterns: routing, transformation, endpoints. Demonstrates how the pattern method extends beyond OO design to distributed-systems concerns.
|
|
471
|
+
- Wertheimer, M. (1923). "Untersuchungen zur Lehre von der Gestalt II." *Psychologische Forschung*, 4. The Gestalt principles (proximity, similarity, continuity, closure); the perceptual mechanisms that make pattern recognition possible at the visual level.
|
|
472
|
+
- Brown, W. J., Malveau, R. C., McCormick, H. W., & Mowbray, T. J. (1998). *AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis*. Wiley. The complementary anti-pattern catalogue; recurring solutions that predictably fail.
|