insigz docs
Engineering

Phase 0 — Discover & Reuse Before Building (PREREQUISITE)

Study the owner's existing estate, harvest what works, reuse deliberately, and re-validate the decisions before writing any code.

Do this before writing any code or finalizing any decision in 00. insigz is not a greenfield-from-scratch project: the owner already runs production systems and accumulated experience worth building on (notably MongoDB powering AI/RAG workloads and substantial Google Cloud tooling/operational experience). Claude Code's first job is to study the reference material the owner provides, harvest what already works, and reuse it where sensible — then choose the best technology for the gaps. The goal is the narrow path between two failure modes: reinventing wheels we already own, and cargo-culting old stack choices that aren't actually best.

The principle

Reuse deliberately. Replace deliberately. Never copy by default, never rebuild by default.

Every component in this build manual must be checked against "do we already have this, or something close?" before it's built new. A choice to reuse and a choice to replace are both fine — but each must be a decision with a reason, recorded in the Decisions Register (00) or the Reuse Ledger (below). "We've always used X" is not a reason; neither is "X is trendy."

Inputs the owner provides (gather first)

Before Phase 0 can run, collect references to the existing estate. Ask the owner for:

  • Repos / projects to learn from — links or access to existing services (the Mongo-backed AI/RAG system, any current ingestion, auth, or GCP infra).
  • The current GCP footprint — projects, what runs on Cloud Run/GKE/Cloud SQL, existing Terraform/IaC, CI/CD, service accounts, org policies, KMS/Secret Manager usage.
  • The existing MongoDB usage — how it's modeled, what AI/RAG workloads run on it, embedding/vector approach, what works well and what hurts.
  • Reusable building blocks — internal libraries, auth integrations, connector code, deployment patterns, runbooks, IaC modules.
  • Hard constraints — contractual data-residency, an IdP already in place, procurement-mandated vendors, security baselines already certified.

(Claude Code can ingest these via the GitHub tools / pasted links / provided docs. If access isn't available, this phase produces questions for the owner rather than guesses.)

What Phase 0 produces (deliverables)

  1. A Reuse Ledger — a table of every major capability in this manual vs. what already exists, with a verdict:

    CapabilityExisting asset (ref)VerdictRationale
    Document/RAG store<their Mongo AI system>Reuse / adaptAlready proven for AI workloads; matches D1's polyglot target — may even pull Mongo forward from "post-M0" if it's battle-tested
    GCP provisioning<their Terraform/infra>Reuse / extendDon't re-author Cloud Run/Cloud SQL modules we already operate
    Auth / IdP<existing>Reuse or replace
    Ingestion<existing connectors>Adapt
  2. Decision deltas — where the existing estate should change a 00 decision. The clearest candidate: D1 (single-store pgvector first) was chosen to avoid standing up Mongo from scratch. If the owner already operates Mongo for AI/RAG in production, that rationale weakens — reusing the proven Mongo setup may be better than introducing pgvector. Phase 0 must explicitly re-test D1 against the real estate and record the outcome.

  3. A "build vs. reuse vs. buy" call per component — feeding 01 (milestones). Reused components shorten M0; net-new components get built per the relevant file.

Decision rubric (how to choose)

For each capability, reuse the existing asset when it is: proven in production, not a security/scaling dead-end, and broadly aligned with the target architecture. Replace it when it: blocks tenant isolation / the security model (4044), can't meet the regulated/sovereign bar, or is materially worse than a now-standard alternative. Adopt a managed service over building unless isolation or cost demands otherwise. When reuse and best-practice genuinely conflict, security and tenant-isolation invariants win (they are non-negotiable in 43/82); everything else is a cost/speed trade the owner signs off.

How this changes the rest of the manual

  • 00 Decisions Register entries are provisional until Phase 0 validates them against the real estate — especially D1 (stores), D2 (language, if there's an existing service to extend), D5 (embeddings, if Mongo Atlas Vector Search is already in use), D11/D12 (GCP layout/routing, if there's an existing footprint).
  • 01 milestones assume some components are reused, not built — M0 scope shrinks by whatever Phase 0 marks "reuse."
  • This file is the gate: M0 doesn't start until the Reuse Ledger + decision deltas exist and the owner has signed off.

Gaps to close (owner)

  • Provide the reference repos / GCP project access / Mongo system docs to study.
  • Confirm which existing assets are in scope to reuse vs. frozen legacy (learn-from-only).
  • Sign off the Reuse Ledger + any decision deltas before M0.