plugins/flow/skills/architecture-patterns/SKILL.md
Document system design decisions with mapped user flows, coupling analysis, failure modes, and explicit non-goals, proving the architecture can survive under unexpected conditions. Use when designing systems, evaluating structural changes, or reviewing architecture decisions. Proactively suggest when coupling analysis reveals circular dependencies, god objects, or hidden shared state.
npx skillsauth add synaptiai/synapti-marketplace architecture-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.
Domain skill for system design, structural evaluation, and architecture decisions.
DESIGN ARCHITECTURE FROM FUNCTIONALITY, NOT TO FUNCTIONALITY. If you can't trace a component to a user flow, delete it.
Architecture serves user flows. Not the other way around.
Before designing ANYTHING, enumerate flows. Track each design activity as a task:
TaskCreate("Map user/admin/system flows", "Enumerate all flows before designing components")
TaskCreate("Coupling analysis", "Check imports, circular deps, god objects, hidden coupling")
TaskCreate("Design proposal", "Components, responsibilities, dependencies, data flow")
TaskCreate("Decision documentation", "Context, options, trade-offs, decision, consequences")
Each flow is a sequence: trigger → steps → outcome. Every component must serve at least one flow.
TaskUpdate("Map user/admin/system flows", status: "completed") after all flows enumerated.
Navigate the right level of abstraction:
| Level | Shows | When to Use | |-------|-------|-------------| | Context | System + external actors | Starting a new project, explaining to stakeholders | | Containers | Deployable units (services, DBs, queues) | Designing infrastructure, choosing tech stack | | Components | Modules within a container | Designing internal structure, reviewing coupling | | Code | Classes, functions, interfaces | Implementation decisions, code review |
Rule: Start at the highest relevant level. Zoom in only when needed. Most design discussions happen at Components level.
TaskUpdate("Coupling analysis", status: "in_progress")
Check actual dependencies, not assumed ones:
# Find imports and dependencies
grep -rn "import\|require\|from " --include="*.{ts,js,tsx,jsx,py,rb}" -l
# Check for circular dependencies
# Look for A imports B AND B imports A patterns
Red flags:
Dependencies should flow ONE direction:
UI → Application → Domain → Infrastructure
↓
External APIs
TaskUpdate("Coupling analysis", status: "completed")
Architecture decisions are incomplete without an explicit fence. Every design proposal MUST capture failure modes and non-goals alongside the happy-path component diagram. A design that only describes the success path is a design that will fail under the first unexpected condition.
Non-goals are scope fences. They prevent the design from sprawling into adjacent problems and prevent reviewers from rejecting the design because it "doesn't handle X" when X was never its job. Capture non-goals as a bulleted list in the decision record:
Non-goals must be written as declarative negations, not hedges. "Does not support multi-region writes" is a non-goal. "May eventually support multi-region writes" is a hedge and is not useful.
Every component in the design must have documented behavior for at least these failure modes:
| Failure Mode | Design Question | Record | |--------------|-----------------|--------| | Timeouts | What happens when a downstream call exceeds the deadline? | Error type, fallback, caller-visible outcome | | Partial failures | What happens when some operations in a batch succeed and others fail? | Rollback / compensate / surface partial result / retry policy | | Invalid input | What happens when input violates the contract (wrong type, missing field, out of range)? | Validation boundary, error shape, rejection vs. coercion | | Missing context | What happens when required config, env vars, or upstream state is absent? | Fail-fast at startup / degrade gracefully / specific error | | Dependency outage | What happens when a required external service is unreachable? | Circuit break / cache / queue / hard fail | | Resource exhaustion | What happens under memory pressure, connection-pool exhaustion, or rate limits? | Backpressure / shed load / error shape |
Record each failure mode's expected behavior in the decision record. If the design has no answer for a failure mode, that is a gap to close before proceeding — not a detail to defer to implementation.
Extend the Decision Framework table (below) with two new fields when documenting architectural decisions:
These fields are NOT optional. A decision record missing them is incomplete and should not ship.
Failure modes discovered at implementation time force backtracking: the author has to redesign mid-build to handle a case the design ignored. Failure modes discovered at verify time force fix-forward loops or rework. Failure modes captured at design time become test cases, verification commands, and explicit non-goals that prevent scope creep. The cost of capturing them early is minutes; the cost of discovering them late is days.
TaskUpdate("Decision documentation", status: "in_progress")
For each architectural decision, document:
| Field | Content | |-------|---------| | Context | What's the situation? What forces are at play? | | Options | 2-4 distinct approaches (not just "do it" vs "don't") | | Trade-offs | Pros and cons per option with evidence | | Decision | Which option and why | | Consequences | What changes? What new constraints? What risks accepted? |
TaskUpdate("Decision documentation", status: "completed") Use TaskList to confirm all design activities resolved before proceeding to implementation.
Before proposing new architecture, check what exists:
# What patterns does the codebase already use?
ls -la src/ app/ lib/
grep -r "class \|module \|interface " --include="*.{ts,js,py,rb}" | head -20
git log --oneline --all -- "src/*/index.*" | head -10
Rule: Follow existing patterns unless there's a documented reason to diverge. Consistency beats novelty.
| Anti-Pattern | Symptom | Fix | |-------------|---------|-----| | Design before mapping flows | Components that serve no user action | Map flows first, then design | | Pattern from trends | Using microservices because "everyone does" | Choose patterns from requirements | | Premature abstraction | Interfaces with one implementation | YAGNI. Concrete first, abstract when needed | | Astronaut architecture | 5 layers for a CRUD app | Match complexity to actual requirements | | Copy-paste architecture | Same structure regardless of problem | Each system is different. Design for THIS problem. |
| Excuse | Response | |--------|----------| | "We might need this later" | YAGNI. Build for now, extend when needed. The cost of removing is lower than maintaining unused code. | | "This is best practice" | Best practice for WHOM? Show the requirement it serves. | | "Let's add an abstraction layer" | For what? One implementation behind an interface is overhead, not architecture. | | "We need to future-proof this" | You can't predict the future. Build for today, refactor when requirements change. | | "Let's use microservices" | For a team of 3? Monolith first. Split when you have evidence of scaling needs. |
tools
Validate a FlowWorkflow YAML at `plugins/flow/workflows/<id>.workflow.yaml` against `schemas/v1/workflow.schema.json` AND cross-reference the referenced skills/agents exist + every Tier 3 action is confirm-gated + no native /goal or /loop dependency is declared. Use when /flow:workflow validate is invoked, when CI runs the workflow schema gates, or when a new workflow is being authored. This skill MUST be consulted because schema validation alone catches shape errors; cross-reference validation catches the silent-correctness failures (typo'd skill name, Tier 3 escape, /goal dependency) that would otherwise ship to users.
tools
Verify UI-facing changes by running a screenshot-analyze-verify loop across configured viewports, with a browser-tool priority cascade (Playwright MCP → Chrome DevTools MCP → CLI fallback → external skill fallback) and bounded iteration. Use after build/runtime verification passes and the diff includes `.tsx`/`.jsx`/`.vue`/`.html`/`.css`/`.scss`/`.svelte` files OR the acceptance criteria mention UI/page/render/display/visual. This skill MUST be consulted because UI changes that pass build and unit tests can still ship blank pages, render-blocking console errors, or broken responsive layouts that no other verification phase catches.
data-ai
Coordinate agent teams for adversarial review (paired skeptic/verifier per facet, challenge round with disposition vocabulary, consolidated findings with confidence) or parallel implementation (task sizing 5-6 per teammate, non-overlapping files). Enforces independent analysis before shared conclusions. Reference only (`disable-model-invocation: true`); loaded only when `agentTeams: true` in settings.
development
Conduct two-stage code review: Stage 1 verifies spec compliance (criterion-to-code mapping), Stage 2 evaluates security, correctness, performance, and maintainability across 6 parallel facets with P1/P2/P3 synthesis and deduplication by file:line. Use when reviewing code changes or pull requests. This skill MUST be consulted because reviewing quality on broken logic is wasted effort, and unmet acceptance criteria must block merge.