Skip to content
Public template

About

A template file and folder structure for an AI supported modeling and data science project.

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

Modeling and Data Science (MDS) project template

Overview

This repository contains a template for a reproducible modeling or data science (MDS) project. It is set up to facilitate reproducible and robust workflows that include AI support.

The default tools to use this template for any MDS project are R, Quarto, Git/GitHub, an IDE (e.g. Positron) and an agentic AI tool. The template structure is workflow-first, so projects can add Python, Julia, shell scripts, or other tools without major reorganization.

Pre-Requisites

You should have the tools mentioned above installed and be familiar with them. If not, this website provides brief introductory courses to these tools.

You also want a reference manager that can handle BibTeX. Zotero with the Better BibTeX plugin is a good choice.

It is also useful to have a word processor installed, such as MS Word or LibreOffice. To produce PDF output, you need a TeX distribution. TinyTeX is a good option; see the Quarto PDF instructions.

The example files use these R packages: broom, dplyr, flextable, ggplot2, here, knitr, readxl, rmarkdown, skimr, and tidyr. Install them before running the example workflow:

install.packages(c("broom", "dplyr", "flextable", "ggplot2", "here", "knitr",
                   "readxl", "rmarkdown", "skimr", "tidyr"))

Getting Started

See new-project-instructions.md for a brief getting started guide.

Template Structure

The template comes with a folder structure and example files to show the kinds of content you would place in each folder. See the folder-specific readme files for more detail.

  • ai/: AI workflow notes, an AI-use policy, and an AI-use log. See ai/readme-ai.md.
  • assets/: static non-code materials such as references, reference style files, PDFs, and manually created figures. See assets/readme-assets.md.
  • code/: code organized by workflow stage. See code/readme-code.md.
  • data/: everything related to different types of data, such as raw, processed, private, and large data folders. See data/readme-data.md.
  • products/: final or near-final deliverables such as reports, manuscripts, presentations, posters, and apps. See products/readme-products.md.
  • results/: outputs automatically generated by code, such as simulation/analysis results, figures, tables. See results/readme-results.md.

Important project-level files:

  • readme.md: this project overview.
  • .here: project-root marker used by the R here package so scripts and Quarto files can find project-relative paths even outside a Git checkout. It can be kept even if R or the here package are not used.
  • new-project-instructions.md: instructions for creating a new project from this template.
  • usage.md: instructions for running and reproducing the project.
  • code-guidelines.md: coding guidelines for scientific and reproducible projects, including documentation, failure behavior, simplicity, packages, and AI-assisted coding expectations.
  • agents.md: the main repository-level instructions for AI coding assistants; AI agents should read this file before working in the project.
  • license.md: the license for this template, or later for your project.

Naming Conventions

Use descriptive file and folder names. In general:

  • use lower-case names;
  • separate words with -;
  • avoid spaces, underscores, and CamelCase unless a standard file name or file extension requires otherwise.

Readme files are named by folder context, such as readme-code.md or readme-data.md.

Git/GitHub and Sensitive Information

Git and GitHub are useful for tracking changes, backing up work, and sharing a project with other users. While you could use this template without Git/GitHub tracking, in the following it is assumed that you'll be using Git/GitHub.

Before using this template and starting a project, you should familiarize yourself with Git/GitHub at least a little bit, e.g. by going through this brief Git/GitHub introduction.

An important feature of Git/GitHub is the tracking of changes (what Git does) and syncing those changes between local machines and a remote server (what GitHub provides). In Git/GitHub language, you commit project updates, then push/pull between local computer(s) and the remote. Once anything has been committed (e.g., a file has been added) and pushed to GitHub, it can be difficult to fully remove from the history, especially if the repository has been shared.

This might raise questions of confidentiality and the risk of accidentally publicly sharing information that should not be public. Because of this, for many projects, it is wise to start with a private GitHub repository. Later, after checking the data, outputs, license, authorship, and project goals, you can decide whether the repository should remain private or become public.

