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
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,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", 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`.
- `.gitignore` ignores `.claude/worktrees/`, so `git add -A` does not add an agent worktree (#363). A test checks that `.claude/settings.json` is not ignored.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/`.
Expand Down
1 change: 1 addition & 0 deletions skills/triage/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions test/routes.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}
});
30 changes: 30 additions & 0 deletions test/tips.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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 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");
});
6 changes: 3 additions & 3 deletions test/triage-routes.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
55 changes: 53 additions & 2 deletions tips/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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="<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.