Quickstart in 5 minutes
One prompt = one module
Map each prompt to a single file or narrowly scoped module. Don’t try to generate an entire subsystem in one prompt.
Include context explicitly
Use
<include>path/to/file</include> to give the model only what it needs. This is a PDD directive — the tool replaces the tag with actual file content before the LLM sees it.Regenerate, don't patch
If the code is wrong, fix the prompt and run
pdd fix. Don’t edit generated code directly unless you also update the prompt.Prompt file naming
Prompt files follow this convention:| Prompt file | Generated output |
|---|---|
factorial_calculator_python.prompt | factorial_calculator.py |
responsive_layout_css.prompt | responsive_layout.css |
data_processing_pipeline_python.prompt | data_processing_pipeline.py |
Prompt structure template
Target size: prompt-to-code ratio
Aim for 10–30% of your expected output code size:| Ratio | Meaning |
|---|---|
| Less than 10% | Too vague — missing contracts, error handling, or key constraints |
| 10–30% | Just right — requirements and contracts without implementation details |
| More than 50% | Too detailed — duplicating what the preamble, grounding, or tests should handle |
Context engineering
Context engineering is the practice of curating exactly what information fits into the model’s context window. The goal is to include everything the model needs and nothing it doesn’t. What to include:- Shared preamble (coding style, conventions, forbidden libraries)
- Dependency interfaces (the example file, not the full implementation)
- Authoritative documentation (schema docs, API references)
- The full codebase
- Implementation patterns (handled by automated grounding on PDD Cloud)
- Every edge case (accumulated by tests over time)
<include> directives
The <include> tag injects file content into the prompt before it reaches the LLM.
Selective includes
Useselect= to include only specific parts of a file:
| Selector | File types | Example |
|---|---|---|
lines:N-M | Any | lines:10-20 |
def:name | Python | def:process_request |
class:Name | Python | class:UserModel |
class:Name.method | Python | class:UserModel.validate |
section:Heading | Markdown | section:Installation |
pattern:/regex/ | Any | pattern:/^import/ |
path:key.nested | JSON/YAML | path:config.database.host |
mode="interface" to extract only signatures, docstrings, and type hints (Python only):
Automatic propagation
When an included file changes, every prompt that references it reflects those changes on the next generation — without editing the prompts themselves. This is particularly useful for shared preambles and evolving API contracts.Shared preambles
Create acontext/project_preamble.prompt file and include it at the top of every prompt. Use it to define your “constitution”:
- Indentation and naming conventions
- Preferred linting rules
- Forbidden libraries or patterns
- Logging and error-handling standards
Parameterized prompts
Use$VAR or ${VAR} substitution to generate multiple files from one prompt:
-e are substituted. All other $ occurrences are left unchanged.
Writing effective requirements
Requirements are the core of your prompt. Aim for 5–10 items. Structure each requirement to be:- Testable — if you can’t write a test for it, it’s too vague
- Behavioral — describe WHAT, not HOW
- Unique — don’t duplicate what the preamble or tests already encode
- Too detailed
- Just right
Common patterns
Dependency injection via auto-deps
Runpdd auto-deps to discover and insert relevant dependencies automatically:
<include> directives, and removes inline content that duplicates what the included files already provide.
Grounding via few-shot examples (PDD Cloud)
On PDD Cloud, generation automatically retrieves the closest prior(prompt, code) pair as a few-shot example. This keeps regenerated code consistent with your established style without any configuration.
For explicit control:
Architecture metadata tags
Place these tags at the top of prompt files to keeparchitecture.json in sync:
Anti-patterns to avoid
Dumping the whole repo
Dumping the whole repo
Including large swaths of the codebase as context overwhelms the model and inflates costs. Use targeted
<include select="..."> tags or example files instead.Patching instead of regenerating
Patching instead of regenerating
When you manually edit generated code without updating the prompt, the prompt and code drift apart. Fix the prompt, then run
pdd fix or pdd sync to regenerate.Mega-prompts
Mega-prompts
If a prompt exceeds 30% of the expected code size, it is likely over-specified. Split it into smaller prompts with explicit interfaces using
pdd split.Specifying implementation details
Specifying implementation details
Don’t dictate variable names, loop structures, or class hierarchies. Write requirements at the level of architecture, contract, and intent. Let the model fill in routine implementation.
Overwriting tests
Overwriting tests
Tests are permanent assets. Never overwrite the test file. PDD accumulates tests over time, creating a ratchet effect where each new test permanently constrains future generations.
Checklist before running pdd generate
Required:
- Module purpose is clear (1–2 sentences)
- Requirements are testable and behavioral (5–10 items)
- Dependencies included via
<include>if external or critical
- Tests exist for known edge cases
- Previous generation was successful (grounding will use it)
- Coding style → shared preamble handles this
- Implementation patterns → grounding handles this
- Every edge case → accumulated tests handle this