Skip to content

Commit ffb60a1

Browse files
feat: new libraries ship the agents page and the copy-page control (#6)
1 parent dd06c49 commit ffb60a1

14 files changed

Lines changed: 702 additions & 6 deletions

File tree

.claude/LIBRARY_CREATION.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,28 @@ When creating a new library repository:
7373
- First `feat:` commit → Release Please creates v0.1.0
7474
- First `fix:` commit → Release Please creates v0.0.1
7575

76-
## 5. Clean Repository Checklist
76+
## 5. The Agents Page
77+
78+
`docs/agents.md` ships as a skeleton with `TODO` markers. Fill it in before the initial
79+
commit — it is the page a person hands to a coding assistant instead of the whole site,
80+
so an empty one is a broken promise and a wrong one teaches an API that does not exist.
81+
82+
Write it from the source you just wrote, not from the README: every name, argument,
83+
default and return type has to be one that exists, and every name a caller is told to
84+
import has to be importable. Check that before committing:
85+
86+
```bash
87+
uv run python -c "import <package>; [getattr(<package>, n) for n in ('Name', ...)]"
88+
```
89+
90+
`https://bedrock-python.github.io/pg-partsmith/agents/` is the worked example. The
91+
sections that carry the weight are **Scope** (what it does not do stops a model
92+
inventing features), **Rules that hold or break the code** and **Common mistakes**.
93+
Delete a section that has nothing true to say rather than padding it.
94+
95+
Keep the `<!-- ... -->` guidance comment out of the committed page.
96+
97+
## 6. Clean Repository Checklist
7798

7899
Before pushing the initial commit, verify:
79100

@@ -83,8 +104,9 @@ Before pushing the initial commit, verify:
83104
- [ ] No backup files (e.g., `.coverage (копия...)`, `file (copy).py`)
84105
- [ ] No cache files (`.mypy_cache`, `.ruff_cache`, `__pycache__`) - should be in `.gitignore`
85106
- [ ] `.release-please-manifest.json` contains `"0.0.0"`
107+
- [ ] `docs/agents.md` written from the real API, no `TODO` markers, guidance comment removed
86108

87-
## 6. PyPI Publication
109+
## 7. PyPI Publication
88110

89111
Before merging the Release Please PR:
90112

@@ -97,15 +119,16 @@ Before merging the Release Please PR:
97119

98120
2. Merge Release Please PR → automatic publication to PyPI
99121

100-
## 7. Common Mistakes to Avoid
122+
## 8. Common Mistakes to Avoid
101123

102124
❌ Including AI agents in commits
103125
❌ Committing `scripts/setup_repo.py` to the library repo
104126
❌ Starting with version `0.1.0` instead of `0.0.0`
105127
❌ Committing backup/cache files
106128
❌ Creating multiple commits before initial push (messy history)
129+
❌ Shipping `docs/agents.md` with its `TODO` markers still in it
107130

108-
## 8. Summary
131+
## 9. Summary
109132

110133
**Clean initial commit = Clean repository forever**
111134

NEW_LIBRARY_CHECKLIST.md.jinja

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ uv run pre-commit install --hook-type commit-msg
1010
make check # should pass on a fresh repo
1111
```
1212

13+
Then fill in `docs/agents.md`. It ships as a skeleton with `TODO` markers, and it is the
14+
page people hand to a coding assistant instead of the whole site — write it from the API
15+
you actually wrote, verify every name it tells a caller to import, and delete the
16+
guidance comment at the top. `https://bedrock-python.github.io/pg-partsmith/agents/` is
17+
the worked example. `CONTRIBUTING.md` keeps it current from there.
18+
19+
```bash
20+
make docs-build # the page is in the nav, so the build fails without it
21+
```
22+
1323
## Step 2 — Create GitHub repo and push
1424

1525
```bash

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ See [`.claude/LIBRARY_CREATION.md`](.claude/LIBRARY_CREATION.md) for important r
7272
- `Makefile` — fmt, check, test-unit, test-integration, test, build, docs-serve, docs-build
7373
- `.github/workflows/` — CI (lint + unit + integration), publish to PyPI, deploy docs, Release Please
7474
- `.github/` — dependabot, issue templates, PR template
75-
- `docs/` — zensical (MkDocs Material) setup with mkdocstrings
75+
- `docs/` — zensical (MkDocs Material) setup with mkdocstrings, a **Copy page** control that
76+
hands any page to an LLM as Markdown, and `docs/agents.md`, the one-page brief for coding
77+
assistants (ships as a skeleton — fill it in)
7678
- `.pre-commit-config.yaml` — ruff, mypy, conventional commits
7779
- `release-please-config.json` — automated semver + CHANGELOG generation

template/.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
- [ ] Tests added or updated
1616
- [ ] `make check` passes locally (`ruff` + `mypy`)
1717
- [ ] `CHANGELOG.md` updated under `[Unreleased]`
18-
- [ ] Documentation updated (if the public API changed)
18+
- [ ] Documentation updated (if the public API changed), `docs/agents.md` included
1919

2020
## Related issues
2121

template/.github/workflows/docs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
- run: uv sync --no-dev --group docs
1919
- run: cp CHANGELOG.md docs/changelog.md
2020
- run: uv run zensical build --clean
21+
- run: uv run python scripts/emit_markdown.py
2122
- uses: actions/upload-pages-artifact@v5
2223
with:
2324
path: site

template/CONTRIBUTING.md.jinja

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,26 @@ Breaking changes: add `!` after the type (`feat!:`) or include a `BREAKING CHANG
5252
4. Run `make check && make test-unit` locally
5353
5. Open a PR against `master`
5454

55+
## The agents page
56+
57+
`docs/agents.md` is the whole library on one page, written for a coding assistant: the
58+
public API, the rules that break code when they are broken, the mistakes models make, and
59+
a map of which page to fetch for the rest. People hand it to an assistant instead of the
60+
site, which is what makes a stale one worse than none — it teaches a model an API that no
61+
longer exists.
62+
63+
It is part of the public API, so it changes in the same pull request the API does: a name
64+
added, renamed or removed, a changed default or signature, a new rule a caller has to
65+
obey. A new docs page means a new row in the documentation map. The review check is
66+
mechanical — if the diff changes the public surface and `docs/agents.md` is untouched, the
67+
pull request is not finished.
68+
69+
The page carries its own weight only if it stays fetchable as text. Every page of the site
70+
is written a second time as raw Markdown next to its HTML by `scripts/emit_markdown.py`,
71+
which the Docs workflow runs after the build; the **Copy page** control above each page
72+
reads those files. A page whose Markdown would not read as the page — the generated API
73+
reference — declines both with `copy_page: false` in its front matter.
74+
5575
## Releasing (maintainers only)
5676

5777
Releases are fully automated via [Release Please](https://github.com/googleapis/release-please).

template/README.md.jinja

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
[![codecov](https://codecov.io/gh/{{ github_org }}/{{ project_slug }}/graph/badge.svg)](https://codecov.io/gh/{{ github_org }}/{{ project_slug }})
1010
[![Docs](https://img.shields.io/badge/docs-online-blue)](https://{{ github_org }}.github.io/{{ project_slug }}/)
1111

12+
> [!TIP]
13+
> **Building this with an AI assistant?** Hand it
14+
> **[one page](https://{{ github_org }}.github.io/{{ project_slug }}/agents/)** instead of the
15+
> whole site: the public API, the rules that break code when they are broken, the mistakes
16+
> models make, and a map of which page to fetch for the rest. Every docs page is also served
17+
> as raw Markdown at its own URL, and a **Copy page** button at the top of each one hands it
18+
> straight to a chat window.
19+
1220
## Installation
1321

1422
```bash
@@ -27,6 +35,10 @@ pip install {{ project_slug }}
2735

2836
Full documentation at [{{ github_org }}.github.io/{{ project_slug }}](https://{{ github_org }}.github.io/{{ project_slug }}/).
2937

38+
- [Guide](https://{{ github_org }}.github.io/{{ project_slug }}/guide/quickstart/) — quick start, configuration, the advanced corners
39+
- [API reference](https://{{ github_org }}.github.io/{{ project_slug }}/reference/) — every public name, generated from the docstrings
40+
- [For AI agents](https://{{ github_org }}.github.io/{{ project_slug }}/agents/) — the whole API surface, the rules that break code when broken and a map of the rest, on one page to hand to a coding assistant
41+
3042
## License
3143

3244
Apache 2.0 — see [LICENSE](LICENSE).

template/docs/agents.md.jinja

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<!--
2+
This page is the one people hand to a coding assistant instead of the whole site,
3+
which is what makes an inaccurate one worse than none: it teaches a model an API
4+
that does not exist. Two rules while filling it in.
5+
6+
Write it from the source, not from memory. Every name, argument, default and
7+
return type here has to be one you read in {{ package_name }}/, and every name a
8+
caller is told to import has to be importable. Delete a section that carries
9+
nothing rather than padding it.
10+
11+
Keep it current. CONTRIBUTING.md says this page changes in the same pull request
12+
the public API does; the pull request checklist names it. That promise is the only
13+
thing keeping the page worth handing over.
14+
15+
bedrock-python.github.io/pg-partsmith/agents/ is the worked example to copy the
16+
shape from. Delete this comment once the page says something.
17+
-->
18+
19+
# {{ project_name }} for AI agents
20+
21+
> One page holding everything a coding assistant needs to use {{ project_name }}
22+
> correctly, plus a map of where the rest of the documentation keeps the details it
23+
> leaves out. Give an agent this page rather than the whole site.
24+
25+
| | |
26+
|---|---|
27+
| Package | `{{ project_slug }}` on PyPI, import root `{{ package_name }}` |
28+
| Requires | Python {{ python_min_version }}+ |
29+
| Install | `pip install {{ project_slug }}` |
30+
| Source | <https://github.com/{{ github_org }}/{{ project_slug }}> |
31+
32+
## How to read this page
33+
34+
Every page of this site is also served as raw Markdown at its own URL with `.md` in
35+
place of the trailing slash — this page is `/agents.md`, the quick start is
36+
`/guide/quickstart.md` — so anything the map below points at can be fetched as plain
37+
text rather than scraped out of HTML. The **Copy page** control at the top of a page
38+
does the same thing for a human with a chat window open. The one exception is the API
39+
reference: its Markdown is a list of instructions to a docstring renderer rather than
40+
the API, so it carries neither the control nor a `.md` twin — read it as HTML, or read
41+
the docstrings in the source.
42+
43+
Top to bottom before writing code. [Rules that hold or break the code](#rules-that-hold-or-break-the-code)
44+
is the section correctness lives in — those are the things the library will not save
45+
you from. Every name used below is in the public API; if you need something not listed
46+
here, fetch the page the [documentation map](#documentation-map) points at rather than
47+
guessing a method that sounds plausible.
48+
49+
## Scope
50+
51+
**It does** TODO: what the library is for, in the vocabulary a caller thinks in.
52+
53+
**It does not** TODO: the neighbouring problems it deliberately leaves alone. This
54+
paragraph stops a model from inventing a feature; it is worth more than the one above.
55+
56+
## Mental model
57+
58+
TODO: the handful of nouns the API is built from and the flow between them. Name each
59+
type once and say what it owns.
60+
61+
## Wiring
62+
63+
```python
64+
# TODO: the shortest correct working example, imports included. It has to run.
65+
```
66+
67+
## API
68+
69+
TODO: tables, not prose. Every public name a caller needs, with its arguments, their
70+
defaults and what comes back. Read the defaults out of the source rather than
71+
remembering them.
72+
73+
| Name | Arguments | Returns |
74+
|---|---|---|
75+
| | | |
76+
77+
## Rules that hold or break the code
78+
79+
TODO: numbered, one rule per item, each one a thing the library will not save a caller
80+
from — an object that must not be shared, an argument whose default surprises people, a
81+
call that has to be repeated until it says it is finished, a lifetime that is the
82+
caller's to manage. Write the ones that are true here, not the ones that sound wise.
83+
84+
## Common mistakes
85+
86+
```python
87+
# WRONG — TODO: the mistake a model actually makes with this API
88+
89+
# RIGHT — TODO: the same thing, done properly
90+
```
91+
92+
## Errors
93+
94+
TODO: the exception classes, what each one means, and what a caller should do about it.
95+
96+
## Documentation map
97+
98+
Fetch a page when the task is the one named beside it.
99+
100+
| Page | Read it when |
101+
|---|---|
102+
| [Quick start](guide/quickstart.md) | writing the first integration end to end |
103+
| [Configuration](guide/configuration.md) | every setting, type and default |
104+
| [Advanced](guide/advanced.md) | TODO: what this page actually covers |
105+
| [API reference](reference/index.md) | an exact signature or docstring — HTML only, see above |
106+
| [Changelog](changelog.md) | what changed between versions |

0 commit comments

Comments
 (0)