Generate architecture guidelines for the project. Analyzes tech stack from DESCRIPTION.md, recommends an architecture pattern, and creates .ai-factory/ARCHITECTURE.md. Use when setting up project architecture, asking "which architecture", or after /aif setup.
67
82%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Generate .ai-factory/ARCHITECTURE.md with architecture decisions tailored to the project.
FIRST: Read .ai-factory/config.yaml if it exists to resolve:
paths.description and paths.architecturelanguage.ui for prompts and language.artifacts for generated architecture contentWhen invoked by /aif, assume .ai-factory/config.yaml has already been written for the current setup run and already contains the resolved language.ui / language.artifacts values.
If config.yaml doesn't exist, use defaults:
.ai-factory/DESCRIPTION.md.ai-factory/ARCHITECTURE.mden (English)THEN: Read .ai-factory/DESCRIPTION.md (use path from config) if it exists to understand:
If .ai-factory/DESCRIPTION.md does not exist:
⚠️ No project description found.
Run /aif first to set up project context, or describe your project manually:
- What are you building?
- Tech stack (language, framework, database)?
- Team size?
- Expected scale?Allow standalone usage — if user provides manual input, use that instead.
Read .ai-factory/skill-context/aif-architecture/SKILL.md — MANDATORY if the file exists.
This file contains project-specific rules accumulated by /aif-evolve from patches,
codebase conventions, and tech-stack analysis. These rules are tailored to the current project.
How to apply skill-context rules:
Enforcement: After generating any output artifact, verify it against all skill-context rules. If any rule is violated — fix the output before presenting it to the user.
Based on project context, evaluate against the decision matrix and recommend an architecture:
If $ARGUMENTS specifies an architecture (e.g., /aif-architecture explicit):
layers → Layered Architecturemicroservices → Microservicesstructured → Structured Modules (ask variant — see below)explicit → Explicit Architecture (ask variant — see below)clean → Explicit Architectureddd → Explicit Architecturemonolith → Structured Modulesvertical → Explicit Architecture (Vertical Slice By Entity)structured-layers → Structured Modules (Technical Layer)structured-vertical → Structured Modules (Vertical Slices By Entity)explicit-layers → Explicit Architecture (Technical Layer)explicit-vertical → Explicit Architecture (Vertical Slice By Entity)explicit-flat → Explicit Architecture (Flat Vertical Slice - Simplified)structured is specified without a suffix: ASK the user: "Which folder structure variant do you prefer for Structured Modules? 1. Technical Layer (simpler) or 2. Vertical Slices by Entity (better for large modules)". Wait for their answer before generating the artifact.explicit is specified without a suffix: ASK the user: "Which folder structure variant do you prefer for Explicit Architecture? 1. Technical Layer or 2. Explicit Architecture (Vertical Slice By Entity) or 3. Explicit Architecture (Flat Vertical Slice - Simplified)". Wait for their answer before generating the artifact.If no specific architecture requested:
references/architecture.md)AskUserQuestion:Based on your project context:
- [reason 1 from project analysis]
- [reason 2 from project analysis]
Which architecture pattern should we use?
1. [Recommended pattern] (Recommended) — [why it fits]
2. [Alternative 1] — [brief reason]
3. [Alternative 2] — [brief reason]
4. [Alternative 3] — [brief reason]Architecture options:
references/architecture.md for detailed descriptions of these patterns to formulate your recommendation).CRITICAL INSTRUCTION: You MUST read references/architecture.md before generating the ARCHITECTURE.md artifact to ensure correct terminology, dependency directions.
CRITICAL: Before generating the document, compare the chosen architecture's ideal folder structure (from references/architecture.md) against the actual existing codebase structure.
AskUserQuestion:The current project structure differs significantly from the ideal [Pattern Name] architecture.
[Briefly list 1-2 major differences]
How should we generate the ARCHITECTURE.md?
1. Adapt the guidelines to fit the existing application structure (document reality).
2. Generate the pure, strict architecture guidelines (requires refactoring the application later to match).Wait for their decision before proceeding to Step 2.
Create the parent directory for the resolved architecture path if needed.
Generate the resolved architecture artifact (default: .ai-factory/ARCHITECTURE.md) with the following structure, adapted to the project's tech stack and language:
# Architecture: [Pattern Name]
## Overview
[1-2 paragraphs: what this architecture is and why it was chosen for THIS project]
## Decision Rationale
- **Project type:** [from DESCRIPTION.md]
- **Tech stack:** [language, framework]
- **Key factor:** [primary reason for this choice]
## Folder Structure
\`\`\`
[folder structure adapted to the project's tech stack]
[use actual framework conventions — e.g., Next.js app/ dir, Laravel app/ dir, Go cmd/ dir]
\`\`\`
## Dependency Rules
[What depends on what. Inner vs outer layers. Module boundaries.]
- ✅ [allowed dependency direction]
- ❌ [forbidden dependency direction]
## Layer/Module Communication
[How layers or modules communicate with each other]
- [pattern 1]
- [pattern 2]
## Key Principles
1. [Principle 1 — adapted to this project]
2. [Principle 2]
3. [Principle 3]
[If the user chose Option 2 (strict architecture) in Step 1.5, add the following section:]
## Legacy vs New Code Policy
- **New Features:** All new code MUST strictly follow the architecture defined in this document.
- **Legacy Code Modification:** Do NOT automatically refactor unrelated legacy code to fit this architecture. Touch legacy code only when necessary for bug fixes, when tasked with explicit refactoring, or when adapting it to be consumed by new features.
- **Interoperability:** When new code must call legacy code, isolate the interaction using adapters, interfaces, or facades so that legacy patterns do not pollute the new architecture.
[If the user chose Option 1 (adapt to reality) in Step 1.5, add the following lighter section:]
## Code Organization Note
- **New Features:** All new code should follow the architecture defined in this document where practical.
- **Existing Code:** Document the current structure as-is. When modifying existing code, prefer following the architectural conventions in this document, but do not force a rewrite of unrelated code.
- **Interoperability:** When new code must call existing code, prefer clean interfaces but do not refactor purely for structural alignment.
## Code Examples
### [Example 1 title]
\`\`\`[language]
[code example in the project's language/framework]
\`\`\`
### [Example 2 title]
\`\`\`[language]
[code example showing dependency rule]
\`\`\`
## Anti-Patterns
- ❌ [What NOT to do in this architecture]
- ❌ [Common mistake to avoid]Rules for generation:
If the resolved DESCRIPTION.md path exists, add or update an architecture-pointer section in resolved language.artifacts.
Use the resolved architecture path from config, not the default path literal.
## [Localized heading: Architecture]
[Localized sentence in resolved artifacts language referencing the resolved architecture artifact path for detailed architecture guidelines.]
[Localized label: Pattern]: [chosen pattern name]If AGENTS.md exists in the project root, add the resolved architecture artifact path to the localized "AI Context Files" table in resolved language.artifacts:
| [resolved-architecture-path] | [Localized architecture artifact description in resolved artifacts language] |Only add if the resolved architecture path is not already present.
Present the confirmation in resolved language.ui and report the resolved architecture path:
[Localized success heading in `language.ui`]
[Localized pattern label in `language.ui`]: [chosen pattern]
[Localized file label in `language.ui`]: [resolved architecture path]
[Localized key-rules heading in `language.ui`]:
- [rule 1]
- [rule 2]
- [rule 3]
[Localized closing sentence in `language.ui` about workflow skills following these architecture guidelines.].ai-factory/ARCHITECTURE.md).config.yaml when provided.config.yaml, architecture row in AGENTS.md context table.e144f95
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.