From e00096cb96c8fdf404e3ef6c7d04378d24505330 Mon Sep 17 00:00:00 2001 From: Daniel Kindl Date: Wed, 25 Nov 2026 17:04:50 +0100 Subject: [PATCH 1/2] docs(tips): add the first tips Closes #367 --- AGENTS.md | 1 + CHANGELOG.md | 1 + README.md | 1 + test/tips.test.mjs | 29 +++++++++++++++++++ test/triage-routes.test.mjs | 6 ++-- tips/index.md | 55 +++++++++++++++++++++++++++++++++++-- 6 files changed, 88 insertions(+), 5 deletions(-) create mode 100644 test/tips.test.mjs diff --git a/AGENTS.md b/AGENTS.md index e6406b9..a20e09e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -63,6 +63,7 @@ Every rule in [workflow/safety.md](workflow/safety.md) is a hard limit. For exam - [versioning/index.md](versioning/index.md): Semantic versioning. - [writing/index.md](writing/index.md): Writing style (ASD-STE100). - [skills/index.md](skills/index.md): Skills to apply. +- [tips/index.md](tips/index.md): Short tips and tricks. A tip is not a rule. - [workflow/index.md](workflow/index.md): Workflow: issues, review and merge, safety and subagents. ## Key rules diff --git a/CHANGELOG.md b/CHANGELOG.md index 13bf9cc..2a0ef1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ change that a consumer must act on has a "Consumer action:" line. - `scripts/check-maps.mjs --diff` (#317). A change to `docs/maps/` fails when it also changes a file outside `docs/maps/`, `docs/adr/` and `CONTEXT.md`, or when it deletes a map. The `validate` workflow runs it. +- The first tips in `tips/index.md` (#367): check the exit code of each step, check for a breaking change before you push, and find worktrees and branches that are left. AGENTS.md "Sections" and the README list `tips/index.md`. - A test fails for a page in a section folder that no file in `test/` names (#314). The 41 pages that had no test get one in `test/section-pages.test.mjs`. - A test checks the example progress block in `learning/progress.md` (#315). It parses the block diff --git a/README.md b/README.md index c599610..ab6249a 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,7 @@ script checks the verdict, the head SHA and each finding. - [versioning/](versioning/index.md): Semantic versioning. - [writing/](writing/index.md): Writing style (ASD-STE100). - [skills/](skills/index.md): Skills for agents. +- [tips/](tips/index.md): Short tips and tricks. - [workflow/](workflow/index.md): Issues, review and merge, and safety. - [ADR 0001](docs/adr/0001-how-consumers-follow-versions.md): How consumers follow versions. The ADRs are in `docs/adr/`. diff --git a/test/tips.test.mjs b/test/tips.test.mjs new file mode 100644 index 0000000..e70aae0 --- /dev/null +++ b/test/tips.test.mjs @@ -0,0 +1,29 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { fileURLToPath } from "node:url"; +import { dirname, join } from "node:path"; +import { readFile, sectionText } from "./helpers.mjs"; + +const root = join(dirname(fileURLToPath(import.meta.url)), ".."); + +async function text(path) { + return readFile(join(root, path), "utf8"); +} + +test("tips/index.md has the first tips and no placeholder", async () => { + const tips = await text("tips/index.md"); + assert.ok(!tips.includes("(None yet."), "placeholder is still there"); + for (const [heading, parts] of [ + ["## Check the exit code of each step", ["last command", "pipefail", "set -e"]], + ["## Check for a breaking change before you push", ["check-breaking.mjs", "TITLE="]], + ["## Find worktrees and branches that are left", ["git worktree list", "[gone]", "review-and-merge.md#after-the-merge"]], + ]) { + const section = sectionText(tips, heading); + for (const part of parts) assert.ok(section.includes(part), `${heading}: missing ${part}`); + } +}); + +test("AGENTS.md lists tips/index.md", async () => { + const sections = sectionText(await text("AGENTS.md"), "## Sections"); + assert.ok(sections.includes("(tips/index.md)"), "AGENTS.md does not list tips/index.md"); +}); diff --git a/test/triage-routes.test.mjs b/test/triage-routes.test.mjs index a61cde5..bc7ad85 100644 --- a/test/triage-routes.test.mjs +++ b/test/triage-routes.test.mjs @@ -46,11 +46,11 @@ test("triage links AGENTS.md Precedence for a rule conflict and does not restate assert.doesNotMatch(rules, /more specific rule/); }); -test("AGENTS.md lists the learning section and not the empty tips section", async () => { +test("AGENTS.md and README.md list the learning section and the tips section", async () => { const sections = section(await read("AGENTS.md"), "## Sections"); assert.match(sections, /\[learning\/index\.md\]\(learning\/index\.md\)/); - assert.doesNotMatch(sections, /tips\/index\.md/); - assert.doesNotMatch(await read("README.md"), /\(tips\/index\.md\)/); + assert.match(sections, /\[tips\/index\.md\]\(tips\/index\.md\)/); + assert.match(await read("README.md"), /\(tips\/index\.md\)/); }); test("skills/index.md links the learning section next to learn, and bootstrap matches its description", async () => { diff --git a/tips/index.md b/tips/index.md index 6f05286..607b120 100644 --- a/tips/index.md +++ b/tips/index.md @@ -2,8 +2,59 @@ Short tips and tricks. -Add detailed files or short sections and link them here. +Add detailed files or short sections and link them here. A tip is not a rule. If a tip and a rule +conflict, follow the rule. ## Current tips -(None yet. Add the first tip as a new file or section and link it.) +- [Check the exit code of each step](#check-the-exit-code-of-each-step) +- [Check for a breaking change before you push](#check-for-a-breaking-change-before-you-push) +- [Find worktrees and branches that are left](#find-worktrees-and-branches-that-are-left) + +## Check the exit code of each step + +The exit code of a command list is the exit code of its last command. The exit code of a pipe is +the exit code of its last command too. A failed step can hide behind a later step that passes. + +```bash +false; true # exit code 0 +false | true # exit code 0 +``` + +- Run each check as its own command, and read its exit code before you report a result. +- In a script, start with `set -e` to stop at the first failed command. Add `set -o pipefail` so + that a failed command in a pipe fails the pipe. +- Do not add a command after a check only to show more output, for example `npm test; ls`. The + exit code then belongs to `ls`. + +These lines were checked with bash 5. + +## Check for a breaking change before you push + +In dkstack, `validate` fails a pull request that removes a page, a skill or a linked anchor, unless +the title has `!`. Run the check locally after you commit and before you push: + +```bash +TITLE="" node scripts/check-breaking.mjs +``` + +The check compares HEAD with its merge base on `origin/main`. See +[CONTRIBUTING.md](../CONTRIBUTING.md#run-the-checks). + +## Find worktrees and branches that are left + +A worktree or a branch can stay after its pull request merges, for example a worktree that a +subagent made. List the worktrees, then each local branch whose remote branch is gone: + +```bash +git fetch --prune +git worktree list +git for-each-ref --format='%(refname:short) %(upstream:track)' refs/heads \ + | awk '$2 == "[gone]" {print $1}' +``` + +A branch in the list can still hold a commit that is not merged. Remove a worktree or a branch +only with the checks in +[after the merge](../workflow/review-and-merge.md#after-the-merge). + +These commands were checked with `git` 2.55.0. From 015fd9a3e644d5054313c9b17025dffe9b52aed7 Mon Sep 17 00:00:00 2001 From: Daniel Kindl <git@danielkindl.dev> Date: Wed, 25 Nov 2026 17:20:36 +0100 Subject: [PATCH 2/2] docs(tips): route triage to the tips --- CHANGELOG.md | 2 +- skills/triage/SKILL.md | 1 + test/routes.test.mjs | 4 +--- test/tips.test.mjs | 3 ++- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a0ef1a..7ac899f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,7 +33,7 @@ change that a consumer must act on has a "Consumer action:" line. - `scripts/check-maps.mjs --diff` (#317). A change to `docs/maps/` fails when it also changes a file outside `docs/maps/`, `docs/adr/` and `CONTEXT.md`, or when it deletes a map. The `validate` workflow runs it. -- The first tips in `tips/index.md` (#367): check the exit code of each step, check for a breaking change before you push, and find worktrees and branches that are left. AGENTS.md "Sections" and the README list `tips/index.md`. +- The first tips in `tips/index.md` (#367): check the exit code of each step, check for a breaking change before you push, and find worktrees and branches that are left. AGENTS.md "Sections", the README and the triage section map list `tips/index.md`. - A test fails for a page in a section folder that no file in `test/` names (#314). The 41 pages that had no test get one in `test/section-pages.test.mjs`. - A test checks the example progress block in `learning/progress.md` (#315). It parses the block diff --git a/skills/triage/SKILL.md b/skills/triage/SKILL.md index 6c5a092..30398d5 100644 --- a/skills/triage/SKILL.md +++ b/skills/triage/SKILL.md @@ -90,6 +90,7 @@ One agent can do all the steps. Many agents can share the steps. A skill does no - Commits or branches: [version-control/index.md](https://raw.githubusercontent.com/daniel-kindl/dkstack/v1/version-control/index.md) - Version numbers or releases: [versioning/index.md](https://raw.githubusercontent.com/daniel-kindl/dkstack/v1/versioning/index.md) - Any text, including documentation, comments and messages: [writing/index.md](https://raw.githubusercontent.com/daniel-kindl/dkstack/v1/writing/index.md). For copy that the users of a product read, also [user-facing copy](https://raw.githubusercontent.com/daniel-kindl/dkstack/v1/writing/user-facing-copy.md). +- A shell, git or check problem, or a short how-to: [tips/index.md](https://raw.githubusercontent.com/daniel-kindl/dkstack/v1/tips/index.md). A tip is not a rule. - Learning work: [learning/index.md](https://raw.githubusercontent.com/daniel-kindl/dkstack/v1/learning/index.md) - A change to `.github/workflows`, tokens, secrets or repository settings: [CI workflows](https://raw.githubusercontent.com/daniel-kindl/dkstack/v1/coding/security.md#ci-workflows) and [safety](https://raw.githubusercontent.com/daniel-kindl/dkstack/v1/workflow/safety.md) - Issues, pull requests, review, merge or release: [workflow/index.md](https://raw.githubusercontent.com/daniel-kindl/dkstack/v1/workflow/index.md) diff --git a/test/routes.test.mjs b/test/routes.test.mjs index 2768559..9ba0fb1 100644 --- a/test/routes.test.mjs +++ b/test/routes.test.mjs @@ -81,12 +81,10 @@ test("each section index lists each page of its section", async () => { } }); -test("AGENTS.md lists each section index, except tips while it has no tip", async () => { +test("AGENTS.md lists each section index", async () => { const agents = await read("AGENTS.md"); const sections = agents.slice(agents.indexOf("## Sections\n"), agents.indexOf("\n## ", agents.indexOf("## Sections\n") + 1)); - const tips = await read("tips/index.md"); for (const section of [...SECTIONS, "skills"]) { - if (section === "tips" && tips.includes("(None yet.")) continue; assert.ok(sections.includes(`(${section}/index.md)`), `AGENTS.md "Sections" does not list ${section}/index.md`); } }); diff --git a/test/tips.test.mjs b/test/tips.test.mjs index e70aae0..2cf76f5 100644 --- a/test/tips.test.mjs +++ b/test/tips.test.mjs @@ -23,7 +23,8 @@ test("tips/index.md has the first tips and no placeholder", async () => { } }); -test("AGENTS.md lists tips/index.md", async () => { +test("AGENTS.md and triage list tips/index.md", async () => { + assert.ok((await text("skills/triage/SKILL.md")).includes("v1/tips/index.md"), "triage does not route to tips/index.md"); const sections = sectionText(await text("AGENTS.md"), "## Sections"); assert.ok(sections.includes("(tips/index.md)"), "AGENTS.md does not list tips/index.md"); });