This document defines a technical implementation plan for applying a specification‑driven, human–AI collaborative development methodology (referred to as Deep Coding) to Ruby software projects. The plan translates four core principles into concrete Ruby constructs, toolchains, and phase‑based workflows:
All steps, evaluation metrics, and verification gates are defined in Ruby‑native terms, avoiding philosophical framing.
The specification is expressed using Ruby’s official type definition language RBS (standard library since Ruby 3.0).
.rbs files (placed in sig/ directory). RBS supports union types, optional types, overloads, type variables, and block parameters.pydantic‑like libraries (e.g. dry‑struct, active_attr). For strict specification, prefer RBS.Example RBS specification:
interface _Entity
def update: (Float delta_time) -> void
def render: (untyped surface) -> void
end
class GameLoopSkeleton
def initialize: () -> void
def run: () -> void
end
NotImplementedError.lib/skeleton/ with restricted write permissions (human only).lib/tissue/; fully regenerated from the structural specification.For each module or feature:
steep check to verify type conformance.If verification fails, regeneration is attempted. The phase does not proceed until all gates pass.
After each development phase, a structured summary is committed as a fixed premise:
Stored as FIXED_PREMISE.md (or YAML) in version control. Subsequent phases treat this summary as immutable.
Development proceeds in phases, each with the following steps:
| Step | Action |
|---|---|
| 1. Plan | Define specification changes (RBS deltas). |
| 2. Approve | Human reviews and approves the delta. |
| 3. Generate | AI generates tissue code from the updated RBS. |
| 4. Static Gate | steep check passes with zero errors. |
| 5. Test Gate | rspec passes all tests. |
| 6. Dependency Gate | packwerk (or custom RuboCop) checks dependency direction. |
| 7. Summary | Commit the fixed premise and tag the phase. |
| Phase | Focus | Specification Change | Generated Output |
|---|---|---|---|
| 1 | Core skeleton | Define GameLoopSkeleton RBS interface |
Manual skeleton code (no generation) |
| 2 | Player & input | Add Player protocol, InputState RBS |
AI‑generated Player implementation |
| 3 | Enemies & collision | Add Enemy protocol, CollisionDetector interface |
AI‑generated enemy types and collision logic |
| 4 | Data‑driven stages | Define Stage RBS model with spawn patterns |
AI‑generated stage loader |
| 5 | Editor integration | Add StageEditor protocol, JSON serialization spec |
AI‑generated editor UI or API |
| 6 | Optimisation | Add performance constraints (frame time) | AI‑optimised rendering loops |
All generated code must pass the following automated checks before phase completion:
| Gate | Tool | Command | Pass Condition |
|---|---|---|---|
| Type safety | Steep | steep check |
0 errors |
| Linting | RuboCop | rubocop |
0 offenses |
| Dependency direction | Packwerk (Rails) / custom RuboCop | packwerk check |
0 violations |
| Unit tests | RSpec | rspec --format documentation |
100% passing |
| Coverage | SimpleCov | rspec --coverage |
≥ 80% |
These gates are implemented as pre‑commit hooks and CI pipelines.
The AI (LLM) is invoked with a structured prompt containing:
The AI output is restricted to:
The AI cannot modify:
lib/skeleton/)Compared to conventional AI‑assisted Ruby development (e.g. GitHub Copilot), this specification‑driven approach provides measurable advantages:
| Factor | Conventional AI | Specification‑driven (this plan) |
|---|---|---|
| Context efficiency | Entire codebase often required | Only RBS specification (few KB) |
| Type information | Implicit, inferred from code | Explicit, defined in RBS |
| Hallucination mitigation | None | Steep validation rejects non‑conforming code |
| Change propagation | Manual or error‑prone | Regenerate tissue from updated RBS |
| Dependency enforcement | None | Packwerk / RuboCop static checks |
These advantages are most significant for medium‑to‑large projects and Rails applications, where context length and architectural consistency become bottlenecks.
Optional:
| Condition | Required | Notes |
|---|---|---|
| Specification completeness | Yes | Incomplete RBS leads to correct‑but‑wrong code |
| Generation correctness | High | LLM must produce code that passes steep check; multi‑agent validation helps |
| Skeleton enforceability | Partial | Template method works; functional paradigms need different mechanisms |
| Non‑Rails projects | Partial | Packwerk unavailable; use custom RuboCop cops for dependency direction |
| Metaprogramming | Limited | Heavy use of method_missing or DSLs is not RBS‑friendly; move such code to tissue |
When these conditions are not met, the methodology applies only to the specifiable subset, and conventional practices handle the remainder.
project-root/
├── sig/ # RBS specification files
│ ├── skeleton/
│ └── tissue/ # generated RBS (optional)
├── lib/
│ ├── skeleton/ # manual, immutable
│ ├── tissue/ # AI‑generated, regenerable
│ └── domain/ # manual entities
├── test/
│ ├── unit/
│ ├── integration/
│ └── type_check/
├── Gemfile
├── Steepfile
├── .rubocop.yml
├── package.yml # Packwerk config (Rails)
├── Rakefile
├── FIXED_PREMISE.md
└── .github/workflows/ci.yml
The implementation plan defines a specification‑driven, AI‑collaborative workflow for Ruby projects using:
FIXED_PREMISE.md for recursive refinement with fixed premisesWhen applied, the workflow reduces context window usage (only RBS needs to be loaded), enables automatic verification of generated code, and allows specification‑only updates without manual propagation across modules. For medium‑to‑large projects and Rails applications, these characteristics provide measurable advantages over conventional AI‑assisted Ruby coding.