# Vaastu > Plan frontend and backend architecture, review AI-generated code, and fix project structure with Vaastu, an open-source architecture skill for AI coding agents. Vaastu is an MIT-licensed architecture decision framework. Examples are illustrative; this site makes no production performance, ranking, or security guarantees. ## Documentation - [Vaastu — Software Architecture Skill for AI Coding Agents](https://get-vaastu.vercel.app/index.md): Plan frontend and backend architecture, review AI-generated code, and fix project structure with Vaastu, an open-source architecture skill for AI coding agents. - [Software Architecture Skill Setup and Docs — Vaastu](https://get-vaastu.vercel.app/docs.md): Apply Vaastu to frontend, backend, and full-stack projects. Read architecture decisions, workflow checks, agent setup, and discovery guidance for your existing stack. - [Software Architecture Guides for AI Coding Agents — Vaastu](https://get-vaastu.vercel.app/guides.md): Practical guides for using an AI coding skill to plan frontend, backend, and full-stack architecture, review software systems, and organize shared code. - [Plan Frontend and Backend Architecture with AI — Vaastu](https://get-vaastu.vercel.app/guides/frontend-backend-architecture.md): Plan full-stack architecture with an AI coding agent: define frontend and backend ownership, API contracts, trusted operations, and one verified user workflow. - [Install an Architecture Skill for AI Coding Agents — Vaastu](https://get-vaastu.vercel.app/guides/install-architecture-skill.md): Install Vaastu for Codex, Claude Code, Cursor, or another Markdown-reading coding agent. Load the AI skill and request an architecture review or scoped change. - [Scalable TypeScript Monorepo Architecture with AI — Vaastu](https://get-vaastu.vercel.app/guides/scalable-typescript-monorepo.md): A worked architecture exercise: turn web and operations requirements into application boundaries, shared contracts, and one verified vertical slice. - [Review and Fix Architecture with an AI Coding Agent — Vaastu](https://get-vaastu.vercel.app/guides/review-existing-architecture.md): Review software architecture and repair AI-generated code with Vaastu. Find dependency, state, and ownership problems, then verify a scoped refactor. - [Frontend Architecture: Features and State Ownership — Vaastu](https://get-vaastu.vercel.app/guides/frontend-architecture.md): Use Vaastu's frontend architecture skill to organize features, components, state, forms, and data fetching with an AI agent. Verify the affected interactions. - [Backend Architecture: APIs, Data, and Authorization — Vaastu](https://get-vaastu.vercel.app/guides/backend-architecture.md): Use Vaastu's backend architecture skill to plan APIs, authorization, domain rules, database operations, retries, and concurrency with your AI coding agent. ## Source - [Skill entry point](https://raw.githubusercontent.com/KOUSHIKG04/scalable-architecture-skill/main/skills/vaastu/SKILL.md) - [Repository and supporting resources](https://github.com/KOUSHIKG04/scalable-architecture-skill) - [Combined public documentation](https://get-vaastu.vercel.app/llms-full.txt) --- # Vaastu — Software Architecture Skill for AI Coding Agents Canonical page: https://get-vaastu.vercel.app/ Make AI reason about your system before it writes the code. Vaastu is an open-source software architecture skill for AI coding agents. Use it to plan frontend and backend architecture, review and untangle an existing codebase, or guide architecture fixes in AI-generated code. Define feature ownership, data contracts, dependencies, and verification before implementation. ## Installation ### npm ```sh npx skills add KOUSHIKG04/scalable-architecture-skill --skill vaastu ``` ### pnpm ```sh pnpm dlx skills add KOUSHIKG04/scalable-architecture-skill --skill vaastu ``` ### bun ```sh bunx skills add KOUSHIKG04/scalable-architecture-skill --skill vaastu ``` ### yarn ```sh yarn dlx skills add KOUSHIKG04/scalable-architecture-skill --skill vaastu ``` Yarn requires version 2 or later for yarn dlx. With Yarn Classic (1.x), use the npm / npx command. Compatible with Markdown-reading coding agents. Automatic installation and discovery depend on the agent. [Documentation](https://get-vaastu.vercel.app/docs) · [Guides](https://get-vaastu.vercel.app/guides) ## Frequently asked questions ### Which coding agents support Vaastu? Codex, Claude Code, Cursor, Windsurf, GitHub Copilot, and Google Gemini can read Vaastu. Install with the Skills CLI where supported, or provide SKILL.md directly. Automatic discovery depends on your agent. ### Can I use Vaastu with an existing project? Yes. Ask your agent to review or untangle a workflow and propose scoped architecture fixes while preserving existing behavior, routes, data, and permissions. ### Does Vaastu work for small projects? Yes. Use only the guidance your task needs. Vaastu does not require a backend, monorepo, or microservices. ### Does the skill guarantee scalability or security? No. Vaastu guides architecture decisions. Scalability, security, and correctness still need implementation checks and verification. [Source repository](https://github.com/KOUSHIKG04/scalable-architecture-skill) [Read SKILL.md](https://raw.githubusercontent.com/KOUSHIKG04/scalable-architecture-skill/main/skills/vaastu/SKILL.md) --- Canonical page: https://get-vaastu.vercel.app/docs # Architecture Specifications & Agent Protocol Use Vaastu to plan and review software architecture across frontend, backend, and full-stack projects. Adapt ownership, dependencies, trusted operations, and verification to the actual requirements and current stack. ## Use Vaastu for small and large projects Use the same skill for small and large projects. Scale planning and verification to the task and its risks. 1. Install from your project root and select your coding agent. 2. Describe the outcome, existing code, constraints, scope and acceptance criteria. Ask the agent to read the installed SKILL.md. 3. Use the short prompt for focused work or the full-project template for substantial builds. Say whether you want a proposal or implementation. ### npm ```sh npx skills add KOUSHIKG04/scalable-architecture-skill --skill vaastu ``` ### pnpm ```sh pnpm dlx skills add KOUSHIKG04/scalable-architecture-skill --skill vaastu ``` ### bun ```sh bunx skills add KOUSHIKG04/scalable-architecture-skill --skill vaastu ``` ### yarn ```sh yarn dlx skills add KOUSHIKG04/scalable-architecture-skill --skill vaastu ``` Yarn requires version 2 or later for yarn dlx. With Yarn Classic (1.x), use the npm / npx command. ### Small project: a personal expense tracker One existing web app, browser-local persistence and a focused workflow. Keep the structure local; add no backend or workspace packages without a requirement. ```text Read .agents/skills/vaastu/SKILL.md and apply the relevant guidance to this existing web app. Implement a personal expense tracker with add, edit and delete actions, a running total, and browser-local persistence. Reuse the current UI and project structure. No accounts, backend service or multi-app workspace are needed for this task. Acceptance criteria: reject invalid or non-positive amounts; totals update after each change; saved expenses survive a page reload; existing routes and unrelated behavior remain intact. Inspect the code, state a brief plan, and implement the scoped workflow. Verify the acceptance criteria with appropriate checks and report anything you could not exercise. ``` Inspect, briefly plan, implement and verify. This example needs no separate architecture proposal or feature specification. ### Backend-only project: a protected record update One existing backend, a protected resource, and a focused mutation. Keep the current runtime and persistence; no frontend or new service is required. ```text Read the installed Vaastu SKILL.md and inspect this backend repository. Implement the record-update workflow described in the requirements using the existing transport and persistence. Validate input, verify identity and resource scope, allow only permitted fields, and preserve the relevant domain invariant under concurrent updates. Keep transport adaptation separate from reusable business behavior without adding unnecessary layers. Define stable errors and retry behavior where duplicate execution matters. Acceptance criteria: permitted updates persist; malformed input, protected-field edits, and unauthorized resource access are rejected; existing contracts and unrelated behavior remain intact. State a brief plan, implement within this scope, and run relevant request, domain, permission, and persistence checks. Report unexecuted cases explicitly. ``` Use the actual resource, permissions, and invariant from the project requirements. Verify trusted behavior directly; a UI and separate backend deployment are unnecessary. ### Large project: a multi-tenant order platform Customer and operations experiences share durable orders and tenant permissions. Use documented requirements and the full-project template; justify each application, package and service. ```text Read .agents/skills/vaastu/SKILL.md and REQUIREMENTS.md. Use the full-project implementation template and relevant supporting resources for this task. Build the must-have scope in REQUIREMENTS.md for a multi-tenant order platform with customer and operations experiences. Customers create and view their own tenant’s orders. Authorized operations users update order status within their assigned tenant. Persist orders on the trusted backend and reject unauthorized or cross-tenant reads and writes. Inspect the repository and present the simplest justified architecture and dependency-ordered plan before substantial edits. This request authorizes implementation of the documented must-have scope. Implement one connected create-order workflow first, verify it, and then complete the remaining dependency-ready must-have workflows. Record significant decisions and relevant measurable requirements, with their sources and owners. Use feature acceptance criteria and the Definition of Done. Verify applicable contracts, permissions, data/retry behavior, dependencies and integrations. For a release, assess the relevant CI, migrations, recovery and operational checks. Do not add speculative services or implement later features. Preserve existing behavior outside scope, and distinguish implemented, tested, deployed and operationally verified work. Report missing requirements or blocked integrations explicitly. ``` First fill REQUIREMENTS.md with must-have workflows, roles, stack constraints, workload and applicable performance, recovery and release criteria. Keep unknown targets explicit. ## Frontend, backend, and full-stack projects Vaastu is a universal architecture decision framework. Apply it to the project's existing language, frameworks, runtimes, and deployment constraints. The examples illustrate responsibilities; they do not require a particular stack or a separate service for each layer. ### Frontend-only work Keep screens, interactions, form behavior, and local state with the owning feature. Reuse the existing UI system and data path. A browser-local tool or static site needs no API or database just to follow the framework. - Assign local, URL, draft, session, and fetched state one owner where each applies. - Exercise loading, empty, invalid, error, keyboard, and relevant viewport states. - Measure performance against the actual problem; verify native behavior on the target runtime when affected. - [Frontend architecture](https://github.com/KOUSHIKG04/scalable-architecture-skill/blob/main/skills/vaastu/references/frontend-architecture.md) ### Backend-only work Keep transport adapters thin and trusted operations owned by their feature. Define validation, identity, resource scope, domain rules, persistence, integrations, and stable outcomes without requiring a UI or a controller/service/repository hierarchy. - Authorize reads and writes at trusted boundaries and reject protected-field edits. - Use transactions, constraints, or conditional writes for affected invariants and concurrency. - Define safe retries, timeouts, duplicate handling, and observable recovery for integrations or jobs. - [Backend architecture](https://github.com/KOUSHIKG04/scalable-architecture-skill/blob/main/skills/vaastu/references/backend-architecture.md) ### Full-stack and multi-client work A full-stack framework can keep UI and backend operations inside one application. Separate client and trusted responsibilities without forcing separate deployments. Add services or shared packages only when real consumers or operational requirements justify them. - Define portable inputs, authoritative outputs, errors, serialization, and retry behavior. - Reconcile affected data after mutations and isolate caches and pending requests when identity or resource scope changes. - Keep privileged modules and credentials out of client bundles; check compatibility with supported older clients. - [Frontend-backend integration](https://github.com/KOUSHIKG04/scalable-architecture-skill/blob/main/skills/vaastu/references/frontend-backend-integration.md) - [Create-order walkthrough](https://github.com/KOUSHIKG04/scalable-architecture-skill/blob/main/skills/vaastu/examples/create-order.md) ### Prove one connected workflow For a workflow that needs both UI and persistence, trace the path below. Omit layers that do not apply to the task. 1. Capture user input in the owning feature and provide immediate feedback. 2. Validate at the trusted boundary and verify identity and resource access. 3. Apply authoritative domain rules and commit required changes atomically. 4. Return a stable result or safe error, with retry behavior defined. 5. Reconcile the owning UI/query state and preserve recoverable user input. 6. Verify success, denied access, failure, and recovery with environment-specific evidence. This is an illustrative flow, not evidence that a particular system has been implemented, load-tested, or deployed. - [Plan frontend and backend architecture](/guides/frontend-backend-architecture) - [Install and use the skill](/guides/install-architecture-skill) - [Frontend feature and state architecture](/guides/frontend-architecture) - [Backend operations and data consistency](/guides/backend-architecture) ## Untangle an existing codebase Use Vaastu's ownership and dependency rules to repair an existing workflow whose responsibilities are unclear. Identify the behavior to preserve and work within the current stack. ### Describe the workflow Record the input, permitted actor, affected data, expected result, and failure behavior. Establish the relevant baseline checks and preserve drafts, navigation, and resource cleanup where applicable. ### Locate the responsible owners Trace feature behavior, state, trusted access, persistence, and consumers. Use file evidence to identify the boundary problem and select the smallest ownership repair. Record significant decisions and alternatives. ### Verify the original behavior Implement within the authorized scope and check the affected consumers, imports, permissions, and persistence. Finish when the agreed workflow checks pass, and report remaining blockers or untested cases. These responsibilities do not require a separate layer or service for each step. Preserve the current architecture where it meets the requirements, and keep unrelated cleanup outside the scoped repair. ```text Read the installed Vaastu SKILL.md and references/codebase-untangling.md. Review [workflow] using this project's existing stack. Do not change files yet. Trace input, feature behavior, state ownership, trusted access, persistence, and the result consumed by the UI or caller, where applicable. For each boundary problem, give file evidence, the affected behavior, the owning module, and the smallest repair with acceptance checks. Preserve routes, contracts, data, permissions, drafts, and lifecycle cleanup. Record significant ownership decisions and distinguish verified facts from unknowns. ``` [Read the untangling example](/guides/review-existing-architecture#untangle-coupled-code) [Skill reference](https://github.com/KOUSHIKG04/scalable-architecture-skill/blob/main/skills/vaastu/references/codebase-untangling.md) ## Agent Protocol Prompt Give your coding agent the project requirements and ask it to read SKILL.md. Use a short prompt for focused work, or the optional full-project template for substantial architecture and implementation. ### Which prompt should I use? Use the short prompt for focused changes. For a substantial build, use the full-project template with requirements, implementation scope and acceptance criteria. ```text Read .agents/skills/vaastu/SKILL.md and use it as the architecture decision framework for this project. Use its references, examples, and templates when relevant. Do not blindly copy an example architecture. First analyze the project requirements and existing repository. Before substantial implementation, define: - requirements and assumptions - system architecture - application/runtime boundaries - repository architecture - feature/module ownership - backend/API responsibilities - database and data ownership - shared-code strategy - dependency rules - state ownership - authentication and authorization boundaries - testing and architecture validation - scalability triggers - first end-to-end vertical slice - implementation order Apply this framework to the project's existing language, frameworks, runtimes, and deployment model. Keep frontend and backend in one application when that meets the requirements. Omit layers the workflow does not use. For focused work, apply only relevant decisions; do not require a full-system proposal. Follow the current request's implementation scope. Stop at the proposal when only a proposal was requested. ``` ### Full-project implementation prompt The optional template adds a project brief and delivery criteria for substantial work. Fill it in or reference your existing requirements. [Read and copy the full-project template](https://github.com/KOUSHIKG04/scalable-architecture-skill/blob/main/skills/vaastu/templates/PROJECT_IMPLEMENTATION_PROMPT.md) ## The 5-Step Execution Lifecycle Inspect, plan, review within scope, then implement and verify one workflow at a time. ### Ingests Framework Heuristics Read SKILL.md and only the supporting resources relevant to the task. ### Inspects Constraints & Context Inspect existing behavior, runtimes, data stores and constraints before proposing changes. ### Emits Architecture Proposal For substantial work, explain boundaries, ownership, data and the first implementation slice. ### Human Review & Confirmation Stop at the proposal if that is the requested scope. Otherwise continue within existing implementation authorization; clarify material departures. ### Execution Build and verify each dependency-ready workflow before expanding. ## The 14 Architecture Decisions For substantial architecture work, evaluate the relevant concerns below. For a focused change, apply the affected decisions instead of requiring a full-system document. ### System Boundaries Category: Boundaries Client, server, worker, or application boundaries justified by the workflow and deployment needs. Failure risk: Unclear ownership or speculative service boundaries that add coordination without solving a requirement. ### Runtime Isolation Category: Boundaries Browser, native, server, worker, command-line, and managed runtimes present in the project. Failure risk: Platform-specific dependencies crossing incompatible runtime or client/server boundaries. ### Feature Ownership Category: Boundaries Each capability owns the UI, commands, queries, and state its workflow actually needs. Failure risk: Unrelated behavior collecting in global folders or features depending on each other's internals. ### Database & Schemas Category: Data & State Authoritative data ownership, scoped access, transaction boundaries, constraints, and reproducible persistence changes. Failure risk: Privileged data access escaping trusted boundaries or multi-step writes leaving inconsistent records. ### State Ownership Category: Data & State Server state vs client cache vs URL state vs local component state. Failure risk: Global stores bloating with stale server data and duplicated entity caches. ### Dependency Rules Category: Governance Unidirectional: Feature → Shared Core; Never Feature A → Feature B internal. Failure risk: Circular imports and tangled dependency graphs that break builds and tests. ### Shared Code Strategy Category: Governance Only truly generic utilities belong in shared; domain logic stays in features. Failure risk: Bloated utils/helpers.ts dumping ground containing thousands of lines. ### Authentication & Authz Category: Governance Verified identity, operation-specific permissions, resource scope, and session handling at trusted boundaries. Failure risk: Navigation-only protection, client-supplied authority, or inconsistent resource access checks. ### Error Handling Category: Governance Structured error models, API status mapping, user-facing vs logged details. Failure risk: Silent failures, unhandled promise rejections, or leaked sensitive stack traces. ### Scalability Triggers Category: Execution Requirements, measurements, and revisit conditions for caches, jobs, replicas, or independent services. Failure risk: Adding infrastructure for hypothetical scale or ignoring measured resource contention. ### First Vertical Slice Category: Execution One real outcome through the boundaries it needs, including failures and recovery. Failure risk: Disconnected mocks passing checks while required integrations or trusted behavior remain unverified. ### Implementation Order Category: Execution Dependency-ready implementation order based on the workflow, current system, and acceptance criteria. Failure risk: Expanding foundations or features before proving the contracts and behavior the next slice needs. ### Contract Validation Category: Data & State Runtime validation of untrusted inputs and integration responses where malformed data violates assumptions. Failure risk: Treating static types as runtime validation or accepting unchecked external values. ### Testing Boundaries Category: Execution Appropriate domain, contract, permission, persistence, client, and connected-flow checks with explicit evidence. Failure risk: Equating mocked checks or source inspection with verified browser, database, hosted, or production behavior. ## Decision System vs. Folder Template Choose boundaries from requirements rather than copying a directory tree. ### Why Templates Fail Fixed folder templates can create empty layers, ignore runtime needs and hide ownership or dependency problems. ### How Heuristics Succeed Start from real requirements, keep domain logic independent of UI, expose deliberate public APIs and verify connected workflows. ### Enforceable Boundary Rule Example ```ts import { UserProfileBadge } from "@/features/users"; ``` ## The 6 Architectural Domains Six areas organize the detailed reference guidance. ### 1. System & Runtime Architecture Identify real client, server, worker, command-line, or managed execution boundaries. Keep platform-specific dependencies inside compatible runtimes. ### 2. Feature & Module Encapsulation Group behavior by its owning capability and expose deliberate public entry points. A feature contains only the UI, commands, queries, or state its workflow needs; no fixed set of files or export convention is required. ### 3. Backend & API Boundaries Choose a transport that fits the project. Keep adapters thin, validate untrusted inputs, enforce authorization at trusted operations, and keep privileged persistence access out of client code. ### 4. Data Ownership & Storage Identifies authoritative data owners, cache invalidation, and migration ownership so each domain entity has a deliberate source of truth. ### 5. Dependency & Shared Code Keep dependencies acyclic and ownership explicit. Shared packages do not import applications. Reusable domain capabilities may be shared when real consumers justify them. ### 6. Scalability Triggers Use requirements and measured pressure to decide when caching, jobs, replicas, or service extraction are justified. Name evidence and revisit conditions instead of inventing universal thresholds. ## The Human Review Protocol Review consequential boundary, state and contract changes in proportion to the task. Follow the current request’s authorization and keep unresolved acceptance criteria visible. ### Gate 1: Boundary & Runtime Check Do module and runtime boundaries match actual workflows? Remove unjustified services and layers. ### Gate 2: State & Contract Verification Does each state value have an owner? Verify untrusted input, permissions and resource scope at trusted boundaries. ### Gate 3: Vertical Slice Viability Can one real workflow be exercised across the boundaries it needs before the structure expands? ## Feature completion and architecture evolution Keep three phases: discovery, foundations and a first slice, then incremental delivery. Apply release checks to the actual risks; small changes need no extra paperwork. #### Measurable requirements Record relevant workload, latency, availability, privacy, budget and recovery targets, with an owner and verification method. Mark unknowns. #### Significant decision records Use ADRs or the existing decision log for consequential choices. Record alternatives, consequences and revisit conditions; preserve history when superseding decisions. #### Feature Definition of Done Verify acceptance, permissions, data changes, integrations and dependency boundaries. Record passed, failed, not-run or not-applicable checks with environment and evidence. #### Security and data lifecycle Test affected trust boundaries and denied access, including cross-tenant cases when relevant. Address secrets, retention/deletion and audit events; this is not compliance certification. #### Release and operations For releases, assess CI, configuration, migrations, recovery and smoke checks. Give important failures useful health/error signals and an owner. Separate implemented, tested, deployed and operationally accepted. - [Feature delivery and evolution](https://github.com/KOUSHIKG04/scalable-architecture-skill/blob/main/skills/vaastu/references/feature-delivery.md) - [Security and data lifecycle](https://github.com/KOUSHIKG04/scalable-architecture-skill/blob/main/skills/vaastu/references/security-checklist.md) - [Deployment readiness](https://github.com/KOUSHIKG04/scalable-architecture-skill/blob/main/skills/vaastu/references/deployment-readiness.md) - [Architecture decision record template](https://github.com/KOUSHIKG04/scalable-architecture-skill/blob/main/skills/vaastu/templates/ADR.md) - [Feature specification template](https://github.com/KOUSHIKG04/scalable-architecture-skill/blob/main/skills/vaastu/templates/FEATURE_SPEC.md) ## Agent Configuration Snippets Install for a supported agent and use the skill location reported by the installer. These prompts request relevant architecture guidance without assuming that every agent has the same discovery or configuration behavior. ### Codex For a standard project-local installation, verify .agents/skills/vaastu/SKILL.md. Invoke the installed skill explicitly or ask Codex to read it; automatic matching depends on the skill description and invocation settings. Use $vaastu to inspect this project's requirements and existing architecture. Apply only relevant guidance, preserve behavior outside scope, and verify the affected workflow. ### Claude Code After installation, use the skill path reported by the installer in your prompt or the agent's supported project-instruction mechanism. Read the installed Vaastu SKILL.md and the supporting references relevant to this task. Apply its architecture decisions to the existing stack and project requirements. Preserve current behavior and work within the requested scope. ### Cursor After installation, use the skill path reported by the installer in your prompt or the agent's supported project-instruction mechanism. Read the installed Vaastu SKILL.md and the supporting references relevant to this task. Apply its architecture decisions to the existing stack and project requirements. Preserve current behavior and work within the requested scope. ### Windsurf After installation, use the skill path reported by the installer in your prompt or the agent's supported project-instruction mechanism. Read the installed Vaastu SKILL.md and the supporting references relevant to this task. Apply its architecture decisions to the existing stack and project requirements. Preserve current behavior and work within the requested scope. ### GitHub Copilot After installation, use the skill path reported by the installer in your prompt or the agent's supported project-instruction mechanism. Read the installed Vaastu SKILL.md and the supporting references relevant to this task. Apply its architecture decisions to the existing stack and project requirements. Preserve current behavior and work within the requested scope. ## Agent discovery, reading, and use Public documentation helps an agent understand Vaastu when it retrieves the site or repository. Finding the skill, recommending it, installing it, and selecting it for a task are separate steps. ### Finding and recommending the skill An agent with web search or a skill-directory tool may find Vaastu for a relevant request. Inclusion depends on that agent's tools, retrieval sources, and the task. SEO, structured data, and crawler access do not guarantee a recommendation. ### Reading the public documentation The Markdown pages, documentation index, and combined text expose the same public guidance in text form. Agents can use these endpoints when their tools support them; no universal requirement makes every coding agent read llms.txt or ai.txt. ### Using an installed skill Install the skill through a supported workflow, verify its reported location, and ask the agent to read SKILL.md. Automatic selection depends on the host's discovery and invocation rules. Reading a webpage alone does not install the skill or grant it authority over project instructions. - [Documentation as Markdown](/docs.md) - [Agent documentation index](/llms.txt) - [Combined public documentation](/llms-full.txt) - [Installation guide](/guides/install-architecture-skill) --- # Use Vaastu in your project Canonical page: https://get-vaastu.vercel.app/guides Use these AI skill guides to plan software architecture, organize frontend features, design backend APIs, connect a full-stack workflow, or review and fix an existing project's architecture. Start with the guide for your actual task and keep your current stack. ## [Plan Frontend and Backend Architecture with AI](https://get-vaastu.vercel.app/guides/frontend-backend-architecture) Plan full-stack architecture with an AI coding agent: define frontend and backend ownership, API contracts, trusted operations, and one verified user workflow. ## [Install an Architecture Skill for AI Coding Agents](https://get-vaastu.vercel.app/guides/install-architecture-skill) Install Vaastu for Codex, Claude Code, Cursor, or another Markdown-reading coding agent. Load the AI skill and request an architecture review or scoped change. ## [Scalable TypeScript Monorepo Architecture with AI](https://get-vaastu.vercel.app/guides/scalable-typescript-monorepo) A worked architecture exercise: turn web and operations requirements into application boundaries, shared contracts, and one verified vertical slice. ## [Review and Fix Architecture with an AI Coding Agent](https://get-vaastu.vercel.app/guides/review-existing-architecture) Review software architecture and repair AI-generated code with Vaastu. Find dependency, state, and ownership problems, then verify a scoped refactor. ## [Frontend Architecture: Features and State Ownership](https://get-vaastu.vercel.app/guides/frontend-architecture) Use Vaastu's frontend architecture skill to organize features, components, state, forms, and data fetching with an AI agent. Verify the affected interactions. ## [Backend Architecture: APIs, Data, and Authorization](https://get-vaastu.vercel.app/guides/backend-architecture) Use Vaastu's backend architecture skill to plan APIs, authorization, domain rules, database operations, retries, and concurrency with your AI coding agent. --- # Plan Frontend and Backend Architecture with AI Canonical page: https://get-vaastu.vercel.app/guides/frontend-backend-architecture Plan full-stack architecture with an AI coding agent: define frontend and backend ownership, API contracts, trusted operations, and one verified user workflow. ## Start with a workflow, not a framework template Vaastu is a software architecture skill for AI coding agents. It helps an agent decide who owns behavior, where data is trusted, and which dependencies are allowed. The same reasoning applies to frontend-only tools, backend APIs, full-stack applications, and systems with several clients. Begin with one user outcome and the existing repository. Record the actor, input, expected result, data owner, permissions, and failure cases. Preserve the current stack unless a requirement justifies changing it. A static page may need no backend; a full-stack framework may host both UI and trusted operations in one application. ## Separate responsibilities without forcing separate services The frontend owns presentation, interaction, form feedback, and local state. Its loader or query owner manages fetched data and reconciliation. Trusted backend operations own authorization, authoritative business rules, and writes that require protected access. These boundaries describe responsibilities, not a required directory tree. Keep a small operation and its queries together when that is clear. Introduce another application, shared package, or independently deployed service only for a concrete consumer, runtime, security, or operational need. ## Define what crosses the boundary For a connected workflow, agree on input shape, authoritative response fields, stable errors, resource scope, and retry behavior. Static types help developers but do not validate untrusted runtime input. Client validation improves feedback; the trusted operation still enforces permissions and invariants. Consider an illustrative order flow. The client submits item identifiers and quantities. The backend verifies the actor and resource scope, determines authoritative prices, and commits the required records atomically. The UI uses the confirmed result rather than declaring success before persistence. This is a design example, not a claim that an order system has been built or tested. ## Give your agent a concrete architecture request Install Vaastu in the project and provide the actual workflow, constraints, and acceptance criteria. This proposal-only prompt preserves the current technology choices while making the frontend, backend, and integration decisions explicit. ```text Read .agents/skills/vaastu/SKILL.md and inspect this repository. Design the architecture for the workflow described below using the current stack. Identify feature ownership, UI and server state, trusted operations, input/output contracts, authorization, persistence, errors, and retry behavior where applicable. Justify every proposed application, package, service, and layer. Keep the simplest structure that meets the requirements. Preserve existing routes, behavior, data, and permissions. Propose one connected implementation slice and its acceptance checks. Do not modify project files yet. Workflow: [describe the real user outcome] Constraints: [current stack, deployment, data, and permissions] Acceptance criteria: [observable success and failure behavior] ``` ## Verify success, failure, and recovery Once implementation is authorized, connect only the boundaries that the workflow uses. Exercise valid input, invalid input, denied access, and integration failures. For mutations where duplicates matter, define how a retry after a lost response recovers the original result. Check ownership and dependency direction alongside behavior. For frontend changes, inspect relevant viewport, keyboard, loading, empty, and error states. For backend changes, verify transactions, permissions, and concurrency against representative persistence when affected. Report source review, mocked tests, connected execution, and deployment as separate evidence. ## Apply the same decisions as the system grows A second client may justify a portable shared contract, while its screens and session integration stay app-owned. A slow or retryable operation may justify a worker. Neither change requires rebuilding every feature around a new template. Revisit architecture when requirements, measured load, failures, or team ownership change. Vaastu supplies the decision framework; framework-specific documentation supplies the implementation APIs. Use the relevant references instead of assuming one stack's conventions apply everywhere. ## Turn system design into a reviewable architecture plan For a system design request, ask the agent to connect requirements to a concrete request and data flow. Name the actors, application owners, API contracts, storage boundaries, and failure recovery. A short diagram can help explain which component calls which operation and where authoritative data changes. Record the reason for each significant architecture decision, the alternatives considered, and the condition that would justify revisiting it. A modular design should make the next feature easier to change while keeping dependencies understandable. Verify that claim against the actual workflow rather than judging the plan by its number of services or folders. ## References - [Vaastu frontend architecture guide](https://github.com/KOUSHIKG04/scalable-architecture-skill/blob/main/skills/vaastu/references/frontend-architecture.md) - [Vaastu backend architecture guide](https://github.com/KOUSHIKG04/scalable-architecture-skill/blob/main/skills/vaastu/references/backend-architecture.md) - [Vaastu integration guide](https://github.com/KOUSHIKG04/scalable-architecture-skill/blob/main/skills/vaastu/references/frontend-backend-integration.md) ## Related architecture guides - [Frontend Architecture: Features and State Ownership](https://get-vaastu.vercel.app/guides/frontend-architecture) - [Backend Architecture: APIs, Data, and Authorization](https://get-vaastu.vercel.app/guides/backend-architecture) [Architecture protocol](https://get-vaastu.vercel.app/docs) [Source repository](https://github.com/KOUSHIKG04/scalable-architecture-skill) --- # Install an Architecture Skill for AI Coding Agents Canonical page: https://get-vaastu.vercel.app/guides/install-architecture-skill Install Vaastu for Codex, Claude Code, Cursor, or another Markdown-reading coding agent. Load the AI skill and request an architecture review or scoped change. ## Understand what the skill adds Vaastu is an open-source architecture decision framework distributed as Markdown instructions and supporting resources. It helps an AI coding agent reason about ownership, dependencies, trust boundaries, state, persistence, and verification. It does not replace your application framework or install a backend runtime. Use it with an agent that can read project files, such as Codex, Claude Code, or Cursor. The CLI can install skills for supported agents; automatic discovery varies by agent and configuration. When native skill discovery is unavailable, give the agent SKILL.md and the relevant references directly. ## Install from the project you want to work on Open a terminal in your project's root and run one of the commands below. Select the agent and installation options when prompted. Check the Skills CLI's current runtime requirements if installation fails; this is separate from the runtime required by your own project. A project-local installation scopes the skill to that project. In a standard Codex project installation, the entry point is .agents/skills/vaastu/SKILL.md. For other agents or installation options, use the location reported by the installer rather than assuming every agent has the same directory. ### npm ```sh npx skills add KOUSHIKG04/scalable-architecture-skill --skill vaastu ``` ### pnpm ```sh pnpm dlx skills add KOUSHIKG04/scalable-architecture-skill --skill vaastu ``` ### bun ```sh bunx skills add KOUSHIKG04/scalable-architecture-skill --skill vaastu ``` ### yarn ```sh yarn dlx skills add KOUSHIKG04/scalable-architecture-skill --skill vaastu ``` Yarn requires version 2 or later for yarn dlx. With Yarn Classic (1.x), use the npm / npx command. ## Check the installed instructions before using them Confirm that the reported SKILL.md exists and that its linked resources are available. Ask the agent to read the entry point and only the supporting guides relevant to the task. Installing the skill does not prove that the agent loaded it automatically. Keep project requirements and local repository instructions available alongside the skill. The skill should adapt to established conventions rather than generating a fixed monorepo, database, or service hierarchy. Review local skill edits before updating an installation. ## Use a short request for a focused task For a small change, name the user outcome, constraints, and acceptance criteria. The following request is a reusable starting point; replace the bracketed details before running it. It authorizes the stated implementation without turning a focused task into a full-system redesign. ```text Read the installed Vaastu SKILL.md and inspect this repository. Implement [specific user outcome] using the existing stack and conventions. Preserve [routes, contracts, data, permissions, and behavior that must remain]. Acceptance criteria: [observable behavior and relevant failure cases]. State a brief plan, make the scoped change, and run appropriate checks. Report what passed, what failed, and what was not exercised. ``` ## Choose a proposal when architecture needs review For a substantial new system or boundary change, provide requirements and ask for an architecture proposal first. The proposal should explain the responsibility of each application, feature, package, or service, plus critical request/data flows and verification. If you want implementation too, say so explicitly and define its scope. Prove one complete workflow before expanding. A frontend-only app, backend-only service, and full-stack application can all use the same decision process without adopting each other's unnecessary layers. ## Judge the result by behavior and evidence Check that the agent preserved existing behavior and justified new structure with real requirements. Run the project's relevant type, lint, build, behavior, contract, and dependency checks. Browser, device, database, and hosted behavior need their own evidence where applicable. A useful architecture skill supports decisions; installation counts, tidy folders, and passing import checks do not establish production correctness. Keep missing integrations and unexecuted acceptance cases visible in the handoff. ## References - [Skills CLI installation and supported agents](https://github.com/vercel-labs/skills) - [Vaastu skill source](https://github.com/KOUSHIKG04/scalable-architecture-skill/tree/main/skills/vaastu) ## Related architecture guides - [Plan Frontend and Backend Architecture with AI](https://get-vaastu.vercel.app/guides/frontend-backend-architecture) - [Review and Fix Architecture with an AI Coding Agent](https://get-vaastu.vercel.app/guides/review-existing-architecture) [Architecture protocol](https://get-vaastu.vercel.app/docs) [Source repository](https://github.com/KOUSHIKG04/scalable-architecture-skill) --- # Scalable TypeScript Monorepo Architecture with AI Canonical page: https://get-vaastu.vercel.app/guides/scalable-typescript-monorepo A worked architecture exercise: turn web and operations requirements into application boundaries, shared contracts, and one verified vertical slice. ## Begin with requirements This is an illustrative design exercise, not a production benchmark or a customer case study. Assume a product needs a customer web app and a separate operations console, both using the same order workflow. The operations team has different permissions and may deploy its console independently. Ask the agent to read SKILL.md and your requirements before creating files. Record the user roles, workflows, deployment constraints, data owners, and expected load. If a single application meets those constraints, keep it; a monorepo is a decision to justify. ## Choose boundaries with a reason In this example, apps/web owns the customer experience and apps/operations owns internal workflows. Neither application imports the other application’s source. A shared contracts package owns runtime request and response schemas that both consumers actually need. Order rules belong to the owning feature on the trusted backend. UI code calls a public contract instead of querying the database directly. Extract shared UI only when it has real consumers and compatible platform requirements. Avoid creating empty packages for hypothetical future clients. ## Request a reviewable proposal Prompt: Read .agents/skills/vaastu/SKILL.md and REQUIREMENTS.md. Inspect this repository. Propose the simplest topology that supports the customer and operations workflows. Explain every application and package, allowed dependencies, authorization boundaries, state ownership, persistence, deployment, and verification. Do not implement yet. Review why each deployment boundary exists, who may mutate an order, where authorization is enforced, and which package owns the request schema. Remove abstractions with no concrete requirement before scaffolding. ## Prove one order workflow Implement one path: the authorized customer submits an order, the backend validates input and permissions, the owning feature applies its rules, persistence commits the change, and the UI receives a typed result. Include a denied-request case and an invalid-payload case. Run relevant typechecks, contract and integration tests, and dependency checks. Confirm that shared packages do not import applications and that the operations app cannot bypass trusted authorization. Report untested deployment or device behavior separately. ## Scale from observed pressure Write down the signals that would justify change: request latency, queueing delay, database contention, throughput, and team ownership conflicts. Set thresholds from your actual workload rather than copying universal numbers. Add a worker for measured asynchronous work or extract a service for a concrete isolation need. Revisit boundaries after measuring the first slice. The goal is a system that can evolve with evidence. ## Related architecture guides - [Review and Fix Architecture with an AI Coding Agent](https://get-vaastu.vercel.app/guides/review-existing-architecture) - [Plan Frontend and Backend Architecture with AI](https://get-vaastu.vercel.app/guides/frontend-backend-architecture) [Architecture protocol](https://get-vaastu.vercel.app/docs) [Source repository](https://github.com/KOUSHIKG04/scalable-architecture-skill) --- # Review and Fix Architecture with an AI Coding Agent Canonical page: https://get-vaastu.vercel.app/guides/review-existing-architecture Review software architecture and repair AI-generated code with Vaastu. Find dependency, state, and ownership problems, then verify a scoped refactor. ## Is there an AI skill that helps fix software architecture? Vaastu is an AI coding skill for architecture planning, codebase review, and scoped repair. It gives the agent a way to inspect feature boundaries, dependency direction, state ownership, API contracts, and trusted operations. Use it with your current repository and stack, including projects built with AI assistance. The skill is a set of instructions and reference material. Your coding agent reads the code and makes authorized changes. Begin with a review that identifies concrete files, the affected workflow, and the consequence of each finding. A large folder tree or a preferred pattern alone is not evidence that a refactor is needed. ## Untangle coupled code with a scoped repair Use Vaastu's codebase-untangling reference to apply its architecture principles to a concrete workflow. Record inputs, actor permissions, affected data, expected results, and relevant failure behavior. Follow the operation through feature behavior, state ownership, trusted access, persistence, and its consumers. These are responsibilities to locate in the existing code, not a required set of layers. Consider an illustrative browser-local expense tracker whose list, detail editor, and summary each keep their own copy of saved records. An edit updates one copy while the total remains stale. A scoped repair can make one app-owned store authoritative, use its existing save operation, and derive the summary from confirmed records. Keep unsaved input local and preserve identifiers, storage format, and navigation. This example needs no backend or workspace package. For the actual project, document the misplaced responsibility with file evidence, identify its owner, and propose the smallest repair with acceptance checks. Verify the original consumers, dependency rules, and relevant success and failure behavior. Record significant decisions with alternatives and revisit conditions. Stop at the agreed acceptance criteria and report environment limits or remaining blockers. ```text Read the installed Vaastu SKILL.md and references/codebase-untangling.md. Review [workflow] using this project's existing stack. Do not change files yet. Trace input, feature behavior, state ownership, trusted access, persistence, and the result consumed by the UI or caller, where applicable. For each boundary problem, give file evidence, the affected behavior, the owning module, and the smallest repair with acceptance checks. Preserve routes, contracts, data, permissions, drafts, and lifecycle cleanup. Record significant ownership decisions and distinguish verified facts from unknowns. ``` ## Map the current system This is a repeatable review workflow, not a claim that a specific project has passed an audit. Install Vaastu, then ask your agent to inspect the actual repository and its existing conventions. Identify applications, runtimes, transport adapters, features, shared packages, persistence, and external integrations. Follow one real request from UI input through validation, authorization, domain behavior, storage, and the resulting UI state. Record file evidence for each finding. ## Ask for findings before changes Prompt: Read .agents/skills/vaastu/SKILL.md. Review this repository without modifying application files. Trace one critical workflow and assess ownership, allowed dependencies, state, runtime validation, authorization, persistence, and scalability constraints. For each finding, provide file evidence, impact, uncertainty, and a minimal corrective step. Separate confirmed source findings from questions that need runtime or hosted verification. A folder name alone is not evidence of a broken boundary. A starter import checker cannot establish security or production correctness. ## Prioritize by behavior and risk Start with findings that affect real workflows: a privileged operation exposed to a client, an application importing another application’s internals, duplicate sources of truth, or an unvalidated external payload. Tie each proposed change to the observed problem. Do not reorganize the whole repository to match an example. Prefer a small change with a clear owner and a verification path. Document existing failures separately so they are not mistaken for regressions. ## Plan a staged migration Choose one vertical slice. Move its behavior behind the owning feature’s public API, keep route URLs and request contracts stable, and migrate callers deliberately. Preserve user data, permissions, subscription cleanup, and in-progress state. For example, replace a cross-feature import of private order state with a deliberate public query or command. Keep the observable behavior the same and check both callers before expanding the change. ## Repair architecture in AI-generated code one workflow at a time An AI-built project can accumulate repeated API calls, business rules in screens, shared folders that import application internals, or several copies of the same server state. Trace the behavior first: which file owns the rule, who calls it, what state is authoritative, and what breaks when it changes? These are review questions, not findings about every AI-generated project. Consider an illustrative checkout screen that calculates the final price and writes directly to protected order records. A scoped repair moves authoritative pricing and the permitted write into the existing trusted backend operation. The screen keeps form feedback and renders the confirmed result. Preserve the request contract where possible, and verify invalid quantities, denied access, and a failed write before expanding the refactor. For a frontend-only tool, the repair may simply consolidate duplicated state or move a component into its owning feature. A better architecture does not always require a backend, more packages, or microservices. Choose the smallest change that addresses the observed problem. ```text Read the installed Vaastu SKILL.md and inspect this repository. Help fix the architecture of [specific workflow] using the existing stack. First report file-level evidence for misplaced responsibilities, duplicate state, invalid dependencies, or missing trust boundaries. Propose the smallest repair and its acceptance checks. Wait for approval before changing files. Preserve routes, API contracts, user data, permissions, and unrelated behavior. After approval, implement one slice and report verified results and unrun checks. ``` ## Verify the result and record the limits Run focused behavior and contract tests along with typechecks and dependency checks appropriate to the change. Exercise the critical workflow, including denied access and failure recovery where relevant. Report what passed, what failed, and what was not exercised. Source review does not replace deployment checks, representative load tests, or a dedicated security assessment. Use those gaps to define the next verification step. ## Related architecture guides - [Install an Architecture Skill for AI Coding Agents](https://get-vaastu.vercel.app/guides/install-architecture-skill) - [Scalable TypeScript Monorepo Architecture with AI](https://get-vaastu.vercel.app/guides/scalable-typescript-monorepo) [Architecture protocol](https://get-vaastu.vercel.app/docs) [Source repository](https://github.com/KOUSHIKG04/scalable-architecture-skill) --- # Frontend Architecture: Features and State Ownership Canonical page: https://get-vaastu.vercel.app/guides/frontend-architecture Use Vaastu's frontend architecture skill to organize features, components, state, forms, and data fetching with an AI agent. Verify the affected interactions. ## Choose the frontend problem to solve Use Vaastu when a frontend workflow has unclear ownership, duplicated state, tangled imports, or a change that crosses feature boundaries. Describe the actual user outcome and preserve the existing design system, routes, and framework conventions. This walkthrough uses a searchable record list as an illustrative example. Users filter records, open a detail view, edit an allowed field, and return to their results. The architecture should preserve the filter and navigation history while keeping edits and fetched data consistent. It is not a claim that this example has been implemented or tested. ## Keep behavior with its feature Let the records feature own the list, detail interaction, filter interpretation, and mutation behavior. The route composes that feature and adapts navigation parameters. Shared UI primitives can render inputs and dialogs without owning record-specific rules. Extract a component or hook when it has a coherent responsibility, lifecycle, or real consumer. Do not move every component into a global folder or create a shared package merely because another page might use it someday. Public feature entry points should make supported dependencies clear. ## Decide what survives navigation For shareable web results, filters and sorting can belong in URL state. The established loader or query cache owns fetched records. The editing form owns unsaved values, while focus and dialog visibility stay near the interaction that controls them. Define back/forward navigation and invalid filter behavior. A slow search response must not overwrite a newer query. Do not copy the result list into another global store just to make it accessible to unrelated components. If offline drafts are required, name their persistence, expiry, and account-change behavior explicitly. ## Reconcile edits without losing the user's work Keep client feedback separate from authoritative validation and permission enforcement. Preserve entered values after a recoverable rejection and associate recognized field errors with their inputs. Update or revalidate affected detail, list, and aggregate data through the existing data owner. If a changed record no longer matches the active filter, decide whether it disappears from the current result and how the user learns that the save succeeded. For optimistic changes, define rollback and reconciliation. For an unknown result after a lost response, use the operation's recovery contract before submitting another mutation. ## Organize frontend components and modules around features For frontend project structure, keep a feature's components, form rules, and interaction logic close to the feature that owns them. Keep route files focused on routing and composition. A reusable visual primitive can live in the design system; a component coupled to one feature's permissions or data shape usually stays with that feature. Before extracting a shared module, identify its consumers and intended public API. Check that shared code does not import application internals and that moving it will not create circular dependencies. This makes code organization an ownership decision with observable consequences instead of a folder naming exercise. ## Ask your coding agent for a scoped frontend change Use the installed skill and the actual record workflow in your project. This prompt focuses the agent on frontend architecture without requiring a backend rewrite. ```text Read the installed Vaastu SKILL.md and its frontend architecture guidance. Inspect this repository's routing, UI components, data loading, and state conventions. Implement [frontend workflow] using the existing stack and visual system. Define the owners of URL state, fetched data, form values, and local interaction state. Preserve navigation, permissions, current contracts, and unrelated behavior. Acceptance criteria: [success, empty, loading, error, keyboard, and viewport behavior]. Check stale responses, mutation reconciliation, and account changes where affected. State a brief plan, implement within scope, and report the verification evidence. ``` ## Verify interaction and architecture together Exercise loading, empty results, invalid filters, server field errors, background refresh, and successful edits. Check that navigation restores the intended result state and obsolete requests cannot replace current data. If identity changes, old results and drafts must not appear under the new account. Inspect keyboard flow, focus recovery, labels, readable errors, narrow widths, and large text in the target runtime. Measure performance against the reported issue before adding memoization, virtualization, or another data library. Record browser/device checks separately from source inspection and mocked interaction tests. ## References - [Vaastu frontend reference](https://github.com/KOUSHIKG04/scalable-architecture-skill/blob/main/skills/vaastu/references/frontend-architecture.md) - [Connect frontend and backend responsibilities](/guides/frontend-backend-architecture) - [Install the architecture skill](/guides/install-architecture-skill) ## Related architecture guides - [Plan Frontend and Backend Architecture with AI](https://get-vaastu.vercel.app/guides/frontend-backend-architecture) - [Review and Fix Architecture with an AI Coding Agent](https://get-vaastu.vercel.app/guides/review-existing-architecture) [Architecture protocol](https://get-vaastu.vercel.app/docs) [Source repository](https://github.com/KOUSHIKG04/scalable-architecture-skill) --- # Backend Architecture: APIs, Data, and Authorization Canonical page: https://get-vaastu.vercel.app/guides/backend-architecture Use Vaastu's backend architecture skill to plan APIs, authorization, domain rules, database operations, retries, and concurrency with your AI coding agent. ## Start with one trusted operation Use Vaastu for a backend architecture decision when ownership, authorization, data consistency, or recovery is unclear. Keep the existing language, framework, transport, and persistence unless a concrete requirement justifies changing them. A backend-only service does not need a frontend or a monorepo to use the skill. Consider an illustrative resource update: an authenticated actor changes an allowed field on a record within their authorized scope. Two actors may edit concurrently, and a request may be retried after its response is lost. Specify the intended behavior before adding layers. This is a design exercise, not a verified service. ## Keep adapters thin and operations coherent The transport adapter parses the request, obtains verified identity, invokes the owning feature operation, and maps the result. The operation enforces resource access and business rules. Scoped queries and writes remain owned by the feature or a justified persistence capability. These are responsibilities rather than mandatory controller, service, and repository files. Separate complex rules for independent testing or isolate an external provider behind an adapter when that clarifies behavior. Keep lower-level modules independent of routes and avoid a generic abstraction for every table. ## Protect the resource rather than only the route Validate runtime input and use verified identity. A supplied actor ID, tenant, role, or owner field is not authority. Scope both reads and writes to the permitted resource and explicitly choose which fields may change. Test a permitted update alongside another user's known record ID, a different tenant where relevant, missing identity, malformed values, and protected-field edits. Stable errors should support callers without exposing database exceptions or private resource details. ## Make the update correct under concurrency Choose the domain policy for competing edits: a version precondition, conditional write, lock, or other database-supported mechanism. A read followed by a write inside one application function does not automatically prevent a race. Use transactions and constraints for changes that must succeed or fail together. Where a repeated operation could create another consequential effect, define durable idempotency scoped to the actor, resource, and operation. Bind the key to a payload fingerprint and retain the result for the supported retry window. Matching retries recover the original outcome; a different payload using the same key conflicts. ## Define failures before promising external work Give provider calls bounded timeouts and retries consistent with their semantics. A database transaction generally cannot roll back a remote side effect. If committed data must reliably trigger downstream work, define an atomic handoff or explicit reconciliation and compensation. Add a worker only when independent execution or recovery is required. Document delivery semantics, duplicate processing, retry limits, failure ownership, and authorization context. Use the existing logging and health setup to make a representative failure diagnosable without exposing secrets. ## Choose between a modular monolith and microservices A modular monolith can keep backend features in one deployment while giving each feature explicit ownership and public operations. Separate API handlers, business rules, and persistence responsibilities where the operation benefits from that separation. Clean architecture does not require every request to pass through an identical stack of interfaces. Consider microservices when independent deployment, team ownership, runtime isolation, or measured load creates a concrete need. Define the new service's contracts, authorization context, timeouts, and recovery before extracting it. Compare that cost with keeping a clear module boundary in the existing application, and verify the affected cross-service workflow if extraction proceeds. ## Give your coding agent a backend acceptance contract Replace the placeholders with the real operation, permissions, invariant, and expected conflict behavior. This prompt authorizes a scoped implementation, not an infrastructure migration. ```text Read the installed Vaastu SKILL.md and its backend architecture guidance. Inspect the existing transport, authentication, feature ownership, and persistence. Implement [trusted operation] with the current stack. Actor/resource access: [who may do what to which records]. Domain invariant: [condition that must remain true]. Concurrency and retry policy: [expected conflict and duplicate behavior]. Keep adapters thin and add layers only for concrete responsibilities. Verify permitted, malformed, denied, concurrent, and partial-failure cases as applicable. Preserve existing contracts and unrelated behavior; report environment and unrun checks. ``` ## Verify persistence and trust boundaries directly Use focused tests for complex domain rules, adapter integration tests for validation and errors, and representative database tests for constraints, permissions, transactions, and concurrent updates. Simulate a committed operation whose response is lost when the retry contract matters. Separate source review, mocked behavior, real persistence checks, hosted settings, and operational acceptance. For release work, verify migration compatibility and recovery with the project's deployment process. Tidy modules and passing import checks alone do not establish production correctness. ## References - [Vaastu backend reference](https://github.com/KOUSHIKG04/scalable-architecture-skill/blob/main/skills/vaastu/references/backend-architecture.md) - [Vaastu integration reference](https://github.com/KOUSHIKG04/scalable-architecture-skill/blob/main/skills/vaastu/references/frontend-backend-integration.md) - [Connect backend and client responsibilities](/guides/frontend-backend-architecture) ## Related architecture guides - [Plan Frontend and Backend Architecture with AI](https://get-vaastu.vercel.app/guides/frontend-backend-architecture) - [Review and Fix Architecture with an AI Coding Agent](https://get-vaastu.vercel.app/guides/review-existing-architecture) [Architecture protocol](https://get-vaastu.vercel.app/docs) [Source repository](https://github.com/KOUSHIKG04/scalable-architecture-skill)