Do not commit private, sensitive, regulated, identifiable, restricted, or license-protected data unless the project owner has explicitly approved that workflow. A private GitHub repository is not the same as a secure data system or an IRB/DUA-approved storage plan. If the repository stays private because it contains or depends on restricted material, document what can be committed and what must stay local or in an approved storage location.

To keep files out of Git, and thus avoid potentially making them public, list them in .gitignore before committing them. For example, this template already ignores the contents of data/private-data/, apart from the readme file, which is included.

If a file has already been committed, adding it to .gitignore is not enough; it must also be removed from Git tracking while leaving the local file in place. See GitHub's documentation on ignoring files for more detail.

In general, any raw or processed data is likely the potentially most sensitive part of your project. Some generated outputs might also contain sensitive information. Check carefully, then decide if what you have can be 1) fully public, 2) private but ok to check into GitHub, 3) so sensitive that you don't want to push it to GitHub, even inside a private repository.

Git/GitHub and large files

Do not try to use Git/GitHub with large files! As a rule of thumb, anything larger than 20MB should not be tracked and synced with Git/GitHub. There are specialized options to work with large files, such as Git LFS. If you think you might have to work with large files, review the relevant information in the brief Git/GitHub introduction course.

This project template is set up to allow for large files, with currently the folders data/large-files/, and results/large-files/ being ignored by Git/GitHub, while keeping small readme or placeholder files in those folders.

Generated Outputs And What Gets Committed

By default, this template commits the outputs that code generates. That includes the computed results, figures, and tables in results/, the processed data in data/processed-data/, and the rendered products such as manuscript.html, optional manuscript.docx, supplementary-material.pdf, and presentation.html. The manuscript template also serves as an analysis report, with HTML as the default output and Word available from the same source. See usage.md for rendering commands.

The reason is convenience for readers. Someone who opens the repository can see the expected results and read the finished products without installing the software and rebuilding everything first. It also makes it easy to notice when a rerun changes a result unexpectedly.

There are two costs to be aware of. Binary outputs such as .docx, .pdf, .rds, and .png files usually record a new version in the project history every time they are regenerated, even when nothing meaningful changed, so the repository grows over time. And a generated output can be sensitive even when the code is not, so outputs need the same privacy check as data.

The exceptions are described elsewhere in this file and in results/readme-results.md: do not commit large outputs, and do not commit outputs containing sensitive, private, regulated, identifiable, or otherwise restricted information.

If you would rather not track generated outputs in your project, add the relevant patterns to .gitignore. For example, to stop tracking rendered products and generated figures:

