一键导入
yagni
YAGNI/KISS enforcement with structured nudges. Use when discussing code complexity, over-engineering concerns, or to understand a yagni nudge.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
YAGNI/KISS enforcement with structured nudges. Use when discussing code complexity, over-engineering concerns, or to understand a yagni nudge.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Multi-agent consensus code review with adaptive budgets, complexity-aware agent selection, multiple consensus protocols (Approval/Veto, AAD, CI, Supermajority), cross-agent coverage tracking, context-folding isolation, and progressive summarization. Use when reviewing PRs, directories, or code changes.
Use when creating new repositories, reviewing existing repos for compliance, or enforcing repository naming, structure, documentation, and security standards. Applies to all fyrsmithlabs projects.
Use when releasing a new version of a fyrsmithlabs plugin. Automates version bumping across all manifests (plugin.json, marketplace.json, CLAUDE.md), validates counts match disk, runs plugin-validator, creates git tag and GitHub release. Say "release the plugin", "bump version", "create a release".
This skill should be used when the user asks to "test opa", "opa test", "test rego", "write rego tests", "policy coverage", "conftest verify", "mock opa", or mentions `_test.rego` files. Provides OPA testing framework guidance including unit tests, mocking, coverage, and Conftest patterns.
This skill should be used when the user asks about "opa cli", "opa eval", "opa build", "opa check", "opa fmt", "regal lint", "opa bundle", "opa bench", "opa run", or mentions OPA tooling, CI/CD pipeline integration for OPA, or Rego linting. Provides OPA CLI and ecosystem tooling reference.
This skill should be used when the user asks about "kubernetes policy", "gatekeeper", "constraint template", "terraform policy", "conftest", "terraform compliance", "docker policy", "dockerfile policy", "envoy authz", "envoy authorization", "service mesh policy", "cloud policy", "aws policy rego", "azure policy rego", "gcp policy rego", or mentions writing OPA policies for a specific platform. Provides platform-specific Rego patterns and input schemas.
| name | yagni |
| description | YAGNI/KISS enforcement with structured nudges. Use when discussing code complexity, over-engineering concerns, or to understand a yagni nudge. |
Enforces YAGNI (You Aren't Gonna Need It) and KISS (Keep It Simple, Stupid) principles through structured, non-blocking nudges with severity scoring and real-time detection.
| Command | Purpose |
|---|---|
/yagni | Show status and recent nudges |
/yagni config | Adjust sensitivity |
/yagni why | Explain the last nudge |
/yagni off | Disable for session |
/yagni on | Re-enable for session |
/yagni status | Show session stats, patterns, snoozed items |
/yagni principles | Review YAGNI/KISS guidelines |
/yagni whitelist <pattern> | Add pattern to project allowlist |
/yagni dashboard | Show technical debt summary |
| Pattern | Trigger | Severity Weight |
|---|---|---|
abstraction | Filename: Factory, Manager, Provider, Handler, Helper, Utils, Base, Abstract, Wrapper, Builder, Coordinator, Orchestrator | 2 |
config-addiction | Feature flag/env var for single-use behavior | 2 |
scope-creep | Task touches 5+ files beyond original scope | 3 |
dead-code | 10+ commented lines, unused imports | 1 |
speculative-generality | Interface with single implementation | 2 |
swiss-army-knife | Plugin system for single implementation | 3 |
premature-optimization | Caching/memoization before profiling | 2 |
file-explosion | 5+ new files in single session | 2 |
| Metric | Threshold | Description |
|---|---|---|
| Cyclomatic Complexity | >10 per function | Control flow paths indicating testability issues |
| Cognitive Complexity | >15 per function | Mental effort to understand code |
| Nesting Depth | >4 levels | Deep nesting indicates extraction opportunity |
| Parameter Count | >5 parameters | Function doing too much |
| File Length | >300 lines | File may need splitting |
| Method Count | >20 per class | Class has too many responsibilities |
| Smell | Indicator | Nudge |
|---|---|---|
| God Object | Class with 10+ dependencies | Split responsibilities |
| Feature Envy | Method uses other class more than own | Move method |
| Data Clump | Same 3+ params passed together | Extract to object |
| Primitive Obsession | Using primitives instead of small objects | Create value object |
| Long Method | Method >20 lines | Extract sub-methods |
| Shotgun Surgery | Change requires touching 5+ files | Consolidate logic |
Patterns have appropriate vs. premature contexts:
| Pattern | Appropriate When | Premature When |
|---|---|---|
| Factory | 3+ concrete types, runtime selection | Single implementation |
| Strategy | Behavior varies at runtime | Single algorithm |
| Observer | Many-to-many relationships | Single subscriber |
| Decorator | Combinations of behaviors | Single wrapper |
| Singleton | Truly global state (rare) | Convenience access |
| Repository | Multiple data sources, complex queries | Simple CRUD |
| Mediator | Complex object interactions | 2 components |
| Command | Undo/redo, queuing | Simple function call |
Each violation receives a weighted severity score:
Severity = BaseWeight × ImpactMultiplier × FrequencyFactor
Where:
- BaseWeight: Pattern weight (1-3)
- ImpactMultiplier: Scope of impact (1.0-2.0)
- FrequencyFactor: How often this pattern recurs (1.0-1.5)
| Scope | Multiplier | Description |
|---|---|---|
| Local | 1.0 | Single function/component |
| Module | 1.3 | Affects multiple files in module |
| Cross-cutting | 1.5 | Spans multiple modules |
| Architectural | 2.0 | System-wide implications |
| Total Score | Level | Action |
|---|---|---|
| 1-3 | Low | Informational nudge |
| 4-6 | Medium | Warning nudge, suggest simpler path |
| 7-9 | High | Strong nudge, provide refactoring guidance |
| 10+ | Critical | Escalate to code review, flag technical debt |
Estimate refactoring cost in time:
| Severity | Estimated Effort | Debt Category |
|---|---|---|
| Low | 15-30 minutes | Cleanup |
| Medium | 1-2 hours | Minor refactor |
| High | 4-8 hours | Significant refactor |
| Critical | 1-3 days | Architectural change |
┌─ YAGNI: [pattern] ─────────────────────────────────────
│ Severity: [Low|Medium|High|Critical] (score: N)
│
│ Trigger: [what triggered]
│ Concern: [why it matters]
│ Simpler: [alternative approach]
│
│ Debt Estimate: ~[time] to refactor later
│ Related: complexity-assessment score if available
│
└─ [Dismiss] [Snooze 1h] [Whitelist] [/yagni why]
YAGNI [pattern]: [one-line concern] → [Dismiss]
Nudges are suggestions, not blocks:
| Level | Description | Use Case |
|---|---|---|
| strict | Fire on any pattern match | Learning projects, code reviews |
| standard | Balanced detection (default) | Normal development |
| relaxed | Only fire on high-severity patterns | Rapid prototyping, time-boxed work |
/yagni on # Enable detection (default)
/yagni off # Disable for session
/yagni status # Show current state
State persists for session only.
Global default: enabled at standard sensitivity.
Create .claude/yagni.local.md:
---
# Sensitivity: strict | standard | relaxed
sensitivity: standard
# Patterns to always allow (legitimate uses)
whitelist:
- "*Factory*" # DI framework requirement
- "*Repository*" # Project architecture standard
- "Abstract*" # Base classes for plugin system
# Patterns to always flag (project-specific concerns)
escalate:
- "*Manager*" # Team prefers explicit naming
- "*Helper*" # Discouraged in this codebase
# Complexity thresholds (override defaults)
thresholds:
cyclomatic_complexity: 15 # Allow higher for legacy code
cognitive_complexity: 20
file_length: 500 # Larger files acceptable
# Ignore paths (auto-generated, vendor code)
ignore:
- "**/generated/**"
- "**/vendor/**"
- "**/*.g.dart"
---
Add legitimate patterns interactively:
/yagni whitelist "*Factory*"
> Added *Factory* to .claude/yagni.local.md whitelist
> Reason required: [DI framework requirement]
YAGNI detection fires via PreToolUse hooks on Write and Edit operations:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "prompt",
"prompt": "Analyze the file being written/edited for YAGNI violations:\n\n1. Check filename against abstraction patterns\n2. Assess complexity metrics if code is substantial\n3. Look for code smells (god object, feature envy, etc.)\n4. Check against project whitelist in .claude/yagni.local.md\n\nIf violation detected and not whitelisted:\n- Calculate severity score\n- Format structured nudge\n- ALLOW with nudge (non-blocking)\n\nIf no violation or whitelisted: ALLOW silently."
}
]
}
]
}
}
.claude/yagni.local.md before firingOptional pre-commit integration for CI:
# In .husky/pre-commit or similar
# Summarize session YAGNI violations
claude --skill yagni --action summary --format json
YAGNI integrates with the complexity-assessment skill for comprehensive analysis.
complexity-assessment yagni
│ │
├─ Scope score ──────────────┤
│ │
├─ Risk score ───────────────┤ → Severity multiplier
│ │
└─ Tier (SIMPLE/STANDARD/ │
COMPLEX) ─────────────────┘ → Sensitivity adjustment
| Complexity Tier | YAGNI Sensitivity |
|---|---|
| SIMPLE | Standard (quick tasks shouldn't over-engineer) |
| STANDARD | Standard |
| COMPLEX | Relaxed (architectural decisions may require patterns) |
When severity is High or Critical, link to examples:
┌─ YAGNI: abstraction ──────────────────────────────────
│ ...
│ Refactoring Guide: skills/yagni/examples/simpler-paths.md#abstraction-creep
└─────────────────────────────────────────────────────────
When contextd MCP is available, YAGNI learns from project history.
mcp__contextd__memory_record(
project_id: "<project>",
title: "YAGNI: <pattern> in <filename>",
content: "Pattern: <pattern>. Severity: <score>. Trigger: <trigger>.
Dismissed: <yes/no>. Reason: <user reason if dismissed>.",
outcome: "<dismissed|addressed|ignored>",
tags: ["yagni", "<pattern>", "<severity-level>"]
)
# When user marks nudge as false positive
mcp__contextd__memory_record(
project_id: "<project>",
title: "YAGNI False Positive: <pattern>",
content: "Pattern <pattern> on <filename> was false positive.
User reason: <reason>. Consider adding to whitelist.",
outcome: "false-positive",
tags: ["yagni", "false-positive", "<pattern>"]
)
Query past violations to improve detection:
# Before firing nudge, check history
mcp__contextd__memory_search(
project_id: "<project>",
query: "yagni false-positive <pattern>",
limit: 5
)
# If pattern has high false-positive rate for this project,
# auto-suggest adding to whitelist
At session end (or on /yagni dashboard):
YAGNI Session Summary
├─ Violations detected: 7
├─ Dismissed: 3 (reasons recorded)
├─ Addressed: 2
├─ Ignored: 2
├─ False positives: 1 (whitelist suggested)
├─ Total debt estimate: ~4 hours
└─ Patterns: abstraction (3), scope-creep (2), config-addiction (2)
Trend: abstraction violations up 20% from last 5 sessions
View with /yagni dashboard:
┌─ Technical Debt Dashboard ──────────────────────────────
│
│ Current Session
│ ├─ Active violations: 3
│ ├─ Estimated debt: ~2.5 hours
│ └─ Highest severity: Medium (score 5)
│
│ Project History (last 30 days)
│ ├─ Total violations: 47
│ ├─ Addressed: 31 (66%)
│ ├─ Accumulated debt: ~18 hours
│ └─ Top patterns: abstraction (18), scope-creep (12)
│
│ Recommendations
│ ├─ Consider whitelisting: *Repository* (8 false positives)
│ ├─ Escalate for review: payment-service.ts (Critical)
│ └─ Schedule debt paydown: ~4 hours/week to stay current
│
└─────────────────────────────────────────────────────────
.claude/yagni.local.md)Full configuration example:
---
# Core settings
sensitivity: standard # strict | standard | relaxed
enabled: true # Master toggle
# Pattern configuration
whitelist:
- "*Factory*" # Legitimate DI framework
- "*Repository*" # Project standard
escalate:
- "*Manager*" # Discouraged naming
# Threshold overrides
thresholds:
cyclomatic_complexity: 15
cognitive_complexity: 20
nesting_depth: 5
parameter_count: 6
file_length: 400
method_count: 25
# Ignore paths
ignore:
- "**/generated/**"
- "**/vendor/**"
- "**/migrations/**"
- "**/*.generated.*"
# contextd integration
contextd:
record_violations: true
track_false_positives: true
learn_patterns: true
---
| Integration | Purpose |
|---|---|
complexity-assessment | Severity multipliers, tier-based sensitivity |
contextd | Violation history, false positive tracking, pattern learning |
git-workflows | Pre-commit summaries, PR debt reports |
brainstorm | Early YAGNI check during design phase |
| Hooks | Real-time detection on Write/Edit |
| Issue | Solution |
|---|---|
| Too many nudges | Lower sensitivity to relaxed or add patterns to whitelist |
| Missing violations | Raise sensitivity to strict |
| False positives | Use /yagni whitelist <pattern> with reason |
| Nudges not firing | Check /yagni status, ensure not disabled |
| contextd not recording | Verify MCP server is running |