# Design Repository Layout

> Use when creating a new repository, or when an existing repo's root is cluttered or confusing — newcomers can't find how to build, run, test, or contribute; con

- Skill: `jeffreytse/design-repository-layout` (Agent Skill)
- Install (CLI): `npx get-skill add jeffreytse/design-repository-layout`
- Raw SKILL.md: https://api.skillmd.com/api/skills/jeffreytse/design-repository-layout/raw
- Safety review: pending
- Works with: any agent that reads SKILL.md (Claude Code, Claude.ai, Cursor, Codex, Windsurf, 60+ more)
- Category: Coding & Dev Tools
- Author: jeffreytse (https://skillmd.com/u/jeffreytse)
- Updated: 2026-12-03
- Page: https://skillmd.com/skills/jeffreytse/design-repository-layout

---

---
name: design-repository-layout
description: Use when creating a new repository, or when an existing repo's root is cluttered or confusing — newcomers can't find how to build, run, test, or contribute; config files, scripts, and docs are scattered; or source and tooling are mixed at the top level.
source: 'GitHub Docs, "About community profiles for public repositories" and "About code owners"; Python Packaging Authority, "src layout vs flat layout", Python Packaging User Guide; Go Team, "Organizing a Go module", go.dev/doc/modules/layout, 2023; Wiggins, "The Twelve-Factor App", 2011; Lacan, "Keep a Changelog"; EditorConfig.org'
tags: [project-structure, repository-layout, onboarding, developer-experience, documentation, conventions]
related: [design-backend-project-structure, design-frontend-project-structure, design-monorepo-structure, apply-convention-over-configuration, write-changelog]
---

# Design Repository Layout

Give every repository a predictable top level: a clear entry point for humans (README), one obvious place each for source, tests, docs, scripts, and CI, and a single command to build, test, and run.

## Why This Is Best Practice

**Adopted by:**
- GitHub's community-profile checklist (README, LICENSE, CONTRIBUTING, CODE_OF_CONDUCT, SECURITY, issue/PR templates).
- The official layout guidance of language ecosystems: the Go team's "Organizing a Go module", the PyPA's src layout, Maven's Standard Directory Layout, and Cargo's conventions.
- Large open-source foundations (CNCF, Apache), which require these files for project graduation.

**Impact:**
- A conventional layout cuts onboarding time: contributors and tools (IDEs, CI, package managers, security scanners) find things without project-specific knowledge.
- The PyPA recommends the src layout specifically because it prevents tests from accidentally importing the uninstalled local copy, a common class of "works on my machine" bug.

**Why best:**
- Every repo has the same questions: what is this, how do I run it, how do I contribute, who owns it.
- Answering them with standard file names in standard places means zero lookup cost. Custom layouts force every reader to reverse-engineer the project.

Sources: GitHub Docs (community profiles, CODEOWNERS). PyPA Packaging User Guide, "src layout vs flat layout". Go Team (2023), "Organizing a Go module". Maven, "Introduction to the Standard Directory Layout". Wiggins, A. (2011), *The Twelve-Factor App*.

## Steps

1. **Start from the language or framework's official layout.** Generate with the official scaffolder (`cargo new`, `go mod init`, `uv init --package`, `npm create vite`, Spring Initializr, `dotnet new`). Deviate only with a reason.

2. **Use a standard top level.** Include only what applies:
   ```
   .github/            # CI workflows, issue/PR templates, CODEOWNERS, dependabot
   docs/               # architecture, ADRs (docs/adr/), runbooks, guides
   scripts/            # dev/ops scripts (bootstrap, seed, release)
   src/ | cmd/ | app/  # source (per ecosystem convention)
   tests/              # if the ecosystem doesn't colocate tests
   deploy/ | infra/    # Dockerfile(s), Helm/k8s, Terraform (or a separate repo)
   .editorconfig
   .gitignore
   .env.example        # documented config keys, never real secrets
   Makefile | justfile | package.json scripts | Taskfile.yml
   README.md
   CONTRIBUTING.md
   CHANGELOG.md
   LICENSE
   SECURITY.md
   ```

3. **Write the README as the front door.** In this order:
   - one-line purpose
   - quick start (clone, install, run in 3 commands or fewer)
   - how to test
   - configuration
   - project layout map (a short tree with one line per folder)
   - links to docs, CONTRIBUTING, and the license

4. **Provide one task runner** with standard verbs: `make setup`, `make dev`, `make test`, `make lint`, `make build`. CI calls the same targets, so local and CI behavior match.

5. **Keep config out of code and secrets out of git.** Read config from the environment (Twelve-Factor III). Commit `.env.example` with every key documented. Add `.env` to `.gitignore`. Scan for secrets in CI (gitleaks, GitHub secret scanning).

6. **Declare ownership and quality gates:**
   - `CODEOWNERS` for review routing.
   - Pinned tool versions (`.tool-versions`, `.nvmrc`, `rust-toolchain.toml`, `go.mod` toolchain).
   - Lockfiles committed for applications.
   - Formatter and linter config at the root, enforced by pre-commit hooks and CI.

7. **Record decisions.** Keep architecture decision records in `docs/adr/` (see `write-adr`) and a CHANGELOG following Keep a Changelog (see `write-changelog`).

8. **Keep the root lean.** Move tool configs into `package.json`/`pyproject.toml` where supported. Group generated output under ignored folders (`dist/`, `build/`, `target/`, `coverage/`).

## Rules

- A newcomer can go from clone to running tests using only the README.
- One canonical command per task, used by both humans and CI.
- No secrets, build artifacts, or IDE-specific files in git.
- Follow the ecosystem's convention before inventing your own.
- Every top-level folder has a one-line explanation in the README layout map.

## Common Mistakes

- **README that only says the project name.** Readers can't run anything.
- **Copying the unofficial "golang-standards/project-layout".** The Go team has said it isn't an official standard. Use go.dev's module layout guide and add `pkg/` or `internal/` only as needed.
- **Committed `.env` files.** Leaked credentials. Rotate immediately and purge from history.
- **Scripts with hidden prerequisites.** Pin versions and document requirements in `setup`.
- **Twenty dotfiles at the root.** Consolidate configs where the tools allow.

## Examples

**Python service:** `src/myservice/`, `tests/`, `pyproject.toml` (deps, ruff, pytest config), `uv.lock`, `Makefile` with `setup/dev/test/lint`, `.env.example`, `docs/adr/0001-use-postgres.md`, `.github/workflows/ci.yml` calling `make lint test`.

**Go CLI:** `go.mod`, `main.go` at the root for a single binary (or `cmd/<name>/main.go` for several), `internal/` for private packages, `README.md` with an install line (`go install …@latest`).

## When NOT to Use

- **Throwaway scripts and gists.** A README line is enough.
- **Repos governed by an organizational template.** Follow the template and propose changes upstream.

