architecture-placement
Guides architecture placement decisions for codebases using Domain-Driven Design, Clean Architecture, Onion Architecture, or Ports and Adapters. Use when planning, reviewing, specifying, refactoring, or implementing behavior that must be assigned to entities, value objects, domain services, use cases, ports, adapters, gateways, repositories, readers, controllers, or schemas. Do not use for simple mechanical edits, formatting-only changes, or architecture-agnostic documentation.
- License 许可
- MIT
- 最近更新
- 2026-07-16
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- architecture-placement
- description
- Guides architecture placement decisions for codebases using Domain-Driven Design, Clean Architecture, Onion Architecture, or Ports and Adapters. Use when planning, reviewing, specifying, refactoring, or implementing behavior that must be assigned to entities, value objects, domain services, use cases, ports, adapters, gateways, repositories, readers, controllers, or schemas. Do not use for simple mechanical edits, formatting-only changes, or architecture-agnostic documentation.
02 资源文件 5
- 参考文档agents/openai.yaml237 B
- 资产文件assets/architecture-placement-plan-template.md1.0 KB
- 参考文档references/architecture-guidelines.md4.7 KB
- 参考文档references/layer-boundary-smells.md3.4 KB
- 参考文档references/placement-rubric.md6.3 KB
03 SKILL.md 正文
Architecture Placement
Use this skill to decide where responsibilities belong before specification, implementation, refactoring, or review in DDD/Clean/Onion/Ports-and-Adapters codebases.
Core Rule
Keep domain decisions in the domain.
Use cases coordinate actor goals, transactions, ports, and persistence boundaries. They must not own formulas, invariants, eligibility decisions, semantic validation, state transitions, or business policies.
Gateways encapsulate access to external systems or resources. They translate between the host application's vocabulary and the foreign API; they must not own domain policy.
Workflow
- Inspect the local architecture source of truth before deciding:
AGENTS.md, architecture docs, existing modules, TechSpecs, ADRs, and nearby code patterns. - Apply the applicability gate: if the project is CRUD-only, utility-only, or architecture-agnostic, avoid forcing DDD/Clean patterns and state the lighter approach.
- Read
references/architecture-guidelines.mdwhen the project architecture is unclear or when explaining Clean, Hexagonal, Gateway, or DDD vocabulary. - Identify the bounded context and write the business language used by the codebase, not generic architecture labels.
- List the domain concepts, invariants, calculations, policies, state transitions, and external dependencies involved.
- Classify each responsibility into one architectural role using
references/placement-rubric.mdwhen placement is non-trivial. - Read
references/layer-boundary-smells.mdwhen reviewing or challenging an existing design. - Produce an Architecture Placement Plan before edits for non-trivial changes, using
assets/architecture-placement-plan-template.mdwhen a full plan is useful. - Implement or review only after the plan makes layer ownership explicit.
Architecture Placement Plan
For non-trivial work, produce this plan before editing code:
Architecture Placement Plan
Bounded context:
User/application goal:
Domain concepts:
Invariants and business rules:
Value objects:
Entities/aggregates:
Domain services:
Domain events:
Use cases/application services:
Ports:
Gateways:
Adapters:
Repositories/readers:
Presentation/API/schema responsibilities:
Prohibited placements:
Expected files:
Expected tests:
Open questions:
Keep the plan short. Use None only after verifying the category is genuinely not involved.
Placement Heuristics
- Put identity, lifecycle, and invariant protection in entities or aggregates.
- Put immutable named concepts, constrained values, formulas over one concept, and equality-by-value behavior in value objects.
- Put domain policies or calculations spanning multiple entities/value objects in domain services.
- Put actor-goal orchestration, unit-of-work ownership, retries, permissions handoff, and calls to ports in use cases/application services.
- Put external dependency contracts in ports.
- Put awkward external systems and foreign vocabularies behind gateways.
- Put framework, database, HTTP, queue, cache, vendor, and file-format mechanics in adapters.
- Put aggregate persistence behind repositories.
- Put reporting, dashboards, read models, and analytic projections behind readers or query adapters.
- Put transport parsing, authentication dependency wiring, status-code mapping, and response shape in presentation.
Review Gate
Before accepting a design, check for these placement failures:
- A use case calculates domain formulas or decides eligibility.
- A controller, schema, serializer, or adapter contains business rules.
- A repository hides domain policy inside SQL instead of returning facts or persisting aggregates.
- A gateway contains business policy instead of translation and external access concerns.
- Foreign DTOs, SDK types, ORM rows, or vendor vocabulary leak inward.
- A domain service calls another domain service as an orchestration chain.
- An adapter type leaks inward into application or domain signatures.
- A generic name such as
Manager,Processor,Handler,Helper,Materializer, orUtilhides the actual architectural role. - A refactor only splits files but leaves ownership unclear.
When one appears, rename or move the responsibility by role before proceeding.
Naming Rule
Name components by architectural responsibility:
- Use case/application service: verb phrase ending in
UseCaseor existing project convention. - Domain service: domain policy/calculation name, not technical action.
- Value object: domain noun.
- Entity/aggregate: identity-bearing domain noun.
- Port: capability contract from the inner layer's perspective.
- Gateway: external system/resource name plus host-facing capability.
- Adapter: concrete technology plus port name.
- Repository/reader: persistence/read concern and aggregate or projection.
Avoid names that describe an implementation effect without a layer role. If a name seems necessary, first classify what it really is.
Outputs by Task Type
- For TechSpecs: add a "Layer Ownership" or "Architecture Placement" section and map every important behavior to a role.
- For implementation: present the Architecture Placement Plan before edits unless the change is trivial.
- For review: lead with placement violations and file/line references, then suggest role-correct moves.
- For refactoring: distinguish moving logic to the right layer from merely extracting files.
Error Handling
- If the project architecture conflicts with this skill, follow the project's explicit source of truth and call out the conflict.
- If bounded context or business language is unclear, inspect nearby code and ask one focused question only if a reasonable assumption would be risky.
- If legacy code violates the desired architecture, do not copy the violation unless the task is explicitly compatibility-only.
- If the user asks for code immediately, still perform the smallest useful placement check before editing.
04 同仓库更多 Skills
to-prompt-opus
Use when preparing or rewriting prompts for Claude Opus 4.8, Anthropic API agents, XML-structured prompts, long-context document work, coding agents, research synthesis, frontend/design tasks, or model-specific prompt optimization. Do not use for GPT/OpenAI prompts or raw context packaging without Opus-specific tuning.
to-prompt-gpt
Use when preparing or rewriting prompts for GPT-5.5, OpenAI API agents, Responses workflows, coding agents, research synthesis, support assistants, or model-specific prompt optimization. Do not use for Claude/Opus prompts or raw context packaging without GPT-specific tuning.
plan-refactor-qa
Plans and runs qa-report before executing Compozy refactor tasks. Use when the user provides a refactor or issue slug and wants Codex to inspect the matching .compozy/tasks directory, related PRD/TechSpec/ADR/task artifacts, affected code, and existing tests, then invoke $qa-report with a repository-grounded prompt. Do not use to run tests, execute qa-execution, implement code, or perform post-refactor verification.
multi-tool-branch-review
Orchestrates a multi-tool branch review of the current git branch against a base branch. By default it runs two independent thermo-nuclear maintainability audits, one on Codex GPT-5.5 xhigh and one on Claude Opus xhigh, then consolidates the findings into a single remediation plan via writing-plans. If the user explicitly asks for native reviews, it can add the Claude native review pass, the Codex native review pass, or both. Use when the user wants a deep cross-model review of a branch or PR before merge, or asks to review this branch with multiple tools or models. Encodes known infra failure modes and their fixes (missing Claude ACP adapter, Codex MCP auth hangs, false-positive report files, long jobs orphaned inside subagents). Do not use for reviewing a single uncommitted snippet, for non-git work, for running only one reviewer, or when the user only wants a quick lint or test run.
create-pr-with-template
Create a GitHub Pull Request with gh CLI and prefer repository PR templates automatically. Use this whenever the user asks to open/create a PR, especially when template compliance is needed. If multiple templates exist, ask the user which template to use.
ui-craft
Provides guardrails for user-facing UI work: usability heuristics, accessibility floors, design-system discipline, component states, microcopy, motion, dark mode, responsive behavior, and human-AI UX. Use when designing, generating, reviewing, or refactoring visible product surfaces such as components, pages, dashboards, forms, dialogs, loading/empty/error states, or AI interfaces. Do not use for backend-only work, infrastructure, CLI/TUI design, or pure documentation editing.