Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,28 @@ htmlcov/
coverage.*
setup.py

# AI
.claude
.cursor
.scratch/
docs/agents/
docs/adr/
CONTEXT.md
# locally installed agent skills (project-owned ones are un-ignored below)
.agents/skills/*
skills-lock.json
# local agent config
.mcp.json
mcp.json
# Added by codegraph
.codegraph
codegraph.mdc
# Added by code-review-graph
.code-review-graph/
# Added by graphify
graphify-out/
.graphifyignore

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
Expand Down
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ building on the workflow provided by `uv init` or `poetry new`.
- [Ruff](https://github.com/astral-sh/ruff) for linting and formatting.
- Preconfigured [prek](https://github.com/j178/prek) hooks, a faster alternative to [pre-commit](https://github.com/pre-commit/pre-commit).
- MIT, BSD-3-Clause, or Apache-2.0 license generation with [lice2](https://github.com/seapagan/lice2).
- `AGENTS.md` with project commands, verification steps, and documentation rules for coding agents.
- Sphinx documentation with the Shibuya theme, Read the Docs configuration, and a GitHub Actions check.
- `llms.txt` and per-page Markdown generated by
[sphinx-llm-friendly](https://github.com/scrapy/sphinx-llm-friendly) for agents reading the library documentation.
- Optional [Context7](https://context7.com/docs/overview) guidance for looking up dependency documentation
and submitting the generated library's published documentation for indexing.

## Installation

Expand Down Expand Up @@ -50,11 +56,33 @@ This installs dependencies and Git hooks while preserving the existing environme
Use `just reinstall` to recreate the environment and remove generated artifacts.

Run `just` to list available commands. `just check-all` checks dependencies, code, formatting,
types, and tests without applying fixes. Use `just format` to format code and `just check`
types, tests, and documentation without applying fixes. Use `just format` to format code and `just check`
to run prek hooks with automatic fixes.
After changing dependencies, run `just install`: check commands do not synchronize the environment
automatically. Use `just upgrade` to update dependency versions and hooks.

## Documentation for agents

Each generated project includes `AGENTS.md` for agents working on its code. The published documentation
also provides `llms.txt`, an index linking to Markdown versions of its pages for agents using the library.

Run `just docs` in the generated project to build HTML, `llms.txt`, and the Markdown pages together in
`docs/_build/html/`. Edit the documentation sources and docstrings; these outputs are generated automatically.
`just docs-check` performs a strict build, runs doctests, and checks that `llms.txt` and `index.md` are nonempty.
The existing documentation workflow runs this command, and Read the Docs publishes the generated files
alongside the HTML pages once the repository is connected.

The generated `AGENTS.md` also guides agents to use Context7, when available, for dependency documentation
matching the versions in `uv.lock`, with a fallback to official documentation or installed sources.
The generated [CONTRIBUTING.md]({{cookiecutter.project_name}}/CONTRIBUTING.md#context7-optional) explains
client setup and submitting the published `llms.txt` to Context7. Maintainers register each library after
publishing its documentation; generation and builds do not register it automatically.
Context7 is optional and requires no additional Python dependency or CI service.

Each generated library also includes `context7.json` for repository-based indexing. It selects `docs/`
and keeps the root README while excluding build output and contributor instructions. The configuration
applies when the repository is submitted as a Context7 source; it does not change the published `llms.txt`.

## Library type

The `type_lib` prompt offers two options:
Expand Down
3 changes: 2 additions & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"_extensions": ["jinja2_git.GitExtension"],
"_copy_without_render": [
".venv",
"docs/_build"
"docs/_build",
"docs/justfile"
]
}
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ test = [
"hatchling>=1.27",
"pytest>=9.1.1",
"pytest-cookies>=0.7",
"pytest-randomly>=5",
"pytest-sugar>=1.1.1",
]
lint = [
Expand Down
16 changes: 16 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions {{cookiecutter.project_name}}/.github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: docs

on:
push:
branches:
- main
paths:
- "docs/**"
- "**/*.py"
- ".github/workflows/docs.yml"
- ".readthedocs.yml"
- "justfile"
- "pyproject.toml"
- "uv.lock"
pull_request:
paths:
- "docs/**"
- "**/*.py"
- ".github/workflows/docs.yml"
- ".readthedocs.yml"
- "justfile"
- "pyproject.toml"
- "uv.lock"
workflow_dispatch:

concurrency:
group: "{% raw %}${{ github.workflow }}-${{ github.head_ref || github.run_id }}{% endraw %}"
cancel-in-progress: true

permissions:
contents: read

jobs:
docs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
version: "0.12.3"
python-version: "{{ cookiecutter.min_version_python }}"
enable-cache: true
- name: Install just
run: uv tool install rust-just
- name: Install dependencies
run: uv sync --locked --all-groups --all-extras
- name: Check documentation
run: just docs-check
6 changes: 6 additions & 0 deletions {{cookiecutter.project_name}}/.pre-commit-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ repos:
- id: ruff-check
args: ["--fix"]
- id: ruff-format
- repo: https://github.com/sphinx-contrib/sphinx-lint
rev: v1.0.2
hooks:
- id: sphinx-lint
args: ["--enable=all", "--disable=line-too-long"]
files: ^docs/
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.13.5
hooks:
Expand Down
17 changes: 17 additions & 0 deletions {{cookiecutter.project_name}}/.readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2

