|
1 | | -# Primitive-First Architecture |
| 1 | +# Primitive-First Architecture (Enforced) |
2 | 2 |
|
3 | | -Use this skill BEFORE proposing any infrastructure, deployment, or platform-level architecture for Floom. |
| 3 | +**ZERO TOLERANCE.** You may not write, modify, or propose any infrastructure, deployment, networking, containerization, or platform code until this skill is fully satisfied. "Infrastructure" includes: Dockerfiles, docker-compose, K8s YAML, Terraform, Pulumi, CI/CD beyond basic GitHub Actions, self-hosted queues, custom API gateways, and hand-rolled OpenAPI specs. |
4 | 4 |
|
5 | | -## Rule |
| 5 | +## Phase 1: Mandatory Stack Archaeology (Cannot Skip) |
6 | 6 |
|
7 | | -You may NOT propose custom infrastructure (Dockerfiles, container orchestration, API gateways, hand-rolled OpenAPI specs, self-hosted runners) until you have completed the three-step lock below. |
| 7 | +Read and cite the following files in THIS repository: |
| 8 | +- `package.json`, `requirements.txt`, `Cargo.toml`, `go.mod`, or equivalent dependency manifests |
| 9 | +- `README.md` |
| 10 | +- Any existing `docker*`, `infra/`, `deploy*`, `terraform*`, `pulumi*` files or directories |
| 11 | +- `CLAUDE.md` or `AGENTS.md` if present |
| 12 | +- Any existing `.decisions/` or `adr/` files |
8 | 13 |
|
9 | | -## The Lock |
| 14 | +Output a bullet list of: |
| 15 | +- Current runtime/framework versions |
| 16 | +- Existing deployment platform |
| 17 | +- Current database/cache/message queue |
| 18 | +- Any existing managed services already in use |
10 | 19 |
|
11 | | -### 1. State the Core Primitive |
12 | | -Write one sentence describing what we actually need to do, without implementation details. |
| 20 | +If these files do not exist, state EXPLICITLY: "No [file] found." |
13 | 21 |
|
14 | | -- ❌ Wrong: "We need a FastAPI service in Docker on Modal." |
15 | | -- ✅ Right: "We need to safely execute untrusted user code and return stdout/artifacts." |
| 22 | +## Phase 2: Core Primitive Declaration |
16 | 23 |
|
17 | | -### 2. Search for SaaS/API Solutions |
18 | | -Search the web or your knowledge for managed services that solve this exact primitive. You must list at least 3 candidates with a one-line verdict. |
| 24 | +State the primitive in exactly this format: |
19 | 25 |
|
20 | | -Examples for common Floom primitives: |
21 | | -- **Sandboxed code execution**: e2b, CodeSandbox API, Replit API, GitHub Codespaces API |
22 | | -- **Background jobs**: Inngest, Trigger.dev, QStash, Temporal Cloud |
23 | | -- **Serverless functions**: Vercel Functions, Netlify Functions, Cloudflare Workers |
24 | | -- **Managed databases**: Supabase, Neon, PlanetScale, Upstash |
25 | | -- **File storage**: UploadThing, Cloudflare R2, S3 (only if egress matters) |
| 26 | +**Primitive:** [One sentence. No brand names. No implementation details.] |
26 | 27 |
|
27 | | -### 3. Rejection Justification |
28 | | -If you want to build custom infrastructure instead of using a managed service, you must provide a specific, falsifiable reason: |
| 28 | +Examples: |
| 29 | +- ❌ "We need a Docker container running FastAPI with Celery." |
| 30 | +- ✅ "We need to accept arbitrary Python code from users, run it in a sandbox, and return stdout plus any generated files." |
| 31 | +- ❌ "We need a Kubernetes cluster with RabbitMQ." |
| 32 | +- ✅ "We need to enqueue background jobs reliably and retry them if they fail." |
29 | 33 |
|
30 | | -- "e2b's max timeout is 5 minutes, we need 30." → OK |
31 | | -- "At our scale, self-hosted costs $X vs service costs $Y." → OK |
32 | | -- "We need it." → NOT OK |
33 | | -- "For flexibility." → NOT OK |
34 | | -- "We might need X later." → NOT OK |
| 34 | +## Phase 3: Mandated Web Research (Anti-Hallucination Lock) |
35 | 35 |
|
36 | | -If you cannot write a specific rejection, you MUST use the managed service. |
| 36 | +You MUST use web search (`SearchWeb`) or fetch a real URL (`FetchURL`) to find current (2024–2025) managed services for this primitive. |
37 | 37 |
|
38 | | -## Examples of Past Mistakes |
| 38 | +Requirements: |
| 39 | +- List minimum 3 candidates |
| 40 | +- Provide a real, working URL for each (not a hallucinated one) |
| 41 | +- State pricing model and one hard limit (timeout, concurrency, file size, region availability, etc.) |
| 42 | +- If the primitive involves **running user code, sandboxes, or untrusted code execution**: **e2b.dev MUST be the first candidate evaluated.** You are not allowed to omit it. |
39 | 43 |
|
40 | | -The following were proposed by agents and were wrong. Do not repeat them: |
| 44 | +If you cannot fetch or search a real URL, you have NOT completed this phase. Do not proceed. |
41 | 45 |
|
42 | | -| Bad Proposal | Why It Was Wrong | What We Should Have Used | |
| 46 | +## Phase 4: The Default Rule |
| 47 | + |
| 48 | +**Managed service is the DEFAULT. Custom infrastructure is the EXCEPTION.** |
| 49 | + |
| 50 | +You may only propose custom infrastructure if ALL of the following are true: |
| 51 | +1. You have a specific, falsifiable rejection for EACH managed service candidate (not generic "doesn't fit our needs") |
| 52 | +2. You have compared costs at Floom's current/expected scale (cite actual numbers, not guesses) |
| 53 | +3. You have checked the managed service's documentation and confirmed it lacks a required feature (cite the doc URL) |
| 54 | + |
| 55 | +**Banned justifications (will be rejected):** |
| 56 | +- "We need more control." |
| 57 | +- "For future flexibility." |
| 58 | +- "We might scale to X." |
| 59 | +- "It's cheaper at scale." (without actual numbers) |
| 60 | +- "We want to avoid vendor lock-in." (for an MVP or early-stage feature) |
| 61 | +- "It's simple to self-host." (it is never simple) |
| 62 | + |
| 63 | +## Phase 5: Hard Stop Gate |
| 64 | + |
| 65 | +If you are proposing ANY custom infrastructure after Phase 4, you MUST stop and output exactly: |
| 66 | + |
| 67 | +``` |
| 68 | +🚨 CUSTOM INFRASTRUCTURE PROPOSED 🚨 |
| 69 | +
|
| 70 | +Primitive: [from Phase 2] |
| 71 | +Rejected Services: [from Phase 3 with SPECIFIC feature/cost/limit reasons] |
| 72 | +Justification: [from Phase 4] |
| 73 | +Cost Comparison: [actual numbers, not guesses] |
| 74 | +
|
| 75 | +AWAITING USER APPROVAL. DO NOT PROCEED WITH IMPLEMENTATION. |
| 76 | +``` |
| 77 | + |
| 78 | +**You are FORBIDDEN from writing implementation code** (Dockerfiles, YAML, configs, scripts) until the user explicitly approves in writing. |
| 79 | + |
| 80 | +## Phase 6: Decision Record |
| 81 | + |
| 82 | +Regardless of outcome, create a decision record so the next agent doesn't re-research the same question. |
| 83 | + |
| 84 | +- If custom infrastructure is approved: create `.decisions/ADR-NNN-[short-name].md` |
| 85 | +- If a managed service is chosen: create `.decisions/ADR-NNN-use-[service].md` |
| 86 | + |
| 87 | +Template: |
| 88 | +```markdown |
| 89 | +# ADR-NNN: [Title] |
| 90 | + |
| 91 | +Date: [YYYY-MM-DD] |
| 92 | +Primitive: [from Phase 2] |
| 93 | +Candidates Considered: [list with URLs] |
| 94 | +Decision: [chosen approach] |
| 95 | +Rationale: [specific reasons] |
| 96 | +Rejected Alternatives: [specific reasons for each rejection] |
| 97 | +``` |
| 98 | + |
| 99 | +## Floom-Specific Landmines (DO NOT REPEAT) |
| 100 | + |
| 101 | +The following were proposed by agents in the past and were objectively wrong. If you are considering anything in the **Wrong Path** column, you are making the same mistake again. |
| 102 | + |
| 103 | +| Primitive | Wrong Path (Past Agent Mistakes) | Correct Default | |
43 | 104 | |---|---|---| |
44 | | -| Modal + Railway + custom Docker for code execution | e2b already exists to run arbitrary code safely | e2b SDK | |
45 | | -| Hand-rolled OpenAPI spec for function schemas | OpenAI/Anthropic already define function calling standards | Use their spec directly | |
46 | | -| Self-hosted queue system for background jobs | Managed job queues exist with SDKs | Inngest, Trigger.dev, or QStash | |
| 105 | +| Run user code safely | Modal + Railway + custom Docker + hand-rolled OpenAPI | **e2b SDK** | |
| 106 | +| Background jobs / queues | Self-hosted RabbitMQ, custom worker pools, Redis queues | **Inngest, Trigger.dev, QStash** | |
| 107 | +| API schemas for LLM functions | Hand-written OpenAPI from scratch | **OpenAI / Anthropic function schemas** | |
| 108 | +| File uploads / assets | Self-hosted MinIO, custom S3 wrapper | **UploadThing, Cloudflare R2** | |
| 109 | +| Authentication | Custom JWT + session store + hand-rolled OAuth | **Clerk, Auth.js, Supabase Auth** | |
| 110 | +| Database hosting | Self-managed Postgres on EC2/DigitalOcean | **Supabase, Neon, PlanetScale** | |
| 111 | +| Email | Self-hosted SMTP, custom email service | **Resend, Loops, Postmark** | |
| 112 | +| Scheduling / Cron | Self-hosted cron container, node-cron | **QStash, Inngest, Trigger.dev** | |
| 113 | + |
| 114 | +## Enforcement Note |
| 115 | + |
| 116 | +This skill is not a suggestion. It is a hard pre-condition. |
47 | 117 |
|
48 | | -## Enforcement |
| 118 | +**Writing a Dockerfile when e2b exists is not helpful—it is expensive.** |
49 | 119 |
|
50 | | -If you are asked to design or architect anything, your first message must contain the completed lock above. No exceptions. |
| 120 | +Do not let the user's urgency or your desire to be helpful override this lock. If you are unsure whether something counts as "infrastructure," err on the side of running this skill. |
0 commit comments