Pattern

From arbazkhan971/godmode · View interactive version

Pattern is an AI agent skill from the GitHub repository arbazkhan971/godmode. Design pattern recommendation and anti-pattern detection.

How to use this skill

Skill file

Activate When

Workflow

1. Problem Analysis

find src/ -name "*.ts" | xargs wc -l \
  | sort -rn | head -20
npx madge --circular src/
Problem: <design challenge>
Language: <primary language>
Framework: <if applicable>
Existing patterns: <detected>

2. Pattern Classification

Creational (object creation problems):

Factory, Builder, Singleton (last resort -- use DI),

Prototype, Abstract Factory.

Structural (composition problems):

Adapter, Decorator, Facade, Proxy, Composite, Bridge.

Behavioral (communication problems):

Strategy, Observer, Command, State, Chain of

Responsibility, Mediator, Iterator, Template Method.

Distributed (resilience/consistency):

Circuit Breaker, Saga, Outbox, CQRS, Strangler Fig,

Bulkhead, Sidecar.

3. Pattern Recommendation

For each candidate:

IF roles < 10 and stable: pure Strategy sufficient.

IF >3 switch/case on same type: consider State pattern.

IF files > 500 LOC: God Object -- extract classes.

4. Anti-Pattern Detection

find src/ -name "*.ts" | xargs wc -l \
  | sort -rn | head -20
npx jscpd src/ --min-lines 10 --min-tokens 50
grep -rn "email: string\|price: number" \
  --include="*.ts" src/

Key anti-patterns:

5. Artifacts

Save: docs/patterns/<feature>-pattern-analysis.md

Commit: "pattern: <feature> -- <pattern> (<confidence>)"

<!-- tier-3 -->

Quality Targets

Hard Rules

  1. NEVER recommend pattern without understanding problem.
  2. NEVER stack multiple patterns at once.
  3. NEVER recommend Singleton for dependency sharing.
  4. NEVER apply patterns prophylactically (YAGNI).
  5. NEVER produce recommendation without implementation.
  6. ALWAYS include trade-offs (benefits AND drawbacks).
  7. ALWAYS show alternatives considered.
  8. ALWAYS include unit test demonstrating pattern.

TSV Logging

Append .godmode/pattern-results.tsv:

timestamp	feature	pattern	category	confidence	antipatterns	language	files	verdict

Keep/Discard

KEEP if: tests pass AND complexity reduced
  AND code no more complex than necessary.
DISCARD if: pattern adds more complexity than it
  removes OR tests fail.

Stop Conditions

STOP when FIRST of:
  - Design problem resolved with tested implementation
  - Anti-pattern scan complete, findings prioritized
  - Pattern recommended with trade-offs + alternative

Autonomous Operation

On failure: git reset --hard HEAD~1. Never pause.

Error Recovery

| Failure | Action |

|--|--|

| Pattern adds complexity | Revert, simple code wins |

| Refactoring breaks tests | Smaller steps, test each |

| Team unfamiliar | Document with codebase example |

| Conflicts with framework | Prefer framework conventions |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.