From 886e9a0f505b56eb56eb7260395f01d8baa745e7 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Nov 2026 15:58:11 +0700 Subject: [PATCH 1/2] docs: read docs by section, one group per session, independent check before closing CLAUDE.md asked every session to read SPEC.md, DESIGN.md and TESTING.md in full (about 520 KB), which filled much of the context before any work. - Read first: headings only, then the sections the issue names. - Rule 2: one group of issues per session; state is written to issues. - Rule 4: a subagent checks each item of the definition of done before an issue is closed. - Rule 5: issues carry a '## Read' list. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01Ryb4bKp5meYCqrb5rfy3dB --- CLAUDE.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 38c2c92..655fe44 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -2,7 +2,7 @@ Guidance for Claude Code, and any other coding agent, working in this repository. -Read first: `README.md`, `docs/SPEC.md` (what the app does), `docs/DESIGN.md` (how it is built), `docs/TESTING.md` (how it is tested). What is planned is in the GitHub issues and milestones, and what was decided is written in the issue it was decided for. +Read first: `README.md`, and nothing else in full. `docs/SPEC.md` (what the app does), `docs/DESIGN.md` (how it is built) and `docs/TESTING.md` (how it is tested) are too long to be read whole: together they fill a large part of a session before any work is done. Of each, read the list of its headings (`grep -n '^##' docs/DESIGN.md`), then only the sections the issue being worked on names under `## Read` (rule 5), by their line range. A section that turns out to be needed and was not named is read then, and added to the issue. What is planned is in the GitHub issues and milestones, and what was decided is written in the issue it was decided for. ## Design principles @@ -60,6 +60,7 @@ Nothing is reported as done before it has been tested, and the report says what Before a release, all of them. - **When they are run.** While working, only the tests of what is being changed are run: `swift test --filter `, `scripts/test-mac.sh `, a mode of `scripts/test-ios.sh`. Several fixes or changes are made first, and the layers of the table are run once for all of them, before they are committed, not after each one: the UI layers alone take about a quarter of an hour. A report given before that run says plainly that the full tests have not been run yet, and asks whether to run them. - **Work goes by groups, as the owner decided (2026-11-19).** The open issues of a milestone are split into groups by what they need: code to change, tries of a bug that comes and goes (principle 8), trials with a real agent, a real iPhone with a TestFlight build. The groups are said before the work starts. All of one group's work is done, with its focused tests, and then the layers are run once for that group; that run counts as one of the tries of the bugs that come and go. +- **One group, one session.** A session works on one group and no more. When the group is done, tested, committed and pushed, the report says so, names the next group, and stops: the next group is started by the owner in a new session. Nothing the next session needs is left in the conversation only: what was found, decided or left undone is written into the issue it belongs to before the report is given. A session that has been summarised (compacted) reads again, from GitHub, the definition of done of the issue it is on before it goes on. - **A change to what is seen is looked at.** Take a picture of the window (`SHOTS=... ALL_SHOTS=1 scripts/test-mac.sh `) and look at it; a build that compiles has not been seen. - **A new behaviour gets a case** in `docs/TESTING.md` and a test that names it. - **The report is true.** Which commands ran, which passed and which failed, with the failing output. What was not run is said, with why: "not tested on the iPhone" is an acceptable sentence, silence about it is not. A check that is skipped ("Executed 0 tests", tests listed as skipped) checked nothing and is not reported as passing. @@ -78,23 +79,25 @@ Nothing is reported as done before it has been tested, and the report says what - **A bug found during a session** gets an issue at once, labelled `bug`, in the milestone being worked on, saying what was seen, what was tried and what is not known yet, written as rule 5 says. - **Work that is done and tested** (rule 2) is committed on the milestone's branch and pushed, without asking. Then CI is run on the branch, which it does by itself only for pull requests and `main` (`gh workflow run ci.yml --ref `, then `gh run watch`), and what fails is fixed, shown and committed the same way, until it is green. A check that cannot be made green without a decision (rule 1) is reported and asked about. - **An issue done in full is closed**, as the owner decided (2026-11-19): a bug or an enhancement whose whole definition of done is true (fixed or made, its tests passing in the layers rule 2 asks for, pushed), with a comment that names the commits and what was run; and a bug not reproduced in principle 8's 5 tries, with a comment that says so. An issue done only in part stays open and says what is left. +- **An issue is checked by someone who did not do it, before it is closed.** The session that did the work does not judge its own work. It starts a subagent that is given only the issue's number and the commits, not the conversation: the subagent reads the issue from GitHub (`gh issue view `), reads the diff, and answers for each numbered item of the definition of done whether it is true, with the file and line, the test or the command's output that shows it. An item it cannot show is not done. The table it gives is put in the closing comment; with any item not done, the issue stays open and the item is either done or asked about (rule 1, "doing less than was asked"). - **A real agent is used when a trial needs one** (principle 5), as the owner decided (2026-11-19): Claude Code, Codex, Antigravity or Copilot CLI is started without asking, with its cheapest model and its lowest level of thinking (for Claude Code, Haiku with thinking off; for the others, their own smallest), and the issue says which agent, version, model and level were used. What rule 1 says of the user's tools still holds: a question the agent asks about itself (an update, a sign-in, whether to trust a folder) is declined or the trial is stopped, and the trial runs in a folder of its own, not in the user's projects. - What stays asked: opening and merging a pull request, releasing, deploying, deleting, closing an issue that is not done in full (above), and planning (rule 1). ### 5. How an issue is written, as the owner decided (2026-11-19) -Every issue, a bug or not, has two versions in its body, kept in step: +Every issue, a bug or not, has two versions in its body, kept in step (the list of what to read, item 2, is in the English only): 1. **English first**, as it has always been written: what was seen or is wanted, what was tried, what is not known yet, what was decided. Its boxes (`- [ ]`) are the only ones: a box is ticked in one place. -2. **`## Definition of done`** at the end of the English: a numbered list of what must be true for that issue to be closed, written for it, not copied. It takes from rule 2 and the principles what applies: +2. **`## Read`** before the definition of done: the sections of `docs/` and the source files a session must read to do this issue, each by its heading or path, and no more than it needs. It is in the English only. +3. **`## Definition of done`** at the end of the English: a numbered list of what must be true for that issue to be closed, written for it, not copied. It takes from rule 2 and the principles what applies: - what has to be decided or found out first, and by whom (the owner's choice, a real agent tried at its version); - for a bug, a test that fails because of it and is seen failing, then passes and stays; the root cause found and taken away; or principle 8's way, 5 tries not reproduced and said so; - what the change must do and must never do, both apps where principle 1 asks it, the words in `AgentTermProtocol` (principle 9), the protocol's number raised for a changed message (principle 6); - which docs say it (`docs/SPEC.md`, `docs/DESIGN.md`, `docs/TESTING.md`, `PRIVACY.md`, `docs/PERFORMANCE.md`), and the case a test names; - which layers of rule 2's table are run, and which pictures are looked at; - `make format` and `make lint`, committed on the milestone's branch and pushed, CI on the branch green. -3. After a horizontal rule, **`# Tiếng Việt`**: the same content in Vietnamese, opened by a line that says it is the translation of the English above (and, where there are boxes, that they are in the English only); boxes become plain bullets. Code, paths, commands and names stay as they are. -4. **`## Định nghĩa hoàn thành`** at the end of the Vietnamese: the definition of done, translated. +4. After a horizontal rule, **`# Tiếng Việt`**: the same content in Vietnamese, opened by a line that says it is the translation of the English above (and, where there are boxes, that they are in the English only); boxes become plain bullets. Code, paths, commands and names stay as they are. +5. **`## Định nghĩa hoàn thành`** at the end of the Vietnamese: the definition of done, translated. When an issue changes (a decision, a finding, what is done), both versions are changed in the same edit. A comment may be in either language. From 19c655c94b8eabfc94e8bc6948c197c5b97330a0 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Nov 2026 16:03:06 +0700 Subject: [PATCH 2/2] docs: split CLAUDE.md into a short index and one file per rule CLAUDE.md keeps what always holds (the principles by name, what is always asked, the conventions) and a table saying which file under docs/rules/ is read before which kind of work. Rules 1 to 5 and the principles are moved as they were on main, with their numbers kept; the three additions of this branch are gathered in a new rule 6, 'How a session goes', instead of being spread over rules 2 and 4. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01Ryb4bKp5meYCqrb5rfy3dB --- CLAUDE.md | 118 ++++++++------------------------- docs/rules/1-decisions.md | 22 ++++++ docs/rules/2-testing.md | 25 +++++++ docs/rules/3-test-isolation.md | 9 +++ docs/rules/4-without-asking.md | 9 +++ docs/rules/5-issues.md | 19 ++++++ docs/rules/6-sessions.md | 15 +++++ docs/rules/principles.md | 15 +++++ 8 files changed, 142 insertions(+), 90 deletions(-) create mode 100644 docs/rules/1-decisions.md create mode 100644 docs/rules/2-testing.md create mode 100644 docs/rules/3-test-isolation.md create mode 100644 docs/rules/4-without-asking.md create mode 100644 docs/rules/5-issues.md create mode 100644 docs/rules/6-sessions.md create mode 100644 docs/rules/principles.md diff --git a/CLAUDE.md b/CLAUDE.md index 655fe44..0908b0d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,105 +1,43 @@ # CLAUDE.md -Guidance for Claude Code, and any other coding agent, working in this repository. +Guidance for Claude Code, and any other coding agent, working in this repository. This file is short on purpose: it says what always holds, and which file under `docs/rules/` is read before which kind of work. A rule's file is read in full before that work is begun, not from memory. -Read first: `README.md`, and nothing else in full. `docs/SPEC.md` (what the app does), `docs/DESIGN.md` (how it is built) and `docs/TESTING.md` (how it is tested) are too long to be read whole: together they fill a large part of a session before any work is done. Of each, read the list of its headings (`grep -n '^##' docs/DESIGN.md`), then only the sections the issue being worked on names under `## Read` (rule 5), by their line range. A section that turns out to be needed and was not named is read then, and added to the issue. What is planned is in the GitHub issues and milestones, and what was decided is written in the issue it was decided for. +What is planned is in the GitHub issues and milestones, and what was decided is written in the issue it was decided for. ## Design principles -How the owner decides. When one of these answers a question, decide by it and go on; the report then says what was decided and by which principle, so it can be undone. Ask only when none of them answers it, or when rule 1 says the matter is always asked. +How the owner decides. When one of these answers a question, decide by it and go on, and say in the report what was decided and by which principle. In full: `docs/rules/principles.md`, read before a principle is used to decide. -1. **The Mac has everything; the iPhone has what is used every day.** What is looked at, started, answered and done in one step is on both. What takes careful editing (picking lines of a diff, resolving a conflict) is on the Mac only, and the iPhone says so rather than offer half of it. -2. **Clear and safe before convenient.** When a behaviour could be made handier at the price of someone not knowing what happens to their sessions, files or shells, the plain one is taken: a shell is typed into only by the agent that opened it, and nothing takes it over. More shells, more clicks or one more confirmation are an accepted price. -3. **What fails is said at once, with its reason and what to do.** An agent is answered immediately, never left to wait for a timeout that explains nothing. The user is told in the top banner of both apps, which stays until the fault is over and can be closed. Nothing fails silently, and a switch never says on while the thing it stands for does not work. -4. **What the app does by itself is on by default, has a switch, and is written down.** Anything done without the user asking (fetching, installing a server in an agent, asking a service) can be turned off in Settings, and `PRIVACY.md` says so when it reaches the network or reads data. -5. **Nothing is guessed that can be tried.** How an agent or a tool behaves is found out by running the real one, at the version in use, before anything is designed around it; what was found, and with which version, is written into the issue. A state that is shown is true, and what is not known is shown as not known. -6. **Until the official release, anything may change.** The protocol, the formats, what is stored and what is written into the agents' configuration change freely from one build to the next: no migration and no compatibility with an earlier 0.x build are owed. Both apps and the host are of one release, and the protocol's number goes up whenever a message changes. The official release is the one that takes the app out of beta. -7. **The released build and a development build never share anything.** A name, a port, a folder, a token, an entry in another program's configuration: each build has its own, and neither touches the other's. -8. **An issue is kept only while it can be acted on.** What cannot be reproduced is closed, to be opened again when it shows: a bug is tried 5 times, in the conditions it was seen in, and when it does not show in any of them, it is closed with a comment that says plainly it could not be reproduced, how it was tried and how many times. What waits on someone outside (a permission, a review) is closed or put in the backlog, not left open in a release. -9. **Both apps say the same thing in the same words.** A sentence the user reads (a banner, a refusal, a row's label) is written once, in `AgentTermProtocol`, and shown by both. +1. The Mac has everything; the iPhone has what is used every day. +2. Clear and safe before convenient. +3. What fails is said at once, with its reason and what to do. +4. What the app does by itself is on by default, has a switch, and is written down. +5. Nothing is guessed that can be tried. +6. Until the official release, anything may change. +7. The released build and a development build never share anything. +8. An issue is kept only while it can be acted on. +9. Both apps say the same thing in the same words. -## Rules - -### 1. Important decisions are asked, unless a principle answers them - -When the work reaches a decision that matters, first look at the design principles above. If one of them answers it, decide by it, go on, and say in the report what was decided and by which principle. If none does, stop and ask the owner: say what the choices are, what each costs, and which one you would take, then wait for the answer. Do not pick one and report it afterwards. - -A decision matters when it is any of these: - -- **What the app does.** Adding, removing or changing a behaviour the user can see, or trading one behaviour for another: a fix that makes one case work by giving up another is a decision, not a fix. -- **Design.** A new protocol message or a change to one, a new dependency, a new component, where data is kept, anything `docs/DESIGN.md` would have to describe differently. - -These are always asked, whatever a principle says: - -- **Anything outward or hard to undo.** Committing, pushing, opening or merging a pull request, releasing, creating or editing issues and milestones, deploying, deleting. Each is done when asked, and being asked once is not being asked for the next time, except for what rule 4 allows without asking. -- **Anything of the user's own.** Their installed app, its sessions, its preferences, its paired devices, their simulators, their accounts, the tools installed on their Mac. This includes every question a tool asks about itself while it is being tried: an update, a sign-in, whether to trust something. Decline it or stop; do not answer it. -- **Security and privacy.** Dismissing or working around a code scanning alert, widening what a client or a plugin may do, anything that touches tokens, pairing, or what is sent off the machine. -- **Doing less than was asked.** Leaving part of a task undone, or solving it only in part. -- **Planning.** Which release an issue belongs to, what is in or out of a milestone, closing an issue that is not done in full (rule 4), what is said in release notes. - -Not decisions to ask about: how to name a local variable, which of two equal ways to write a loop, the order of tests in a file. When unsure whether a principle covers something, it does not: ask. - -If a choice was made without asking, say so plainly in the report, with what was chosen and what the other choices were, so it can be undone. - -### 2. Work that is done is tested in full +## Always asked -Nothing is reported as done before it has been tested, and the report says what was run and what came of it. +Whatever a principle says, these are asked first and done only when asked; being asked once is not being asked for the next time. The only exceptions are those of rule 4. -- **A bug is shown before it is fixed.** Write a test that fails because of the bug, run it and see it fail, fix the bug, run it again and see it pass. The test stays. A bug that cannot be shown by a test is said to be so, with what was done instead. -- **A bug is closed only when it is fixed at its root.** Its cause is found and taken away. What only bears it (a retry, a longer wait, a test that repeats a step until it works) does not close it: the issue stays open, saying what was done meanwhile and what is still not known. The one other way to close a bug is principle 8's: not reproduced in 5 tries. -- **Every layer the change touches is run**, as `docs/TESTING.md` says under "Running them": +- Anything outward or hard to undo: committing, pushing, opening or merging a pull request, releasing, creating or editing issues and milestones, deploying, deleting. +- Anything of the user's own: their installed app, sessions, preferences, devices, simulators, accounts and tools. +- Security and privacy. +- Doing less than was asked. +- Planning: releases, milestones, closing an issue that is not done in full, release notes. - | Changed | Run | - |---|---| - | Anything | `swift build` and `swift test` | - | The Mac app, or anything it uses | `scripts/test-mac.sh` | - | The iPhone app, or code shared with it (`AgentTermClient`, `AgentTermProtocol`, `AgentTermTerminal`, `AgentTermEditor`) | `scripts/test-ios.sh "iPhone Air"` | - | What one app shows of what the other did | `scripts/test-both.sh "iPhone Air"` | - | What a picture shows (toolbar, lists, the terminal) | `scripts/screenshots.sh`, and look at each picture | - - Before a release, all of them. -- **When they are run.** While working, only the tests of what is being changed are run: `swift test --filter `, `scripts/test-mac.sh `, a mode of `scripts/test-ios.sh`. Several fixes or changes are made first, and the layers of the table are run once for all of them, before they are committed, not after each one: the UI layers alone take about a quarter of an hour. A report given before that run says plainly that the full tests have not been run yet, and asks whether to run them. -- **Work goes by groups, as the owner decided (2026-11-19).** The open issues of a milestone are split into groups by what they need: code to change, tries of a bug that comes and goes (principle 8), trials with a real agent, a real iPhone with a TestFlight build. The groups are said before the work starts. All of one group's work is done, with its focused tests, and then the layers are run once for that group; that run counts as one of the tries of the bugs that come and go. -- **One group, one session.** A session works on one group and no more. When the group is done, tested, committed and pushed, the report says so, names the next group, and stops: the next group is started by the owner in a new session. Nothing the next session needs is left in the conversation only: what was found, decided or left undone is written into the issue it belongs to before the report is given. A session that has been summarised (compacted) reads again, from GitHub, the definition of done of the issue it is on before it goes on. -- **A change to what is seen is looked at.** Take a picture of the window (`SHOTS=... ALL_SHOTS=1 scripts/test-mac.sh `) and look at it; a build that compiles has not been seen. -- **A new behaviour gets a case** in `docs/TESTING.md` and a test that names it. -- **The report is true.** Which commands ran, which passed and which failed, with the failing output. What was not run is said, with why: "not tested on the iPhone" is an acceptable sentence, silence about it is not. A check that is skipped ("Executed 0 tests", tests listed as skipped) checked nothing and is not reported as passing. -- **Tests that fail are not made to pass** by weakening them, skipping them or deleting them. If a test is wrong, say why and ask (rule 1). - -### 3. Nothing of the user's is touched while testing - -- Hosts and apps run for a test use a state folder (`AGENTTERM_STATE_DIR`), a port (`AGENTTERM_PORT`) and a home folder of their own, never `~/Library/Application Support/AgentTerm` or the installed app's port. -- An app's preferences are kept under its bundle identifier, whatever home folder it is given. A copy of the app built for a test gets an identifier of its own (`IDENTIFIER=... scripts/bundle-mac.sh`), and is never built into `dist/`, where a copy may be running. -- What a test throws away goes to a folder of its own (`AGENTTERM_TRASH_DIR`), never into the user's Trash. -- The iPhone tests reset the keychain of the simulator they run in: use "iPhone Air", not a simulator an app is paired in. -- No pairing code, token or other secret is printed. - -### 4. Done without asking, as the owner decided (2026-11-15) - -- **A bug found during a session** gets an issue at once, labelled `bug`, in the milestone being worked on, saying what was seen, what was tried and what is not known yet, written as rule 5 says. -- **Work that is done and tested** (rule 2) is committed on the milestone's branch and pushed, without asking. Then CI is run on the branch, which it does by itself only for pull requests and `main` (`gh workflow run ci.yml --ref `, then `gh run watch`), and what fails is fixed, shown and committed the same way, until it is green. A check that cannot be made green without a decision (rule 1) is reported and asked about. -- **An issue done in full is closed**, as the owner decided (2026-11-19): a bug or an enhancement whose whole definition of done is true (fixed or made, its tests passing in the layers rule 2 asks for, pushed), with a comment that names the commits and what was run; and a bug not reproduced in principle 8's 5 tries, with a comment that says so. An issue done only in part stays open and says what is left. -- **An issue is checked by someone who did not do it, before it is closed.** The session that did the work does not judge its own work. It starts a subagent that is given only the issue's number and the commits, not the conversation: the subagent reads the issue from GitHub (`gh issue view `), reads the diff, and answers for each numbered item of the definition of done whether it is true, with the file and line, the test or the command's output that shows it. An item it cannot show is not done. The table it gives is put in the closing comment; with any item not done, the issue stays open and the item is either done or asked about (rule 1, "doing less than was asked"). -- **A real agent is used when a trial needs one** (principle 5), as the owner decided (2026-11-19): Claude Code, Codex, Antigravity or Copilot CLI is started without asking, with its cheapest model and its lowest level of thinking (for Claude Code, Haiku with thinking off; for the others, their own smallest), and the issue says which agent, version, model and level were used. What rule 1 says of the user's tools still holds: a question the agent asks about itself (an update, a sign-in, whether to trust a folder) is declined or the trial is stopped, and the trial runs in a folder of its own, not in the user's projects. -- What stays asked: opening and merging a pull request, releasing, deploying, deleting, closing an issue that is not done in full (above), and planning (rule 1). - -### 5. How an issue is written, as the owner decided (2026-11-19) - -Every issue, a bug or not, has two versions in its body, kept in step (the list of what to read, item 2, is in the English only): - -1. **English first**, as it has always been written: what was seen or is wanted, what was tried, what is not known yet, what was decided. Its boxes (`- [ ]`) are the only ones: a box is ticked in one place. -2. **`## Read`** before the definition of done: the sections of `docs/` and the source files a session must read to do this issue, each by its heading or path, and no more than it needs. It is in the English only. -3. **`## Definition of done`** at the end of the English: a numbered list of what must be true for that issue to be closed, written for it, not copied. It takes from rule 2 and the principles what applies: - - what has to be decided or found out first, and by whom (the owner's choice, a real agent tried at its version); - - for a bug, a test that fails because of it and is seen failing, then passes and stays; the root cause found and taken away; or principle 8's way, 5 tries not reproduced and said so; - - what the change must do and must never do, both apps where principle 1 asks it, the words in `AgentTermProtocol` (principle 9), the protocol's number raised for a changed message (principle 6); - - which docs say it (`docs/SPEC.md`, `docs/DESIGN.md`, `docs/TESTING.md`, `PRIVACY.md`, `docs/PERFORMANCE.md`), and the case a test names; - - which layers of rule 2's table are run, and which pictures are looked at; - - `make format` and `make lint`, committed on the milestone's branch and pushed, CI on the branch green. -4. After a horizontal rule, **`# Tiếng Việt`**: the same content in Vietnamese, opened by a line that says it is the translation of the English above (and, where there are boxes, that they are in the English only); boxes become plain bullets. Code, paths, commands and names stay as they are. -5. **`## Định nghĩa hoàn thành`** at the end of the Vietnamese: the definition of done, translated. +## Rules -When an issue changes (a decision, a finding, what is done), both versions are changed in the same edit. A comment may be in either language. +| Rule | Read it | File | +|---|---|---| +| 1. Important decisions are asked, unless a principle answers them | when a decision comes up | `docs/rules/1-decisions.md` | +| 2. Work that is done is tested in full | before testing, and before reporting anything as done | `docs/rules/2-testing.md` | +| 3. Nothing of the user's is touched while testing | before running a host, an app or a simulator | `docs/rules/3-test-isolation.md` | +| 4. Done without asking | before committing, pushing, opening or closing an issue, or starting a real agent | `docs/rules/4-without-asking.md` | +| 5. How an issue is written | before creating or editing an issue | `docs/rules/5-issues.md` | +| 6. How a session goes | at the start of every session, and before closing an issue | `docs/rules/6-sessions.md` | ## Conventions diff --git a/docs/rules/1-decisions.md b/docs/rules/1-decisions.md new file mode 100644 index 0000000..ec7468d --- /dev/null +++ b/docs/rules/1-decisions.md @@ -0,0 +1,22 @@ +# Rule 1. Important decisions are asked, unless a principle answers them + +Part of the rules in [`CLAUDE.md`](../../CLAUDE.md), which says when this file is read. + +When the work reaches a decision that matters, first look at the design principles above. If one of them answers it, decide by it, go on, and say in the report what was decided and by which principle. If none does, stop and ask the owner: say what the choices are, what each costs, and which one you would take, then wait for the answer. Do not pick one and report it afterwards. + +A decision matters when it is any of these: + +- **What the app does.** Adding, removing or changing a behaviour the user can see, or trading one behaviour for another: a fix that makes one case work by giving up another is a decision, not a fix. +- **Design.** A new protocol message or a change to one, a new dependency, a new component, where data is kept, anything `docs/DESIGN.md` would have to describe differently. + +These are always asked, whatever a principle says: + +- **Anything outward or hard to undo.** Committing, pushing, opening or merging a pull request, releasing, creating or editing issues and milestones, deploying, deleting. Each is done when asked, and being asked once is not being asked for the next time, except for what rule 4 allows without asking. +- **Anything of the user's own.** Their installed app, its sessions, its preferences, its paired devices, their simulators, their accounts, the tools installed on their Mac. This includes every question a tool asks about itself while it is being tried: an update, a sign-in, whether to trust something. Decline it or stop; do not answer it. +- **Security and privacy.** Dismissing or working around a code scanning alert, widening what a client or a plugin may do, anything that touches tokens, pairing, or what is sent off the machine. +- **Doing less than was asked.** Leaving part of a task undone, or solving it only in part. +- **Planning.** Which release an issue belongs to, what is in or out of a milestone, closing an issue that is not done in full (rule 4), what is said in release notes. + +Not decisions to ask about: how to name a local variable, which of two equal ways to write a loop, the order of tests in a file. When unsure whether a principle covers something, it does not: ask. + +If a choice was made without asking, say so plainly in the report, with what was chosen and what the other choices were, so it can be undone. diff --git a/docs/rules/2-testing.md b/docs/rules/2-testing.md new file mode 100644 index 0000000..36b39cf --- /dev/null +++ b/docs/rules/2-testing.md @@ -0,0 +1,25 @@ +# Rule 2. Work that is done is tested in full + +Part of the rules in [`CLAUDE.md`](../../CLAUDE.md), which says when this file is read. + +Nothing is reported as done before it has been tested, and the report says what was run and what came of it. + +- **A bug is shown before it is fixed.** Write a test that fails because of the bug, run it and see it fail, fix the bug, run it again and see it pass. The test stays. A bug that cannot be shown by a test is said to be so, with what was done instead. +- **A bug is closed only when it is fixed at its root.** Its cause is found and taken away. What only bears it (a retry, a longer wait, a test that repeats a step until it works) does not close it: the issue stays open, saying what was done meanwhile and what is still not known. The one other way to close a bug is principle 8's: not reproduced in 5 tries. +- **Every layer the change touches is run**, as `docs/TESTING.md` says under "Running them": + + | Changed | Run | + |---|---| + | Anything | `swift build` and `swift test` | + | The Mac app, or anything it uses | `scripts/test-mac.sh` | + | The iPhone app, or code shared with it (`AgentTermClient`, `AgentTermProtocol`, `AgentTermTerminal`, `AgentTermEditor`) | `scripts/test-ios.sh "iPhone Air"` | + | What one app shows of what the other did | `scripts/test-both.sh "iPhone Air"` | + | What a picture shows (toolbar, lists, the terminal) | `scripts/screenshots.sh`, and look at each picture | + + Before a release, all of them. +- **When they are run.** While working, only the tests of what is being changed are run: `swift test --filter `, `scripts/test-mac.sh `, a mode of `scripts/test-ios.sh`. Several fixes or changes are made first, and the layers of the table are run once for all of them, before they are committed, not after each one: the UI layers alone take about a quarter of an hour. A report given before that run says plainly that the full tests have not been run yet, and asks whether to run them. +- **Work goes by groups, as the owner decided (2026-11-19).** The open issues of a milestone are split into groups by what they need: code to change, tries of a bug that comes and goes (principle 8), trials with a real agent, a real iPhone with a TestFlight build. The groups are said before the work starts. All of one group's work is done, with its focused tests, and then the layers are run once for that group; that run counts as one of the tries of the bugs that come and go. +- **A change to what is seen is looked at.** Take a picture of the window (`SHOTS=... ALL_SHOTS=1 scripts/test-mac.sh `) and look at it; a build that compiles has not been seen. +- **A new behaviour gets a case** in `docs/TESTING.md` and a test that names it. +- **The report is true.** Which commands ran, which passed and which failed, with the failing output. What was not run is said, with why: "not tested on the iPhone" is an acceptable sentence, silence about it is not. A check that is skipped ("Executed 0 tests", tests listed as skipped) checked nothing and is not reported as passing. +- **Tests that fail are not made to pass** by weakening them, skipping them or deleting them. If a test is wrong, say why and ask (rule 1). diff --git a/docs/rules/3-test-isolation.md b/docs/rules/3-test-isolation.md new file mode 100644 index 0000000..6446a55 --- /dev/null +++ b/docs/rules/3-test-isolation.md @@ -0,0 +1,9 @@ +# Rule 3. Nothing of the user's is touched while testing + +Part of the rules in [`CLAUDE.md`](../../CLAUDE.md), which says when this file is read. + +- Hosts and apps run for a test use a state folder (`AGENTTERM_STATE_DIR`), a port (`AGENTTERM_PORT`) and a home folder of their own, never `~/Library/Application Support/AgentTerm` or the installed app's port. +- An app's preferences are kept under its bundle identifier, whatever home folder it is given. A copy of the app built for a test gets an identifier of its own (`IDENTIFIER=... scripts/bundle-mac.sh`), and is never built into `dist/`, where a copy may be running. +- What a test throws away goes to a folder of its own (`AGENTTERM_TRASH_DIR`), never into the user's Trash. +- The iPhone tests reset the keychain of the simulator they run in: use "iPhone Air", not a simulator an app is paired in. +- No pairing code, token or other secret is printed. diff --git a/docs/rules/4-without-asking.md b/docs/rules/4-without-asking.md new file mode 100644 index 0000000..c59cb3d --- /dev/null +++ b/docs/rules/4-without-asking.md @@ -0,0 +1,9 @@ +# Rule 4. Done without asking, as the owner decided (2026-11-15) + +Part of the rules in [`CLAUDE.md`](../../CLAUDE.md), which says when this file is read. An issue is closed only after the check of rule 6. + +- **A bug found during a session** gets an issue at once, labelled `bug`, in the milestone being worked on, saying what was seen, what was tried and what is not known yet, written as rule 5 says. +- **Work that is done and tested** (rule 2) is committed on the milestone's branch and pushed, without asking. Then CI is run on the branch, which it does by itself only for pull requests and `main` (`gh workflow run ci.yml --ref `, then `gh run watch`), and what fails is fixed, shown and committed the same way, until it is green. A check that cannot be made green without a decision (rule 1) is reported and asked about. +- **An issue done in full is closed**, as the owner decided (2026-11-19): a bug or an enhancement whose whole definition of done is true (fixed or made, its tests passing in the layers rule 2 asks for, pushed), with a comment that names the commits and what was run; and a bug not reproduced in principle 8's 5 tries, with a comment that says so. An issue done only in part stays open and says what is left. +- **A real agent is used when a trial needs one** (principle 5), as the owner decided (2026-11-19): Claude Code, Codex, Antigravity or Copilot CLI is started without asking, with its cheapest model and its lowest level of thinking (for Claude Code, Haiku with thinking off; for the others, their own smallest), and the issue says which agent, version, model and level were used. What rule 1 says of the user's tools still holds: a question the agent asks about itself (an update, a sign-in, whether to trust a folder) is declined or the trial is stopped, and the trial runs in a folder of its own, not in the user's projects. +- What stays asked: opening and merging a pull request, releasing, deploying, deleting, closing an issue that is not done in full (above), and planning (rule 1). diff --git a/docs/rules/5-issues.md b/docs/rules/5-issues.md new file mode 100644 index 0000000..4528b1f --- /dev/null +++ b/docs/rules/5-issues.md @@ -0,0 +1,19 @@ +# Rule 5. How an issue is written, as the owner decided (2026-11-19) + +Part of the rules in [`CLAUDE.md`](../../CLAUDE.md), which says when this file is read. + +Every issue, a bug or not, has two versions in its body, kept in step (the list of what to read, item 2, is in the English only): + +1. **English first**, as it has always been written: what was seen or is wanted, what was tried, what is not known yet, what was decided. Its boxes (`- [ ]`) are the only ones: a box is ticked in one place. +2. **`## Read`** before the definition of done: the sections of `docs/` and the source files a session must read to do this issue, each by its heading or path, and no more than it needs. It is in the English only. +3. **`## Definition of done`** at the end of the English: a numbered list of what must be true for that issue to be closed, written for it, not copied. It takes from rule 2 and the principles what applies: + - what has to be decided or found out first, and by whom (the owner's choice, a real agent tried at its version); + - for a bug, a test that fails because of it and is seen failing, then passes and stays; the root cause found and taken away; or principle 8's way, 5 tries not reproduced and said so; + - what the change must do and must never do, both apps where principle 1 asks it, the words in `AgentTermProtocol` (principle 9), the protocol's number raised for a changed message (principle 6); + - which docs say it (`docs/SPEC.md`, `docs/DESIGN.md`, `docs/TESTING.md`, `PRIVACY.md`, `docs/PERFORMANCE.md`), and the case a test names; + - which layers of rule 2's table are run, and which pictures are looked at; + - `make format` and `make lint`, committed on the milestone's branch and pushed, CI on the branch green. +4. After a horizontal rule, **`# Tiếng Việt`**: the same content in Vietnamese, opened by a line that says it is the translation of the English above (and, where there are boxes, that they are in the English only); boxes become plain bullets. Code, paths, commands and names stay as they are. +5. **`## Định nghĩa hoàn thành`** at the end of the Vietnamese: the definition of done, translated. + +When an issue changes (a decision, a finding, what is done), both versions are changed in the same edit. A comment may be in either language. diff --git a/docs/rules/6-sessions.md b/docs/rules/6-sessions.md new file mode 100644 index 0000000..3b3847c --- /dev/null +++ b/docs/rules/6-sessions.md @@ -0,0 +1,15 @@ +# Rule 6. How a session goes + +Part of the rules in [`CLAUDE.md`](../../CLAUDE.md), which says when this file is read. + +## At the start + +Read `README.md`, and no other document in full. `docs/SPEC.md` (what the app does), `docs/DESIGN.md` (how it is built) and `docs/TESTING.md` (how it is tested) are too long to be read whole: together they fill a large part of a session before any work is done. Of each, read the list of its headings (`grep -n '^##' docs/DESIGN.md`), then only the sections the issue being worked on names under `## Read` (rule 5), by their line range. A section that turns out to be needed and was not named is read then, and added to the issue. + +## One group, one session + +A session works on one group (rule 2, "Work goes by groups") and no more. When the group is done, tested, committed and pushed, the report says so, names the next group, and stops: the next group is started by the owner in a new session. Nothing the next session needs is left in the conversation only: what was found, decided or left undone is written into the issue it belongs to before the report is given. A session that has been summarised (compacted) reads again, from GitHub, the definition of done of the issue it is on before it goes on. + +## An issue is checked by someone who did not do it, before it is closed + +The session that did the work does not judge its own work. It starts a subagent that is given only the issue's number and the commits, not the conversation: the subagent reads the issue from GitHub (`gh issue view `), reads the diff, and answers for each numbered item of the definition of done whether it is true, with the file and line, the test or the command's output that shows it. An item it cannot show is not done. The table it gives is put in the closing comment; with any item not done, the issue stays open and the item is either done or asked about (rule 1, "doing less than was asked"). diff --git a/docs/rules/principles.md b/docs/rules/principles.md new file mode 100644 index 0000000..94d70c4 --- /dev/null +++ b/docs/rules/principles.md @@ -0,0 +1,15 @@ +# Design principles + +Part of the rules in [`CLAUDE.md`](../../CLAUDE.md), which says when this file is read. + +How the owner decides. When one of these answers a question, decide by it and go on; the report then says what was decided and by which principle, so it can be undone. Ask only when none of them answers it, or when rule 1 says the matter is always asked. + +1. **The Mac has everything; the iPhone has what is used every day.** What is looked at, started, answered and done in one step is on both. What takes careful editing (picking lines of a diff, resolving a conflict) is on the Mac only, and the iPhone says so rather than offer half of it. +2. **Clear and safe before convenient.** When a behaviour could be made handier at the price of someone not knowing what happens to their sessions, files or shells, the plain one is taken: a shell is typed into only by the agent that opened it, and nothing takes it over. More shells, more clicks or one more confirmation are an accepted price. +3. **What fails is said at once, with its reason and what to do.** An agent is answered immediately, never left to wait for a timeout that explains nothing. The user is told in the top banner of both apps, which stays until the fault is over and can be closed. Nothing fails silently, and a switch never says on while the thing it stands for does not work. +4. **What the app does by itself is on by default, has a switch, and is written down.** Anything done without the user asking (fetching, installing a server in an agent, asking a service) can be turned off in Settings, and `PRIVACY.md` says so when it reaches the network or reads data. +5. **Nothing is guessed that can be tried.** How an agent or a tool behaves is found out by running the real one, at the version in use, before anything is designed around it; what was found, and with which version, is written into the issue. A state that is shown is true, and what is not known is shown as not known. +6. **Until the official release, anything may change.** The protocol, the formats, what is stored and what is written into the agents' configuration change freely from one build to the next: no migration and no compatibility with an earlier 0.x build are owed. Both apps and the host are of one release, and the protocol's number goes up whenever a message changes. The official release is the one that takes the app out of beta. +7. **The released build and a development build never share anything.** A name, a port, a folder, a token, an entry in another program's configuration: each build has its own, and neither touches the other's. +8. **An issue is kept only while it can be acted on.** What cannot be reproduced is closed, to be opened again when it shows: a bug is tried 5 times, in the conditions it was seen in, and when it does not show in any of them, it is closed with a comment that says plainly it could not be reproduced, how it was tried and how many times. What waits on someone outside (a permission, a review) is closed or put in the backlog, not left open in a release. +9. **Both apps say the same thing in the same words.** A sentence the user reads (a banner, a refusal, a row's label) is written once, in `AgentTermProtocol`, and shown by both.