products/**/*.html
products/**/*.docx
products/**/*.pdf
results/figures/*.png

Adding a pattern only prevents future commits. Files that are already committed must also be removed from Git tracking, while keeping your local copy:

git rm --cached products/manuscript/manuscript.docx

If you do stop committing generated outputs, say so in usage.md, so users know they need to run the workflow themselves before anything is available.

Software And Package Management

Document the software and package/library setup your project needs. The default example uses manually installed R packages because that is easiest. It can be suitable for small projects.

In general, you can think of levels of package/software management and use the one that's best for your project. It is possible to switch, but easier to pick the appropriate one early on.

This is a quick overview of the different levels:

  • Manual package list: the default for this template. List required packages prominently in user-facing documentation.
  • Lockfile or environment manager: use tools such as renv, Conda, Python virtual environments, or Julia project files when exact package versions matter for longer-term work. Commit the lock or project files needed to restore the environment, but do not commit local package libraries or virtual environments.
  • Continuous Integration or containers: use GitHub Actions, Docker, or similar tools for advanced long-term, multi-user, multi-language, publication, or regulated workflows that need controlled reruns across machines.

This repository template assumes you will start with a manual approach, and add any more advanced software management pieces yourself, based on needs.

Code should load the needed packages and fail clearly when a package is missing. In general, there should not be any silent install of packages or other environment modification done by code.

As a lightweight reproducibility aid, final products may include optional software/session information, such as sessionInfo() or sessioninfo::session_info(), when that information would help readers or users understand the computing environment.

Code Guidelines

Code should be written for scientific and reproducible workflows. That means it should be transparent, reproducible, simple, heavily documented, and strict about unexpected inputs or missing requirements. See code-guidelines.md for the full coding guidelines that apply to both humans and AI tools.

AI-Supported Workflow

Overview

This project is set up such that AI tools can be used at any level of intensity - from not at all to letting the AI tool perform most of the work and focus on guiding and assessing its work.

AI tools can be used widely for tasks such as helping write and explain code, improving documentation, helping with exploratory data analysis, suggesting analysis options, reviewing project components, and more.

That said, such tools should not be trusted blindly. Human users need to guide, assess and decide. In the end, you need to be able to fully stand behind your results, and for that you need to be in charge and understand what the AI suggests and implement at a level where you are comfortable explaining and defending your project approaches and results.

AI Use

When using AI tools:

  • Use AI tools in agentic mode, such that they can read/write files inside the repo, and run commands on your computer (either in a sandboxed environment, or directly on your machine - the latter tends to be more powerful but also riskier).
  • Tell the AI to start by reviewing the project and the files. Most importantly, point the tool to readme.md, usage.md, agents.md, code-guidelines.md, and relevant files in ai/.
  • Do not paste sensitive, private, regulated, or identifiable data into external AI tools unless the project owner has explicitly approved that workflow.
  • Ask for small, reviewable changes.
  • Follow ai/ai-use-policy.md for AI-use expectations.
  • AI tools should write concise entries to ai/ai-use-log.md for meaningful project-specific AI-assisted work. Logging is enabled by default once the repository has been renamed for a new project, unless the project owner asks to turn it off. Human users may read the log as needed, but are not expected to write or edit it.

Running code and rendering products

AI tools working in this project do not run scripts or render Quarto documents on their own. They only do so when you ask for it, or when your request clearly requires it.

This is deliberate. Running code can overwrite generated results and products, and can take a long time. You should be the one deciding when that happens.

The practical consequence is that a change to analysis code can leave the saved results and rendered products out of date. When that is the case, the AI tool should tell you which scripts need to be rerun and which products need to be rerendered, and then wait for you to ask. The instructions that produce this behavior live in agents.md.

AI-related files and expected readers/writers

It is strongly advised that you review all of these files fully at least once and adjust to your own needs. Some of these files contain detailed instructions, which might not fit your circumstances and you thus want to update before starting to use AI help.

The starting point is agents.md, which contains a lot of general information. code-guidelines.md tells AI (and humans) how to write code.

The files in ai/ have different expected readers and writers. For example, ai/ai-use-log.md is written by AI tools, while ai/readme-ai.md and ai/ai-use-policy.md are human-facing. See the "File Roles" section of ai/readme-ai.md for the full list.

Project files outside ai/, such as readme.md, usage.md, data/readme-data.md, code/, results/, and products/, are human-facing project materials. Humans should be able to read and understand them. AI tools may help edit or review them, but important scientific, statistical, privacy, and interpretation choices need human review.

GitHub Actions and other automated workflows can be useful for advanced users. They are intentionally not enabled by default in this template because many users will be new to Git and GitHub.

License

This template is licensed under the MIT License. See license.md for the full license text.

The MIT License permits reuse, modification, distribution, and commercial use. That means users may use this template as a starting point for a wide range of projects, including work-related or commercial projects, as long as the license notice is included where required.

That applies to the template's own content. Third-party files bundled with the template, or added to your project later, keep their own licenses, which may be more restrictive. Reference PDFs and images taken from the web are the two cases that most often cause trouble, because both are easy to add without checking whether they may be redistributed. See the "Third-Party Materials" section of license.md before committing material you did not create yourself.

About

A template file and folder structure for an AI supported modeling and data science project.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages