feat(skills): add general write-readme skill

- feat(skills): detect ecosystem from marker files (py/r/node/rust/generic)
- feat(skills): add shared readme.template.md generalizing the py card layout
- docs(skills): add REFERENCE.md with per-ecosystem extraction snippets
- generalizes write-readme-py, which stays as the worked python example
This commit is contained in:
Łukasz Boryń 2026-06-17 10:10:26 +02:00
parent f4fbf1438c
commit 5ea282ec03
3 changed files with 190 additions and 0 deletions

View File

@ -0,0 +1,72 @@
# write-readme — per-ecosystem extraction
What to read for each ecosystem, and the `<install-block>` /
`<usage-block>` snippet to emit. Fill `<...>` from the source; omit a line
when its source is absent.
## python (`pyproject.toml`)
Read: `project.name`, `project.description`, `project.dependencies`,
`dependency-groups.dev`, `project.license`. Task runner: `justfile`
recipes (group by `# ── Section ──` comments).
```
## Installation
Requires Python ≥ 3.11. Install with [uv](https://docs.astral.sh/uv/):
uv pip install -e "." # core: <core-deps-csv>
uv pip install -e ".[dev]" # + dev tools: <dev-deps-csv>
```
Usage = `just` recipes. For the full `[dev]`-extras treatment defer to
[`../write-readme-py/SKILL.md`](../write-readme-py/SKILL.md).
## r-package (`DESCRIPTION`)
Read: `Package`, `Title`, `Description`, `Imports`, `License`.
```
## Installation
# install.packages("remotes")
remotes::install_github("<owner>/<Package>")
```
Usage = exported functions / vignette entry points.
## r-analysis (`_targets.R`)
Read: title/description from `index.qmd` front matter or `_targets.R`
header comment. Pipeline targets from `_targets.R`.
```
## Installation
renv::restore() # reproduce the recorded library
```
Usage = `targets::tar_make()` plus the `justfile` recipes that wrap it.
## node (`package.json`)
Read: `name`, `description`, `dependencies`, `devDependencies`, `license`,
`scripts`.
```
## Installation
npm install # or pnpm / yarn
```
Usage = the `scripts` block (`npm run <name>`).
## rust (`Cargo.toml`)
Read: `package.name`, `package.description`, `package.license`,
`dependencies`.
```
## Installation
cargo build --release
```
Usage = `cargo run` / installed binary, or `justfile` recipes.
## generic (no manifest)
Config / script / dotfile repos (e.g. shell installers, system configs).
Read: every script's leading comment, `Makefile`/`justfile`, and any
existing README. Ask the user for a one-line description if none is
inferable.
- `<install-block>` → "Clone the repo" or the prerequisite packages.
- `<usage-block>` → the actual setup commands, in order, **verbatim**.
- Group long setup guides under `##` headings per concern (drivers,
browser, display, prompt, …) and link them from the table of contents.
- `<project-layout>` → annotate each top-level script/dir with its role.

View File

@ -0,0 +1,68 @@
---
name: write-readme
description: Generate a README.md for any project by detecting its ecosystem from marker files (pyproject.toml → python, DESCRIPTION → R package, _targets.R → R analysis, package.json → node, Cargo.toml → rust, none → generic/shell). Reads the manifest and task runner to populate name, description, install steps, usage commands, and license, then materialises a README from a shared template and stops on `jj diff` for review. Use when the user says "write readme", "/write-readme", "generate readme", "document the project".
---
# write-readme
## When to use
- Any project needs a README and you do not know its ecosystem up front.
- User says "write readme", "/write-readme", "generate readme",
"document the project".
- For a confirmed Python project, the dedicated
[`../write-readme-py/SKILL.md`](../write-readme-py/SKILL.md) carries the
fuller `[dev]`-extras handling — prefer it once python is established.
## Process
1. **Detect ecosystem** (first marker wins; ask if none or several):
| Marker | Ecosystem | Source of truth |
|---|---|---|
| `pyproject.toml` | python | `[project]` + `justfile` |
| `DESCRIPTION` | r-package | `DESCRIPTION` fields |
| `_targets.R` | r-analysis | `index.qmd` / `_targets.R` + `justfile` |
| `package.json` | node | `package.json` (name/description/scripts) |
| `Cargo.toml` | rust | `[package]` + `cargo`/`justfile` |
| *(none of the above)* | generic | scripts, `Makefile`/`justfile`, repo files |
Field-by-field extraction per ecosystem lives in
[REFERENCE.md](REFERENCE.md).
2. **Read sources, never memory.** Pull `name`, `description`, `license`,
dependencies, and runnable commands from the files above. For a generic
repo, read the scripts and any existing README to learn what it does.
3. **Refuse to invent.** If the description is empty, ask the user for a
one-line description before writing. Never fabricate dependency
versions, deps not listed, recipes not in the task runner, or commands
not in the repo. Keep shell commands **verbatim** — they are the
author's tested values; flag anything suspect instead of "fixing" it.
4. **Materialise `README.md`** from
[`readme.template.md`](readme.template.md):
- `<project.name>`, `<project.description>`, `<project.overview>`,
`<project.license.text>`.
- `<install-block>` — the ecosystem's install snippet (REFERENCE.md).
- `<usage-block>` — task-runner recipes (grouped by section comment),
CLI invocation, or setup steps for a config/script repo.
- `<project-layout>` — the real top-level tree, annotated.
- **Omit** any section with no source data instead of padding it.
5. **Stop. Do not commit.** Tell the user:
> "Review with `jj diff`. Check that the Installation and Usage blocks
> match how you actually run this. Describe with `/jj-atomic` when
> satisfied."
## Guardrails
- **Never** invent versions, dependencies, recipes, or commands.
- **Never** rewrite a tested shell command — quote it as-is, flag doubts.
- **Never** commit; stop after writing the file.
- **Omit** empty sections rather than hallucinating content.
## See also
- [`../write-readme-py/SKILL.md`](../write-readme-py/SKILL.md) — the
worked python example and `readme-py.template.md` this skill generalizes.
- [`../../scaffold/containerize-project/SKILL.md`](../../scaffold/containerize-project/SKILL.md)
— same marker-file ecosystem detection.
- [`../../productivity/jj-atomic/SKILL.md`](../../productivity/jj-atomic/SKILL.md)
— the commit step this skill hands off to.

View File

@ -0,0 +1,50 @@
# <project.name>
<table>
<tr>
<td width="40%" align="center">
<h3><project.name></h3>
<p><project.description></p>
</td>
<td width="60%">
## Table of Contents
- [Overview](#overview)
- [Installation](#installation)
- [Usage](#usage)
- [Project layout](#project-layout)
- [License](#license)
</td>
</tr>
</table>
<!-- Overview: 1–2 sentences. Omit if project.description already says it all. -->
## Overview
<project.overview>
<!-- Installation: the ecosystem block. Pick ONE and delete the rest.
See REFERENCE.md for what each ecosystem reads and emits. -->
## Installation
<install-block>
<!-- Usage: how to run the thing — task-runner recipes, CLI invocation,
or setup steps for a config/script repo. Omit if there is nothing
to run. -->
## Usage
```bash
<usage-block>
```
## Project layout
```
<project-layout>
```
## License
<project.name> is licensed under <project.license.text>.