What is a dev unit?
A dev unit is the fundamental building block of a PDD project. It consists of four artifacts that belong together and are kept in continuous sync:Prompt
The source of truth. Defines intent, requirements, and constraints for the module. Versioned in git. Never generated — always authored.
Generated code
The implementation produced by
pdd generate. Disposable — regenerated from the prompt whenever the prompt changes. Never manually patched for structural changes.Runnable example
A minimal program demonstrating how to use the module. Produced by
pdd example. Serves as the public interface consumed by dependent modules.Tests
Unit tests produced by
pdd test. Accumulate over time — never replaced, only expanded. Serve as mold walls that constrain all future generations.How the four artifacts relate
Prompt is the source of truth for all three
When the prompt changes,pdd sync determines which downstream artifacts are out of date and regenerates them. Code is always regenerated from the prompt. The example is regenerated to match updated code. Tests are not regenerated — they accumulate. New tests may be added, but existing passing tests are never discarded.
Tests constrain code, not just verify it
Whenpdd generate runs, existing tests are included as context in the LLM’s prompt. This means generated code is constrained to pass existing tests — the tests act as specification walls, not after-the-fact checks.
Each bug found adds a test, which permanently prevents that bug from recurring in any future generation. This is the ratchet effect: the mold becomes more precise over time.
The example is the interface
The example is not documentation — it is the interface that dependent modules include as context. A 500-line module might have a 50-line usage example. By including only the example, dependent prompts save ~90% of tokens while getting the same contract information. Module A’s prompt includes Module B’s example. When Module B changes,pdd auto-deps updates the include reference, and Module A regenerates with the current interface.
The sync cycle
pdd sync <basename> runs the complete dev unit workflow automatically, executing only the steps needed based on what has changed.
auto-deps
Discover and inject relevant dependencies into the prompt — both code examples and documentation files. Remove redundant inline content that duplicates what included documents provide.
generate
Create or update the code module from the prompt. Uses fingerprint-based change detection to determine whether to perform incremental patching or full regeneration.
crash
Fix any runtime errors to make the code and example executable. Resolves immediate failures before verification.
verify
Run functional verification — execute the program and judge its output against the prompt’s stated intent.
test
Generate comprehensive unit tests if they do not exist, or expand them if the module has changed. Tests accumulate in a single test file per target.
fix
Iteratively resolve any bugs found by unit tests. Each iteration sees the failing tests and generates code that satisfies them.
generate is skipped. If tests already pass at the target coverage, fix is skipped.
Fingerprint-based change detection
PDD uses content hashes and timestamps to precisely detect what has changed since the last sync. This prevents unnecessary regeneration and enables safe incremental updates. Fingerprint data is stored in.pdd/meta/<basename>_<language>.json. Each fingerprint file tracks:
- The hash of the prompt at the time of last generation
- The hash of the generated code
- The hash of the example
- Test results and coverage from the last run
- Timestamps for each operation
pdd sync runs, it compares current file hashes against stored fingerprints to decide which steps to execute. If the prompt hash matches the stored value, code regeneration is skipped. If the code hash has changed since the last example generation, the example is regenerated.
For complex scenarios — such as multiple files changing simultaneously — PDD uses LLM-powered conflict resolution to determine the best approach.
Test accumulation
Tests are a permanent asset. This is a core PDD invariant: The accumulation workflow:pdd testgenerates the initial test file from the prompt and code- When a bug is found,
pdd bugadds a failing test case to the existing test file pdd fixresolves the bug — the LLM sees all existing tests and must pass them- The new test is now a permanent mold wall
The .pdd/ directory
PDD uses a .pdd/ directory in the project root to store metadata and state:
.pdd
meta
factorial_calculator_python.json
data_processor_python.json
locks
llm_model.csv
| Path | Purpose |
|---|---|
.pdd/meta/<basename>_<language>.json | Fingerprint files — operation history, test results, coverage, sync logs |
.pdd/locks/ | File-descriptor-based lock files that prevent concurrent sync operations |
.pdd/llm_model.csv | Optional project-specific LLM model configuration |
Add
.pdd/ to version control (except lock files). The meta/ directory contains important project state — fingerprints, run reports, and sync history — that enables reproducibility across machines.Smart lock management
Lock files in.pdd/locks/ prevent race conditions when multiple sync operations run simultaneously. PDD uses file-descriptor-based locking and automatically cleans up stale locks from crashed processes.
The --dry-run flag performs state analysis without acquiring locks, making it safe to inspect sync state even while another sync is running:
Lifecycle summary
| Artifact | Created by | Updated when | Discarded? |
|---|---|---|---|
| Prompt | Developer (authored) | Developer edits it | Never |
| Code | pdd generate | Prompt changes | Yes — regenerated |
| Example | pdd example | Code changes | Yes — regenerated |
| Tests | pdd test | Bugs found (expanded) | Never |
| Fingerprints | pdd sync | After each operation | No — accumulated |