{"slug": "secret-sauce-code-now-open-source-it-beats-ai-generated-code", "title": "Secret sauce code now open source ( * it beats AI generated code)", "summary": "A developer has open-sourced TDK CLI, a tool that turns a small declarative service.json file into a full local development stack, generating Dockerfiles, live-reload rules, Traefik routes, shared Postgres wiring, health probes, and Tilt configuration. The project splits responsibilities across a TypeScript CLI for commands, validation, port allocation and template generation, plus Starlark-based discovery and engine layers that build a dependency DAG and run inside Tilt. The author argues the approach beats AI-generated code for local infrastructure because a committed source-of-truth file keeps agents and humans from silently breaking the setup.", "body_md": "`service.json` Becomes a Full Local Stack\nMost multi-service setups still force you to maintain Docker Compose files, Tiltfiles, nginx configs, port maps, and health checks by hand. AI coding agents make the application code easy, but they are still bad at keeping the local infrastructure consistent.\n\n**TDK CLI** solves this by treating a tiny declarative file as the source of truth and generating everything else.\n\nThis is essentially all you write for a service:\n\n```\n{\n  \"$schema\": \"https://tdk-landscape.github.io/schema.service.json\",\n  \"schemaVersion\": 1,\n  \"appName\": \"orders-api\",\n  \"appType\": \"backend\",\n  \"stack\": \"shop\",\n  \"port\": 4000,\n  \"healthCheckPath\": \"/health\",\n  \"dependsOn\": []\n}\n```\n\nFrom this single file, TDK generates Dockerfiles, live-reload rules, Traefik routes, shared Postgres wiring, health probes, and the Tilt configuration that actually runs it.\n\nThe project is organized as **Project → Stack → Resource**.\n\n``` php\nflowchart LR\n    P[Project<br/>.tdk/project.json] --> S1[Stack: shop]\n    P --> S2[Stack: billing]\n    S1 --> R1[orders-api<br/>backend]\n    S1 --> R2[orders-app<br/>frontend]\n    S2 --> R3[checkout-api<br/>backend]\n```\n\nThe codebase is deliberately split so each part has a clear job:\n\n```\nflowchart TB\n    subgraph CLI[\"cli/ (TypeScript)\"]\n        Commands[Commands & validation]\n        Templates[Handlebars templates]\n        Ports[Port allocation]\n    end\n\n    subgraph Discovery[\"discovery/ (Starlark)\"]\n        Scan[Scan service.json]\n        DAG[Build dependency DAG]\n    end\n\n    subgraph Engine[\"engine/ (Starlark)\"]\n        LiveUpdate[live_update rules]\n        Traefik[Traefik routing]\n        Infra[Postgres + platform]\n    end\n\n    CLI -->|generates Tiltfile + configs| Discovery\n    Discovery -->|registry + DAG| Engine\n    Engine -->|docker_build + containers| Docker[(Docker)]\n```\n\n| Subsystem | Language | Responsibility | \n|---|---|---|\n| `cli/` | TypeScript | Commands, validation, port allocation, template generation, launching Tilt | \n| `discovery/` | Starlark | Scan for `service.json` files, normalize them, build the dependency DAG | \n| `engine/` | Starlark | Runs *inside* Tilt — turns the DAG into real`docker_build` ,`live_update` , Traefik, Postgres, etc. | \n\nThe CLI never starts containers itself. The engine never parses CLI flags. Discovery never builds images.\n\nThe real glue is the template engine (`cli/src/generator/template-engine.ts`). It reads `.tdk/project.json` and emits files into the gitignored `.tdk/.tdk-out/` directory:\n\n`Tiltfile`` TILT_TECH_STACK.star` and `TILT_RESOURCE_DEFAULTS.star`\n`spec.master``.tiltignore`\nThese come from Handlebars templates. The CLI also vendors a copy of the engine and discovery code so `tdk up` works offline.\n\n`tdk up`\n\n```\nsequenceDiagram\n    actor Dev\n    participant CLI as TDK CLI\n    participant Gen as Template Engine\n    participant Tilt\n    participant Engine as Starlark Engine\n    participant Docker\n\n    Dev->>CLI: tdk up shop\n    CLI->>CLI: Preflight (Docker, schema, drift, ports)\n    CLI->>Gen: Ensure master configs\n    Gen-->>CLI: .tdk/.tdk-out/Tiltfile\n    CLI->>Tilt: tilt up -f Tiltfile -- --focus=shop\n    Tilt->>Engine: Load discovery + engine\n    Engine->>Engine: Scan service.json → DAG\n    Engine->>Docker: docker_build + live_update\n    Engine->>Docker: Start Traefik + Postgres\n    Docker-->>Tilt: Containers healthy\n    Tilt-->>CLI: Ready\n    CLI-->>Dev: Print URLs + Tilt UI\n```\n\nHigh-level steps:\n\n`pre_alpha` phase.`tilt up` against the generated Tiltfile.`.autogenerated/` files, registers builds with live-update, and starts shared infrastructure.\nTDK is strict about this boundary so AI agents (and humans) cannot silently break the infrastructure:\n\n```\nflowchart LR\n    subgraph Committed[\"Committed (source of truth)\"]\n        PJ[.tdk/project.json]\n        SJ[services/*/*/service.json]\n        Code[Your app source]\n    end\n\n    subgraph Generated[\"Generated (gitignored)\"]\n        Out[.tdk/.tdk-out/<br/>Tiltfile, specs]\n        Auto[services/*/*/.autogenerated/]\n        Env[.env]\n    end\n\n    Committed -->|tdk project / tdk resource / tdk up| Generated\n    Generated -->|tdk config regenerate| Committed\n```\n\n| Path | Status | Why | \n|---|---|---|\n| `.tdk/project.json` | Committed | Project identity and phases | \n| `services/*/*/service.json` | Committed | Service contract | \n| Application source | Committed | Your code | \n| `.tdk/.tdk-out/` | Generated | Derived from templates | \n| `services/*/*/.autogenerated/` | Generated | Engine output during Tilt | \n| `.env` | Generated | Local secrets | \n\nTDK is a **local development runtime**. It does not deploy to staging or production. The project explicitly leaves production to Helm, Argo CD, or whatever you already use. The local environment is optimized for speed and developer experience, not for being a perfect replica of production.\n\n```\nnpm install -g @tdk-landscape/tdk-cli-core\ntdk doctor\ntdk project --yes\ntdk resource orders-api --type backend --stack shop --yes\ntdk up shop\n```\n\nOr clone the official starter and open it in any cloud IDE.", "url": "https://wpnews.pro/news/secret-sauce-code-now-open-source-it-beats-ai-generated-code", "canonical_source": "https://dev.to/tdk-cli/secret-sauce-code-now-open-source-it-beats-ai-generated-code-2h2a", "published_at": "2026-10-19 22:09:12+00:00", "updated_at": "2026-10-19 22:15:07.245554+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools", "ai-agents"], "entities": ["TDK CLI", "Tilt", "Docker", "Traefik", "Postgres", "Starlark", "TypeScript", "Handlebars"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/secret-sauce-code-now-open-source-it-beats-ai-generated-code", "markdown": "https://wpnews.pro/news/secret-sauce-code-now-open-source-it-beats-ai-generated-code.md", "text": "https://wpnews.pro/news/secret-sauce-code-now-open-source-it-beats-ai-generated-code.txt", "jsonld": "https://wpnews.pro/news/secret-sauce-code-now-open-source-it-beats-ai-generated-code.jsonld"}}