feat(generator): scaffold AGENTS.md + a write-docs-page skill into consuming sites#37
Merged
Merged
Conversation
…nsuming sites ## Summary An agent dropped into a consuming site today has to reverse-engineer the kit's authoring idioms. This wires the docs-kit authoring contract into every site (and every `docs-kit new` site) in a machine-readable form, maintained in ONE place — the gem's templates — so "document this endpoint" works out of the box. The install generator gains `create_agent_docs`, which writes: - `AGENTS.md` (site root) — the cross-tool authoring contract (the one-command page flow, the `md <<~'MD'` prose idiom, that `DocsUI::Section` owns structure and the TOC, the reference helpers, and the invariants an agent must not break). Idempotent: a fresh file is created whole; an existing one gets only its `<!-- BEGIN/END docs-kit -->` block replaced (the user's own content is never touched); a re-run rewrites only what's between the markers. - `.claude/skills/write-docs-page/SKILL.md` — a Claude Code skill: the task recipe (gather subject → `rails g docs_kit:page` → write sections md-first → self-review → run the gates). Skipped if the site already has one. Frontmatter targets "write / add / update a documentation page". `docs-kit new` inherits both automatically (it runs the install generator). The gem's own repo gets an adapted `AGENTS.md` (dogfooding for agents contributing to docs-kit's docs site). ## Test Coverage - fresh app → AGENTS.md + skill created, brand substituted, core idioms present - skill frontmatter targets "document" + names the page generator - existing AGENTS.md → docs-kit block injected between delimiters, user content preserved - re-run → no duplicate block; a hand-edited AGENTS.md's user sections stay intact - existing skill file → not clobbered ## Verification - [x] bundle exec rspec (459 examples, 0 failures) - [x] bundle exec rubocop (94 files, no offenses) - [x] end-to-end smoke: generated AGENTS.md + skill render with brand substituted Refs #21 Claude-Session: https://claude.ai/code/session_01FPQb6z3YwcKRMbvoJhdxnX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #21.
Problem
The user story behind the epic: "I am one of those developers who won't document" — the fix is letting an agent do the writing while the developer reviews. But an agent dropped into a consuming site today has to reverse-engineer the kit: it doesn't know
mdheredocs are preferred overplainchains, that the registry line is required, thatdocs_kit:pageexists, or that headings belong to Sections.What this does
The install generator gains
create_agent_docs, which scaffolds the docs-kit authoring contract in a machine-readable form — maintained in ONE place (the gem's templates), so "document this endpoint" works out of the box.AGENTS.md(site root) — the cross-tool convention file (Claude Code, Cursor, Copilot, Aider, …). A terse, example-first contract:rails g docs_kit:page),md <<~'MD'single-quoted-heredoc prose idiom,DocsUI::Sectionowns page structure and the "On this page" TOC (never a Markdown##for structure),PropTable/FieldTable/RequestExample/Callout),rubocop:disable).It links the live
/docs/authoringpage for depth..claude/skills/write-docs-page/SKILL.md— a Claude Code skill: the task recipe (gather the subject → run the generator → write sections md-first → self-review against a checklist → run the gates). Frontmatter targets "write / add / update a documentation page," so Claude Code reaches for it automatically.Idempotence (the interesting bit)
AGENTS.mdAGENTS.md<!-- BEGIN docs-kit -->/<!-- END docs-kit -->— user content preserveddocs-kit newinherits both files automatically (it runs the install generator). The gem's own repo gets an adaptedAGENTS.md(dogfooding for agents contributing to docs-kit's docs site).Test plan
New
spec/generators/install_generator_spec.rbblock (AI-authoring scaffold):AGENTS.md+ skill created, brand substituted, core idioms present (rails g docs_kit:page,md <<~'MD',DocsUI::Section),AGENTS.md→ docs-kit block injected between delimiters, user content preserved,AGENTS.md's user sections stay intact,Verification
bundle exec rspec— 459 examples, 0 failuresbundle exec rubocop— 94 files, no offensescreate_agent_docsagainst a throwaway destination — the generatedAGENTS.md(with delimiters) and skill (with valid frontmatter) render with the brand substituted.Out of scope (per the issue)
https://claude.ai/code/session_01FPQb6z3YwcKRMbvoJhdxnX