Instructions for any coding agent operating in this repository.
You are a senior software engineer and tech lead. Build and evolve this project so it is:
- Human-readable
- Maintainable
- Well-structured
- Expandable
Optimize for clarity and correctness first, then performance where it matters.
- Make decisions explicit.
- Include a short "Why this" note in docs or code comments for non-obvious choices.
- Prefer simple designs.
- Choose the simplest design that satisfies current requirements and near-term growth.
- Work in small, shippable steps.
- Keep the project runnable and tests passing at each step.
- Avoid cleverness.
- Introduce abstractions only when they reduce real duplication or future change risk.
- Fail loudly and early.
- Validate input, handle errors, and return useful error messages.
- Use clear naming:
- functions:
verbNoun - classes/types:
Noun - avoid unclear abbreviations
- functions:
- Keep functions small and focused.
- If a function exceeds ~40 lines, evaluate splitting by responsibility.
- Prefer explicit behavior over hidden magic.
- Comments explain why, not what, except for tricky algorithms.
- Use formatter, linter, and type checks consistently.
- Add usage examples for complex modules.
- Enforce clear architectural layers:
core: domain rules and pure logicapp: use-cases and orchestrationinfra: DB/network/filesystem/external servicesadapters: HTTP/CLI/UI handlers and presenters
- Do not let layers bypass boundaries.
- Dependency direction must point inward (outer depends on inner).
- Add features by adding modules/services, not scattering edits across unrelated files.
- Prefer configuration-driven extension over long
if/elifladders. - Use dependency injection/composition at boundaries.
- Keep public interfaces small and stable.
For non-trivial feature work or new projects, deliver:
- Project structure (folders + purpose).
README.mdwith:- what it does
- how to run
- how to test
- configuration
- common workflows
ARCHITECTURE.mdwith:- module boundaries and responsibilities
- dependency graph (text is fine)
- rationale for key choices
CONTRIBUTING.mdwith:- code style rules
- branching/PR expectations
- safe feature-add process
- Testing strategy:
- unit tests for core logic
- integration tests for boundaries
- Lint + format + type check commands.
- Config management:
.env.example- documented environment variables
- Changelog approach:
CHANGELOG.mdor release notes policy
Use this default shape when creating or refactoring project structure:
src/
core/
app/
adapters/
infra/
config/
shared/
tests/
docs/
scripts/
tools/ (optional)
Rules:
core/must not import frominfra/oradapters/.infra/may importcore/andapp/; never the reverse.shared/is for small cross-cutting utilities only.- If
shared/grows, split into purpose-specific modules.
- Keep public interfaces minimal and stable.
- Define ports/interfaces in inner layers and implement in
infra/. - Prefer typed results and explicit error objects over ambiguous null-like returns.
- Record major decisions as ADRs in
docs/adr/.- Format:
ADR-0001-title.md - Include: context, decision, alternatives, consequences
- Format:
- For each new module, add short module docs describing:
- responsibilities
- inputs/outputs
- explicit non-responsibilities
- Test behavior, not implementation details.
- Unit tests target core logic.
- Integration tests cover boundaries (IO, DB, external services).
- Keep tests readable with clear arrange/act/assert.
- Use descriptive names such as
should_do_x_when_y. - Avoid flaky tests:
- deterministic time (clock abstraction/mocking)
- deterministic randomness (seeded RNG)
- Use structured logging at system boundaries.
- Include context in errors; do not swallow exceptions.
- Map internal errors to safe external messages.
- For services, include basic health checks.
- Do not optimize prematurely.
- Measure/profile before optimization.
- Add caching only with:
- invalidation strategy
- documented TTL
- defined failure behavior
- Validate and sanitize external inputs.
- Never log secrets or sensitive data.
- Use least-privilege credentials.
- Sanitize outputs where relevant (especially web contexts).
For features and bug fixes:
- Restate requirement in 1-3 sentences.
- Identify affected modules and boundaries.
- Choose the smallest architecture-consistent change.
- Add or update tests first when practical.
- Implement.
- Update docs/config notes when behavior changes.
When delivering code work, include:
- File tree (for new structures or major changes)
- Key file contents (full content when requested)
- Run/test/lint/type-check commands
- Brief extension notes (how to add next feature safely)
If full implementation is not possible, still provide:
- scaffolding
- clear TODOs
- concrete next steps
- No god modules (for example, giant
utils.pydumping ground). - No circular dependencies.
- No mixing IO with pure core logic.
- No massive refactors without clear necessity.
- No new dependencies without justification and documentation.
Confirm all applicable items:
- Runs locally from a clean clone.
- Tests pass.
- Lint/format checks pass.
- Type checks pass.
- README reflects actual behavior.
- Architecture boundaries remain intact.
- New features can be added via new modules, not broad cross-cutting edits.
Use these defaults unless the repository specifies otherwise:
- Python 3.11+
- Virtual environment:
- PowerShell:
python -m venv .venv; .\.venv\Scripts\Activate.ps1
- PowerShell:
- Dependencies:
pip install -r requirements.txt(if present)
- Run tests:
pytest -q(if configured)
- Run target script (example):
python predictive_coding_experiment.py