You are working on Pocket CFO, an evidence-native finance discovery and decision system.
Read this file before doing any work.
For non-trivial work, also read docs/ACTIVE_DOCS.md, PLANS.md, plans/ROADMAP.md, and the active Finance Plan in plans/.
-
Prefer modular code. Do not collapse transport, domain logic, persistence, formatting, and prompt assembly into one file. Soft cap: keep most source files below 300 logical lines. Split early.
-
Use a Finance Plan for meaningful work. If a task spans multiple files, touches more than one package, or is likely to take more than 45 minutes, create or update a
plans/FP-*.mdplan before coding. FollowPLANS.mdexactly. -
Finance evidence is the source of truth. Raw source files, source snapshots, checksums, provenance, freshness posture, and derived twin state matter more than chat convenience. Never treat a model answer as the source of truth.
-
Raw sources are immutable. Do not silently rewrite uploaded exports, PDFs, or source documents. Derived artifacts belong in the twin, wiki, reports, or evidence layers.
-
GitHub is an optional connector, not the product center. Do not let repo or PR semantics leak into the primary Pocket CFO path. Keep GitHub-specific logic isolated behind connector boundaries.
-
Preserve architecture boundaries.
packages/domain: pure contracts, schemas, shared finance mission and artifact typespackages/db: persistence schema and DB helpers onlypackages/codex-runtime: Codex App Server protocol wrapper onlypackages/config: env parsing and runtime configpackages/stack-packs: pack interfaces and manifestspackages/testkit: fixtures and reusable test helpersapps/control-plane: sources, missions, orchestrator, replay, evidence, finance twin, wiki, reports, monitoringapps/web: operator UI and read models only
-
Routes stay thin. HTTP route files should parse input, call a service, and serialize output. They should not contain SQL, ingest logic, finance math, or prompt-building.
-
Database changes are additive first. Avoid destructive schema changes unless the active Finance Plan names them explicitly and includes recovery guidance.
-
Replay and evidence are mandatory. Any mission state change or meaningful ingest/report action needs replay or an explicit recorded reason why it does not.
-
Freshness and limitations are first-class. If a result depends on stale, partial, inferred, or conflicting evidence, say that plainly in code, docs, and outputs. Do not hide uncertainty.
-
Do not claim unfinished finance capabilities as implemented. The active docs define direction. The code defines current reality. When those differ, state the gap honestly and implement through the active plan.
-
No hidden policy. If a workflow rule matters, encode it in code, config,
WORKFLOW.md, or a checked-in doc. Do not rely on ephemeral prompt memory. -
Ship the evidence spine before cleverness. Source registry, Finance Twin, replay, approvals, evidence bundles, and durable outputs matter more than glossy chat behavior.
-
Do not cross the product safety boundary. No autonomous bank writes, ledger writes, tax filings, legal advice, or external communication releases without explicit human approval and a named plan.
-
When uncertain, narrow scope instead of diluting the design. Prefer one strong finance slice over three half-built surfaces.
A slice is not done until all of the following are true:
- code exists in the right module boundaries
- tests exist for the touched behavior
- the active Finance Plan is updated
- the active docs are updated if behavior or workflow changed
- acceptance is observable by a human
- replay implications are covered
- mission-facing outputs expose provenance, freshness posture, and limitations when relevant
Use these patterns by default:
routes.tsorcontroller.tsfor transportschema.tsfor validationservice.tsfor orchestration or domain logicrepository.tsfor persistenceformatter.tsfor operator summaries and evidence formattingevents.tsfor replay or outbox events
If a bounded context grows, make a folder and split by responsibility instead of extending one file forever.
- TypeScript strict mode
- Zod for external input validation
- Drizzle ORM for database schema and queries
- Fastify for control-plane HTTP endpoints
- Next.js App Router for the web UI
- Pino for logs
- OpenTelemetry hooks from the beginning
- Postgres as the state source of truth
- S3-compatible artifact storage
- file-first finance ingestion before API connector sprawl
- Codex App Server as the narrow runtime seam
- deterministic extraction before freeform generation
pnpm install
pnpm dev
pnpm lint
pnpm typecheck
pnpm test
pnpm check
pnpm db:generate
pnpm db:migrate
docker compose up -dUse the pocket-cfo-codex-operator plugin instead of repo-local skills.
The repo-local marketplace entry lives at .agents/plugins/marketplace.json, and the plugin bundle lives at plugins/pocket-cfo-codex-operator/.
Use the bundled skills deliberately:
$finance-plan-orchestratorfor Finance Plan truthfulness, active roadmap docs, phase handoffs, and plan-scoped execution$execplan-orchestratorfor any complex slice or refactor that needs a step-by-step execution document$modular-architecture-guardwhen implementing or refactoring code$source-provenance-guardwhen touching source ingest, lineage, or freshness$cfo-wiki-maintainerwhen compiling or maintaining the markdown knowledge layer$evidence-bundle-auditorwhen shipping answers, reports, approvals, or proof logic$f6-monitoring-semantics-guardwhen touching F6 monitoring semantics$validation-ladder-composerwhen composing validation or smoke-test ladders$pocket-cfo-handoff-auditorwhen preparing or auditing handoffs$github-app-integration-guardonly for GitHub connector work
docs/ACTIVE_DOCS.mdREADME.mdSTART_HERE.mdPLANS.mdplans/ROADMAP.md- the unfinished
plans/FP-*.mdfile if one exists; otherwise the latest closeout or handoffplans/FP-*.mdrecord plus a new next-phase plan before code changes docs/ops/source-ingest-and-cfo-wiki.mddocs/ops/local-dev.mddocs/ops/codex-app-server.mddocs/ops/github-app-setup.mdonly if connector work is in scope
Historical Pocket CTO material such as plans/EP-*.md and the old M2/M3 exit reports may still exist temporarily, but they are reference only and must not be treated as active product scope.
Avoid these unless the active Finance Plan explicitly approves them:
- using GitHub as the default product source of truth
- mutating raw source files instead of creating derived artifacts
- answering finance questions from chat context alone
- deleting legacy engineering modules before the replacement path exists
- one giant route or service file that owns everything
- route handlers talking directly to the database
- a repo-wide internal namespace rename during the pivot foundation phase
- auto-releasing external memos or packets without a review path
At each stopping point:
- update the active Finance Plan
Progresssection - record design changes in the
Decision Log - note surprises that affect scope or sequence
- state exactly what remains
- mention any archive or active-doc boundary changes you made
The compelling proof point is not “an AI that sounds like a CFO.”
It is:
raw finance evidence becomes a persisted, freshness-aware decision system that can answer a question, explain its limitations, and produce a durable artifact another human can review outside chat.