This plan defines a technical framework for applying Deep Coding — a specification‑driven, human‑AI collaborative development methodology — to TypeScript projects. Deep Coding separates intent, structural specification, and implementation, then enforces generative conformance through automated validation gates. The plan translates five core principles into concrete TypeScript constructs, toolchain integrations, and phase‑based workflows.
All philosophical framing is replaced with executable technical procedures.
| Original Principle | TypeScript Technical Equivalent |
|---|---|
| Intent–Structure–Implementation Separation | TypeScript interfaces (specification) + abstract classes (skeleton) + concrete classes (tissue) |
| Generative Conformance | Interface implementation + tsc --strict + runtime schema validation (Zod) |
| Recursive Refinement with Fixed Premises | Version‑controlled specification files + Git commits as phase checkpoints |
| Skeleton–Tissue Architecture | Abstract classes (skeleton, manually maintained) + concrete classes (tissue, generated) |
| Inferential Information Density (Negentropy) | Type density (exported types / lines) + absence of circular dependencies (dependency-cruiser) |
Layer 0: Intent (Human)
↓
Layer 1: Structural Specification
- OpenAPI / JSON Schema / TypeScript interfaces / Zod schemas
- Stored in `specification/`
↓
Layer 2: Generation (Tooling + Optional AI)
- OpenAPI Generator, json-schema-to-typescript, custom AST transformers
- Output to `generated/`
↓
Layer 3: Validation Gates
- `tsc --strict`, ESLint, dependency-cruiser, Zod runtime checks
↓
Layer 4: Tissue (Generated Code) + Skeleton (Manual Code)
- Tissue: `tissue/` – business logic, concrete implementations
- Skeleton: `skeleton/` – abstract classes, cross‑cutting concerns
| Scope | Format | Tooling |
|---|---|---|
| API boundaries (REST) | OpenAPI 3.0+ YAML | openapi-typescript, orval |
| Data models | JSON Schema | @rxap/json-schema-to-typescript |
| Internal module contracts | TypeScript interfaces | tsc --noEmit |
| Runtime‑validated boundaries | Zod schemas | zod (inference + validation) |
| Full‑stack TypeScript | tRPC (implicit spec) | TypeScript compiler only |
Selection rule: Prefer OpenAPI for external APIs, JSON Schema for shared data, interfaces for internal modules, Zod for runtime‑critical boundaries.
| Layer | Tool | Command | Fail Condition |
|---|---|---|---|
| Compile‑time | TypeScript | tsc --strict --noEmit |
Any type error |
| Lint‑time | ESLint (custom rules) | eslint . --rule 'no-restricted-imports: ["error", { patterns: ["skeleton/*"] }]' |
Tissue imports skeleton directly (inverse dependency) |
| Dependency | dependency-cruiser | depcruise src --config .dependency-cruiser.js |
Circular import or forbidden dependency direction |
| Runtime | Zod + Jest | zod.parse() in tests |
Schema validation fails |
CI Integration: All gates must pass before merging. Generated code is re‑validated on every PR.
src/skeleton/. Human only. AI never modifies.// skeleton/GameLoopSkeleton.ts
export abstract class GameLoopSkeleton {
run(): void {
this.initialize();
while (this.isRunning()) {
this.update();
this.render();
}
this.cleanup();
}
protected abstract initialize(): void;
protected abstract update(): void;
protected abstract render(): void;
private isRunning(): boolean { /* ... */ }
private cleanup(): void { /* ... */ }
}
src/tissue/. Generated from specification.// tissue/GameLogic.ts (generated)
import { GameLoopSkeleton } from '../skeleton/GameLoopSkeleton';
export class GameLogic extends GameLoopSkeleton {
protected initialize(): void { /* AI generated */ }
protected update(): void { /* AI generated */ }
protected render(): void { /* AI generated */ }
}
// .dependency-cruiser.js
{
forbidden: [{
name: 'tissue-to-skeleton-inverse',
from: { path: '^src/tissue' },
to: { path: '^src/skeleton' }
}]
}
Each phase follows:
orval, json-schema-to-typescript, or AI prompt).Rollback: Revert to previous commit of specification files, then regenerate.
| Challenge | TypeScript Solution |
|---|---|
| Structural typing (duck typing) accidental conformance | Branded types: type UserId = string & { __brand: 'UserId' } |
| Async flow control in skeleton | async template methods + explicit ExecutionContext passing |
| Single inheritance limitation | Compose via interfaces + dependency injection (prefer over multiple inheritance) |
| Type erasure at runtime | Zod schemas for runtime validation (dual source with interfaces) |
| Build pipeline (bundlers, transpilers) | Run tsc --noEmit before bundling; never rely on Babel for type checking |
| External npm packages with no types | Adapter pattern: wrap with interface + Zod schema in specification/adapters/ |
strict: true in tsconfig.jsonsrc/skeleton/, src/tissue/, src/specification/ directoriestissue → skeleton importsdependency-cruiser with circular dependency and direction rulesopenapi-typescript, orval, json-schema-to-typescript)Deep Coding on TypeScript is a technically executable methodology that replaces philosophical declarations with:
The plan is scoped to TypeScript projects with strict mode enabled. For event‑driven frameworks (React, Vue), replace “flow ownership” with “state transition contracts” (Zod‑validated state machines). External npm dependencies must be isolated behind adapter layers with explicit specifications.
All principles reduce to tool‑enforced rules and directory conventions — no philosophy required.