build:
os: ubuntu-lts-latest
tools:
python: "{{ cookiecutter.min_version_python }}"

python:
install:
- method: uv
command: sync
groups: ["docs"]
path: .

sphinx:
configuration: docs/conf.py
fail_on_warning: true
77 changes: 71 additions & 6 deletions {{cookiecutter.project_name}}/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ source of truth for commands; run `just` to list the available recipes.
- Python version for development: `{{ cookiecutter.min_version_python }}`.
- Library code: `{{ cookiecutter.project_name.lower().replace('-', '_') }}/`.
- Tests: `tests/`.
- Documentation: `docs/`.
- Dependencies and tool configuration: `pyproject.toml`.
- Resolved dependency versions: `uv.lock`.
{% if cookiecutter.type_lib == "django" -%}
Expand Down Expand Up @@ -37,22 +38,86 @@ automatically. There is no need to activate `.venv` manually.
| `just type-check` | Run both mypy and Pyright. |
| `just mypy` / `just pyright` | Run one type checker. |
| `just package` | Check the lockfile, installed environment, and dependency compatibility. |
| `just check-all` | Run `package`, `lint`, `type-check`, and `test`. |
| `just docs` | Build the HTML documentation. |
| `just docs-check` | Build documentation strictly and run its doctests. |
| `just docs-linkcheck` | Check external links in the documentation. |
| `just check-all` | Run `package`, `lint`, `type-check`, `test`, and `docs-check`. |
| `just check` | Run prek hooks on all Git-tracked files, with automatic fixes. |

`just lint` and `just format` accept file or directory paths and default to the
entire project. `just test`, `just mypy`, and `just pyright` forward extra arguments
to their tools. The type-checker aliases also have the names `just type-mypy` and
`just type-pyright`.

While working, run the checks relevant to the change. Use `just format` when
formatting or lint fixes are needed, then run `just check-all` before handing off
code changes. Report the checks run and any failures or checks you could not run.
## Code verification

Run verification commands from the repository root:

- Tests: `just test`.
- Linting and formatting check: `just lint`.
- Formatting and automatic fixes: `just format`.
- Static type analysis: `just type-check`.
- Documentation: `just docs-check`.
- Full verification: `just check-all`.

After changing code:

1. Run `just format`.
2. Run the checks relevant to the changed code.
3. Run `just check-all` before committing or handing off the change.
4. Report which checks were run and whether they passed. Include any failures or
checks that could not be run.

`just check` may modify files, including `uv.lock`; inspect its changes. Hooks
also run when committing. After dependency changes, run `just install` and repeat
the checks. `just package` validates dependencies; use `uv build` when a task
requires building wheel and source distributions, since there is no build recipe.
the checks. Unlike `just format` and `just check`, `just check-all` is intended to
verify the project without applying fixes. `just package` validates dependencies;
use `uv build` when a task requires building wheel and source distributions, since
there is no build recipe.

## External dependency documentation

- When a task needs documentation for a dependency's API, behavior, or
configuration, use Context7 if its tools are available.
- Identify the dependency version in `uv.lock` and request documentation for that
version when available. Before the first lockfile is generated, use the
constraints in `pyproject.toml` and state any uncertainty about the exact version.
- Resolve the library's Context7 ID before querying its documentation, unless a
verified ID is already available. Check that examples apply to the project's
dependency version before using them.
- If Context7 is unavailable or lacks the required library or version, consult
official versioned documentation or the installed package's source and
docstrings. Context7 availability must not block development or verification.
- Use this repository's code and documentation to understand the library being
developed; an external index may lag behind local changes.

See [Context7 setup](CONTRIBUTING.md#context7-optional) for optional client setup
and the separate process for indexing this library's published documentation.

## Documentation rules

A change to public behavior is incomplete until its docstrings, guides, and API
reference are updated and `just docs-check` passes. Follow the complete
[documentation guidelines](docs/pages/documentation-guidelines.rst).

- Document every new or changed public module, class, function, method, and
attribute. Do not document private implementation details unless they explain
an important constraint.
- Use Google-style docstrings. Keep types in Python annotations instead of
repeating them in docstrings.
- Include `Args`, `Returns`, `Yields`, and `Raises` only when applicable. Explain
behavior, constraints, side effects, and exceptions rather than restating names.
- Use Sphinx roles such as `:class:`, `:func:`, `:meth:`, `:attr:`, and `:doc:`
for internal references. Prefer fully qualified targets when a reference could
be ambiguous.
- Put stable, executable examples in `.. doctest::` blocks. Use `.. code-block::`
for illustrative examples that require network access, nondeterministic values,
external services, or extensive setup.
- Add public modules and objects to `docs/pages/api-reference.rst`; add conceptual
or task-oriented documentation to the appropriate guide and to a `toctree`.
- Never edit generated files under `docs/_build/`.
- Run `just docs-check` after changing public APIs or documentation. Run
`just docs-linkcheck` when adding or changing external links.

## Dependency maintenance and cleanup

Expand Down
Loading
Loading