Appendix D: Project Plans and Code Templates
Below is a collection of project plans and code templates referenced throughout this textbook. Rather than embedding all content here, each item is split into its own file for easier navigation and reuse.
Use these templates with sanitized plans and synthetic fixtures. Keep protected data outside the repository, do not paste individual-level records or private paths into LLM prompts, and run generated code against real data only in the approved environment.
flowchart TB
accTitle: Appendix D template relationship map
accDescr: A relationship map showing planning materials flowing into coding, review, refactoring, standardization, and documentation resources.
A[Project plan examples] --> B[Coding prompt]
B --> C[Generated R script]
C --> D[Red teaming prompt]
D --> E[Refactoring prompt]
E --> F[R code template]
F --> G[Standardized script]
G --> H[GitHub documentation guidelines]
D.1 Project Plan – Initial Draft
A basic outline covering data ingestion, cleaning, representative record selection, and categorization. It serves as the starting point for iterative improvements.
- See file: ProjectPlan_InitialDraft.md
D.2 Project Plan – Improved Version
In this iteration, the project plan is enhanced with more detailed steps for filtering, validation, and output generation. It refines the initial draft for better clarity and completeness.
- See file: ProjectPlan_Improved.md
D.3 Project Plan – Advanced Version
This synthetic adult tutorial adds validated demographic joins, age-at-measurement eligibility, deterministic record selection, and missingness audits. It uses general descriptive BMI categories without mapping broad EHR race labels to clinical thresholds. The plan includes acceptance criteria and identifies methodological decisions that must be resolved before coding.
- See file: ProjectPlan_Advanced.md
D.4 Coding Prompt for R Script Generation
This prompt guides an AI assistant to generate a reviewable R script using data.table and optparse. It resolves material uncertainties, proceeds to implementation, and asks for verification against synthetic fixtures.
- See file: CodingPromptForRScript.md
D.5 R Code Refactoring Prompt Example
This document demonstrates how to instruct an AI assistant to reformat an existing R script to match a prescribed template’s structure and style guidelines. It emphasizes code readability and robust error handling.
- See file: R_CodeRefactoringPromptExample.md
D.6 R Code Template
This R script template includes metadata, dependency management, command-line argument parsing, core logic, and output saving sections. Adapt and test it against the project’s input/output contract before use.
- See file: R_CodeTemplate.R
D.7 GitHub Repository Documentation Guidelines
This prompt creates a README and script documentation grounded in the repository’s code, existing environment manifests, and verified versions. It covers Miniforge3/Mamba and renv when those tools apply.
- See file: GitHubRepoDocumentationGuidelines.md
D.8 Agent Task Brief and Session Handoff
Use a bounded task brief to specify the goal, editable files, method, commands, and acceptance criteria. For work spanning sessions, preserve decisions and verification evidence in a handoff that the next agent checks against the working tree.