Skip to content

/schema

Design or update your multi-tenant database schema.


Usage

/schema

Or with specific entities:

/schema

Design a schema for:
- Projects (name, description, status)
- Tasks (title, priority, assigned_to)

What It Does

The /schema command invokes the schema-architect skill to:

  1. Analyze Requirements
  2. Reviews discovery document (if exists)
  3. Reviews Gherkin scenarios (if exists)
  4. Identifies entities and relationships

  5. Design Multi-Tenant Schema

  6. Organization as tenant root
  7. Row-level data isolation
  8. Proper foreign key relationships
  9. Indexes for query performance

  10. Generate Artifacts

  11. backend/.apsorc - Schema definition
  12. docs/plans/schema-design.md - Documentation
  13. Entity relationship diagram (Mermaid)

Output Example

.apsorc

{
  "name": "my-saas",
  "entities": [
    {
      "name": "Project",
      "fields": [
        { "name": "name", "type": "string", "required": true },
        { "name": "description", "type": "text" },
        { "name": "status", "type": "enum", "values": ["active", "archived"] }
      ],
      "relationships": [
        { "type": "belongsTo", "entity": "Organization" },
        { "type": "hasMany", "entity": "Task" }
      ]
    }
  ]
}

ERD Diagram

erDiagram
    Organization ||--o{ Project : has
    Project ||--o{ Task : contains
    User ||--o{ Task : assigned

Prerequisites

For best results, have:

  • Discovery document (docs/discovery/discovery-notes.md)
  • OR Gherkin scenarios (docs/scenarios/*.feature)
  • OR clear entity descriptions

Multi-Tenancy

All entities automatically include:

  • organizationId - Foreign key to Organization
  • Row-level isolation enforced
  • Queries scoped to current organization

After Schema

Next steps:

  1. Review schema - Verify entities match requirements
  2. Run /tests - Generate test scenarios
  3. Run /plan - Create technical plan
  4. Bootstrap backend - Use orchestrator or backend-bootstrapper

See Also