software-architecture
Guides architectural decisions using Clean Architecture, separation of concerns, and SOLID principles, covering where new code should live, how modules depend on each other, and which anti-patterns to avoid, with a review checklist. Use when designing a new module or feature structure, refactoring code organization, deciding where code belongs, or reviewing a codebase's architecture.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-08
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- software-architecture
- license
- Apache-2.0
- metadata
- { "owner": "razorvision", "version": "0.1.0" }
- description
- Guides architectural decisions using Clean Architecture, separation of concerns, and SOLID principles, covering where new code should live, how modules depend on each other, and which anti-patterns to avoid, with a review checklist. Use when designing a new module or feature structure, refactoring code organization, deciding where code belongs, or reviewing a codebase's architecture.
03 SKILL.md 正文
Software Architecture Guide
Principles and patterns for maintainable, scalable software design.
Usage
Invoke with the module, directory, or feature to design or review. With no argument, apply the guidance to the change under discussion.
When to Use
- Designing new module or feature structure
- Refactoring existing code organization
- Deciding where new code should live
- Reviewing separation of concerns
- Choosing between architectural patterns
Core Principles
Separation of Concerns
| Layer | Responsibility | Example |
|---|---|---|
| UI/Components | Rendering, user interaction | React components, pages |
| Hooks/State | Client state management, side effects | Custom hooks, context |
| API/Routes | Request handling, validation, response formatting | API route handlers |
| Services/Lib | Business logic, data transformation | Pure functions, calculators |
| Data Access | Database queries, external API calls | ORM queries, SDK clients |
| Types | Shared interfaces and contracts | TypeScript types/interfaces |
SOLID for TypeScript/React
- S: Single Responsibility. Each file/function does one thing
- O: Open/Closed. Extend via composition, not modification
- L: Liskov Substitution. Subtypes must honor parent contracts
- I: Interface Segregation. Small, focused interfaces over large ones
- D: Dependency Inversion. Depend on abstractions, not concretions
Practical Guidelines
- Functions under 50 lines when possible
- Files under 300 lines: split if larger
- Max 3 levels of nesting: extract helpers or early-return
- No
utils.tsorhelpers.ts: use domain-specific names (invoice-parser.ts,price-formatter.ts) - Colocation: put related files together (component + test + types)
- Library-first: check for a well-maintained package before writing custom code
Decision Framework
When adding new code, ask:
- Does this already exist? Search the codebase first.
- Where does this belong? Match the layer (UI, logic, data).
- Is this reusable? If yes, put it in a shared module (e.g.
lib/). If no, keep it near its usage. - Does this need state? Prefer server-rendered or stateless code; add client state only when needed.
- Is this testable? Pure functions beat side-effect-heavy code.
Anti-Patterns to Avoid
| Anti-Pattern | Better Approach |
|---|---|
| God component (500+ lines) | Split into container + presentational |
| Prop drilling 3+ levels | React Context or composition |
| Business logic in API routes | Extract to service/lib/ functions |
| Duplicate validation | Single schema (e.g. Zod), reused on client and server |
| Direct DB calls in components | A data access layer (e.g. lib/db/queries/) |
| Premature abstraction | Wait until you have 3 concrete cases |
Review Checklist
When reviewing the architecture of the named target:
- [ ] Each module has a single, clear responsibility
- [ ] Dependencies flow inward (UI -> Logic -> Data)
- [ ] No circular dependencies
- [ ] Shared types defined in one place (e.g.
types/), not duplicated - [ ] Tests can run without external services
- [ ] New patterns are consistent with existing codebase conventions
04 同仓库更多 Skills
<folder-name-lowercase-hyphens>
<What it does. Use when the user asks for <X> or mentions <Y>.>
full-skill
暂无简介
typescript
Guides TypeScript best practices for strict-mode projects, covering discriminated unions, interface contracts, nullability, type guards, utility types, async return types, const assertions, and a review checklist of common anti-patterns. Use when writing, reviewing, or debugging TypeScript code or type definitions.
testing
Guides writing, reviewing, and debugging Vitest tests for JavaScript and TypeScript projects, covering test structure, async handling, mocking, error cases, setup and teardown, and a review checklist of common anti-patterns. Use when writing new tests, reviewing a test file, or debugging a failing or flaky Vitest suite. Not for Python test suites.
staleness-check
Sweeps the repo and related sources for artifacts that a just-completed body of work should have updated but did not, such as stale doc indexes, READMEs, ADRs, registries, agent instruction files, agent memory files, issue status, and cross-references, then reports each stale item with a proposed fix. Use at the end of an epic, feature, or executed plan, or when the user says "staleness check", "did we miss anything", "are we done", or "anything stale".
root-cause
Traces a bug backward through the call chain to the original trigger instead of patching where the error surfaces, then fixes it at the source and adds defensive validation at intermediate layers. Use when debugging an error, a failing test, or unexpected behavior where the symptom appears far from its cause.