What is a prompt file?
A prompt file is the source of truth for a PDD module. It defines the intent, requirements, and constraints for a single code file. PDD reads the prompt file, preprocesses it (resolving directives), then sends the result to an LLM to generate the corresponding code. Prompt files use the extension.prompt and follow a strict naming convention.
Naming convention
<basename>is the name of the module (underscore-separated words)<language>is the target programming language or context
pdd sync detects which language to use. For example, factorial_calculator_python.prompt generates factorial_calculator.py.
Supported languages
Python
JavaScript
TypeScript
Java
C++
Ruby
Go
CSS / other
Files ending in
_llm.prompt are reserved for PDD’s internal processing and cannot form valid development units. They lack the associated code, examples, and tests required for the sync workflow.Prompt structure
A well-designed prompt contains only what cannot be handled elsewhere. With cloud grounding and accumulated tests, prompts can be minimal — aim for 10–30% of your expected code size.Required sections
- Role and scope (1–2 sentences): what this module does
- Requirements (5–10 items): functional and non-functional specs
- Dependencies (via
<include>): external or critical interfaces
Optional sections
- Instructions: only if default behavior needs overriding
- Deliverables: only if non-obvious
Example structure
factorial_calculator_python.prompt
PDD directives
Directives are special XML-style tags that PDD’s preprocessor resolves before sending the prompt to the LLM. The LLM sees the resolved content, not the tags themselves. Processing order:<pdd> → <include> / <include-many> → <shell> → <web>
<include>
Injects the content of a file at that position in the prompt.
<include> when:
- Including a shared preamble that applies to all prompts
- Referencing a dependency’s example file as an interface
- Pulling in authoritative documentation (README, API schema, config reference)
<shell>
Executes a shell command and inlines stdout at that position.
<web>
Fetches a URL (via Firecrawl) and inlines the markdown content.
<pdd> (comment)
A human-only comment. Removed entirely during preprocessing; never reaches the LLM.
The shared preamble pattern
A shared preamble is a file (conventionallycontext/project_preamble.prompt) included at the top of every prompt in the project. It defines your “constitution”: coding style, linting rules, naming conventions, and forbidden libraries.
- Indentation and formatting rules
- Preferred import conventions
- Forbidden libraries or patterns
- Logging and error handling standards
- Security baseline requirements
- Module-specific requirements or constraints
- Business logic or domain rules
- Dependency references specific to one module
Parameterized prompts
Prompt files can contain template variables using$VAR or ${VAR} syntax. Values are provided at generation time via the -e / --env flag.
module_python.prompt
- Only variables explicitly provided via
-eare substituted. All other$text is left unchanged. -e KEY(no=VALUE) reads the value from the current shell environment.-evalues take precedence over same-named OS environment variables during template expansion.
Architecture metadata tags
Prompt files can embed optional metadata tags that sync witharchitecture.json. These enable bidirectional sync between prompt files and the architecture visualization.
<pdd-dependency> declares architectural dependencies that update architecture.json. It is distinct from <include>, which injects file content into the prompt for the LLM’s context. Use both when appropriate — they serve different purposes.Writing effective requirements
Requirements are the core of your prompt. Everything else — coding style, implementation patterns, edge cases — is handled by the shared preamble, grounding, and accumulated tests respectively.Structure (aim for 5–10 items)
- Primary function: what does this module do? (one sentence)
- Input contract: types, validation rules, what’s accepted
- Output contract: types, error conditions, return values
- Key invariants: what must always be true
- Performance constraints: if any (latency, memory, complexity)
- Security constraints: if any (input sanitization, auth requirements)
Before and after
- Too detailed
- Just right
What not to include
| Do not specify | Reason |
|---|---|
| Coding style (naming, formatting, imports) | Handled by shared preamble |
| Implementation patterns (class structure, helpers) | Handled by grounding |
| Every edge case | Handled by accumulated tests |
| Step-by-step implementation instructions | Let the LLM decide unless critical |