@guilhermednobre/agent-kit 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +102 -47
  3. package/bin/cli.js +79 -38
  4. package/package.json +12 -4
  5. package/src/cli/tools.js +51 -0
  6. package/src/cli/wf.js +400 -0
  7. package/src/core/briefing.js +188 -0
  8. package/src/core/config.js +321 -0
  9. package/src/core/dag.js +103 -0
  10. package/src/core/engine.js +505 -0
  11. package/src/core/policy.js +145 -0
  12. package/src/core/report.js +104 -0
  13. package/src/core/states.js +59 -0
  14. package/src/core/store.js +60 -0
  15. package/src/core/verify.js +54 -0
  16. package/src/detect.js +6 -0
  17. package/src/generate.js +55 -0
  18. package/src/install.js +22 -14
  19. package/src/render.js +5 -7
  20. package/src/runtimes/index.js +24 -0
  21. package/src/runtimes/orca.js +61 -0
  22. package/src/runtimes/t3.js +87 -0
  23. package/src/trackers/index.js +34 -0
  24. package/src/trackers/linear-t3.js +138 -0
  25. package/src/trackers/linear.js +209 -0
  26. package/templates/AGENTS.md +111 -110
  27. package/templates/CLAUDE.md +185 -306
  28. package/templates/agent-kit/hooks/pretooluse.mjs +53 -0
  29. package/templates/agent-kit/hooks/session-context.mjs +41 -0
  30. package/templates/agent-kit/runtime/orca.md +68 -0
  31. package/templates/agent-kit/runtime/t3.md +109 -0
  32. package/templates/claude/commands/analisar-consistencia.md +111 -0
  33. package/templates/claude/commands/avaliar-ideia.md +63 -0
  34. package/templates/claude/commands/configurar-worker.md +116 -0
  35. package/templates/claude/commands/criar-prd.md +16 -1
  36. package/templates/claude/commands/criar-tasks.md +40 -3
  37. package/templates/claude/commands/criar-techspec.md +12 -1
  38. package/templates/claude/commands/executar-bugfix.md +11 -11
  39. package/templates/claude/commands/executar-qa.md +14 -15
  40. package/templates/claude/commands/executar-release.md +20 -0
  41. package/templates/claude/commands/executar-review.md +51 -31
  42. package/templates/claude/commands/executar-task.md +14 -23
  43. package/templates/claude/commands/executar-workflow.md +101 -0
  44. package/templates/claude/commands/fechar-ciclo.md +88 -0
  45. package/templates/claude/commands/replanejar-workflow.md +32 -0
  46. package/templates/claude/commands/retomar-workflow.md +30 -0
  47. package/templates/claude/commands/status-workflow.md +19 -0
  48. package/templates/claude/rules/README.md +2 -2
  49. package/templates/claude/settings.json +25 -0
  50. package/templates/claude/templates/bugs-template.md +2 -2
  51. package/templates/claude/templates/plan-template.json +33 -0
  52. package/templates/claude/templates/prd-template.md +65 -61
  53. package/templates/claude/templates/task-template.md +8 -8
  54. package/templates/claude/templates/tasks-template.md +1 -1
  55. package/templates/claude/templates/techspec-template.md +129 -129
  56. package/templates/claude/templates/worker-brief-template.md +11 -7
  57. package/templates/docs/agents/worker.md +94 -0
@@ -0,0 +1,138 @@
1
+ // Linear through T3 Code's issue tools (create_issue, set_issue_state, comment_on_issue).
2
+ // No API key: like the runtime adapters, it prints the calls; the coordinator makes them, then
3
+ // binds the returned issue keys (`wf tracker-bind`) and acknowledges events (`wf sync --ack`).
4
+ import { taskDescription } from "./linear.js";
5
+
6
+ export const PARENT = "_parent";
7
+
8
+ const DEFAULT_STATE_NAMES = {
9
+ pending: "Todo",
10
+ ready: "Todo",
11
+ running: "In Progress",
12
+ testing: "In Progress",
13
+ review: "In Progress",
14
+ blocked: "In Progress",
15
+ failed: "In Progress",
16
+ completed: "Done",
17
+ cancelled: "Canceled",
18
+ };
19
+
20
+ export function linearT3Tracker({ settings }) {
21
+ const names = { ...DEFAULT_STATE_NAMES, ...(settings.stateNames || {}) };
22
+ const labels = settings.labels?.length ? { labels: settings.labels } : {};
23
+
24
+ function createOperations(run) {
25
+ const operations = [];
26
+ if (!run.tracker?.parent) {
27
+ operations.push({
28
+ bind: PARENT,
29
+ tool: "create_issue",
30
+ args: { title: `[${run.id}] ${run.objective || "agent-kit run"}`, body: parentBody(run), ...labels },
31
+ then: `agent-kit wf tracker-bind ${run.id} ${PARENT} --key <key> --url <url>`,
32
+ });
33
+ return operations;
34
+ }
35
+ for (const id of run.order) {
36
+ const task = run.tasks[id];
37
+ if (task.tracker?.key) continue;
38
+ operations.push({
39
+ bind: id,
40
+ tool: "create_issue",
41
+ args: { title: `[${run.id}] ${task.id} ${task.title}`, body: taskBody(run, task), ...labels },
42
+ then: `agent-kit wf tracker-bind ${run.id} ${task.id} --key <key> --url <url>`,
43
+ });
44
+ }
45
+ return operations;
46
+ }
47
+
48
+ return {
49
+ kind: "linear",
50
+ via: "t3",
51
+ deferred: true,
52
+
53
+ async publishPlan(run) {
54
+ return { deferred: true, operations: createOperations(run) };
55
+ },
56
+
57
+ async sync(run) {
58
+ const create = createOperations(run);
59
+ if (create.length) {
60
+ return { deferred: true, operations: create, note: "Create and bind the issues first, then run wf sync again" };
61
+ }
62
+ const pending = run.events.map((event, index) => ({ event, index })).filter(({ event }) => !event.synced);
63
+ const byIssue = new Map();
64
+ for (const { event, index } of pending) {
65
+ const key = event.scope === "workflow" ? run.tracker.parent.key : run.tasks[event.id]?.tracker?.key;
66
+ if (!key) continue;
67
+ const entry = byIssue.get(key) || { key, lines: [], state: null, ids: [] };
68
+ entry.lines.push(line(event));
69
+ if (event.scope === "task") entry.state = names[event.to] || null;
70
+ if (event.scope === "workflow" && ["completed", "cancelled"].includes(event.to)) entry.state = names[event.to];
71
+ entry.ids.push(index);
72
+ byIssue.set(key, entry);
73
+ }
74
+ const operations = [];
75
+ const ack = pending.map(({ index }) => index);
76
+ for (const entry of byIssue.values()) {
77
+ if (entry.state) operations.push({ tool: "set_issue_state", args: { key: entry.key, state: entry.state } });
78
+ operations.push({ tool: "comment_on_issue", args: { key: entry.key, body: entry.lines.join("\n") } });
79
+ }
80
+ return {
81
+ deferred: true,
82
+ operations,
83
+ ack,
84
+ then: ack.length ? `agent-kit wf sync ${run.id} --ack ${ack.join(",")}` : null,
85
+ };
86
+ },
87
+
88
+ async importPlan() {
89
+ throw new Error('Importing a plan needs tracker.linear.via "api" (an API key); with T3, resume from .agent-kit/runs/<run>/');
90
+ },
91
+ };
92
+ }
93
+
94
+ export function bindIssue(run, target, { key, url }) {
95
+ if (target === PARENT) {
96
+ run.tracker = { kind: "linear", via: "t3", ...(run.tracker || {}), parent: { key, identifier: key, url } };
97
+ return run.tracker.parent;
98
+ }
99
+ const task = run.tasks[target];
100
+ if (!task) throw new Error(`Unknown task "${target}"`);
101
+ task.tracker = { key, identifier: key, url };
102
+ return task.tracker;
103
+ }
104
+
105
+ export function acknowledge(run, ids) {
106
+ let count = 0;
107
+ for (const id of ids) {
108
+ const event = run.events[id];
109
+ if (event && !event.synced) {
110
+ event.synced = true;
111
+ count += 1;
112
+ }
113
+ }
114
+ return count;
115
+ }
116
+
117
+ function parentBody(run) {
118
+ return [
119
+ `Workflow \`${run.id}\` gerenciado pelo agent-kit.`,
120
+ "",
121
+ "Tarefas:",
122
+ ...run.order.map((id) => `- ${id} ${run.tasks[id].title}`),
123
+ ].join("\n");
124
+ }
125
+
126
+ function taskBody(run, task) {
127
+ const deps = task.dependsOn.map((id) => run.tasks[id]?.tracker?.key || id);
128
+ const header = [
129
+ run.tracker?.parent?.key ? `Parte de ${run.tracker.parent.key}.` : null,
130
+ deps.length ? `Depende de: ${deps.join(", ")}.` : null,
131
+ ].filter(Boolean);
132
+ return [...header, ...(header.length ? [""] : []), taskDescription(run, task)].join("\n");
133
+ }
134
+
135
+ function line(event) {
136
+ const head = event.scope === "workflow" ? "workflow" : event.scope === "attempt" ? "" : `${event.from || "—"} → ${event.to}`;
137
+ return `agent-kit · ${head}${head && event.reason ? " — " : ""}${event.reason || ""}`;
138
+ }
@@ -0,0 +1,209 @@
1
+ // Linear tracker over the public GraphQL API (verified against linear/linear packages/sdk schema.graphql).
2
+ // Personal API keys go in the Authorization header without "Bearer".
3
+
4
+ export const LINEAR_ENDPOINT = "https://api.linear.app/graphql";
5
+ export const TASK_FENCE = "agent-kit-task";
6
+ const TASK_BLOCK = new RegExp("```" + TASK_FENCE + "\\s*\\n([\\s\\S]*?)\\n```");
7
+ const SPEC_FIELDS = ["role", "profile", "tags", "dependsOn", "files", "doc", "context", "acceptance", "validation"];
8
+
9
+ export function createLinearClient({ apiKey, fetchImpl = globalThis.fetch, endpoint = LINEAR_ENDPOINT }) {
10
+ if (!apiKey) throw new Error("Linear API key is missing (set the variable named in tracker.linear.apiKeyEnv)");
11
+ return async function gql(query, variables = {}) {
12
+ const response = await fetchImpl(endpoint, {
13
+ method: "POST",
14
+ headers: { "Content-Type": "application/json", Authorization: apiKey },
15
+ body: JSON.stringify({ query, variables }),
16
+ });
17
+ const payload = await response.json().catch(() => ({}));
18
+ if (!response.ok || payload.errors?.length) {
19
+ const message = payload.errors?.map((error) => error.message).join("; ") || `HTTP ${response.status}`;
20
+ throw new Error(`Linear API error: ${message}`);
21
+ }
22
+ return payload.data;
23
+ };
24
+ }
25
+
26
+ const Q_TEAM = `query Team($key: String!) { teams(filter: { key: { eq: $key } }) { nodes { id key name } } }`;
27
+ const Q_STATES = `query States($teamId: ID!) { workflowStates(first: 100, filter: { team: { id: { eq: $teamId } } }) { nodes { id name type } } }`;
28
+ const M_CREATE = `mutation Create($input: IssueCreateInput!) { issueCreate(input: $input) { success issue { id identifier url } } }`;
29
+ const M_UPDATE = `mutation Update($id: String!, $input: IssueUpdateInput!) { issueUpdate(id: $id, input: $input) { success } }`;
30
+ const M_RELATION = `mutation Relate($input: IssueRelationCreateInput!) { issueRelationCreate(input: $input) { success } }`;
31
+ const M_COMMENT = `mutation Comment($input: CommentCreateInput!) { commentCreate(input: $input) { success } }`;
32
+ const Q_LABELS = `query Labels($teamId: ID!) { issueLabels(first: 250, filter: { team: { id: { eq: $teamId } } }) { nodes { id name } } }`;
33
+ const Q_PARENT = `query Parent($id: String!) {
34
+ issue(id: $id) {
35
+ id identifier title url
36
+ children(first: 250) { nodes {
37
+ id identifier title description url state { name type }
38
+ inverseRelations(first: 100) { nodes { type issue { identifier } } }
39
+ } }
40
+ }
41
+ }`;
42
+
43
+ export function linearTracker({ settings, gql }) {
44
+ let cache = null;
45
+
46
+ async function team() {
47
+ if (cache) return cache;
48
+ const data = await gql(Q_TEAM, { key: settings.teamKey });
49
+ const found = data.teams.nodes[0];
50
+ if (!found) throw new Error(`Linear team with key "${settings.teamKey}" not found`);
51
+ const states = (await gql(Q_STATES, { teamId: found.id })).workflowStates.nodes;
52
+ let labelIds = [];
53
+ if (settings.labels?.length) {
54
+ const labels = (await gql(Q_LABELS, { teamId: found.id })).issueLabels.nodes;
55
+ labelIds = labels.filter((label) => settings.labels.includes(label.name)).map((label) => label.id);
56
+ }
57
+ cache = { ...found, states, labelIds };
58
+ return cache;
59
+ }
60
+
61
+ function stateId(states, taskState) {
62
+ const wanted = settings.stateMap?.[taskState];
63
+ if (!wanted) return null;
64
+ const lower = String(wanted).toLowerCase();
65
+ const byName = states.find((state) => state.name.toLowerCase() === lower);
66
+ return (byName || states.find((state) => state.type === lower))?.id || null;
67
+ }
68
+
69
+ async function create(input) {
70
+ const result = await gql(M_CREATE, { input });
71
+ if (!result.issueCreate.success) throw new Error(`Linear refused to create "${input.title}"`);
72
+ return result.issueCreate.issue;
73
+ }
74
+
75
+ return {
76
+ kind: "linear",
77
+
78
+ async publishPlan(run) {
79
+ const info = await team();
80
+ const base = { teamId: info.id, ...(settings.projectId ? { projectId: settings.projectId } : {}), ...(info.labelIds.length ? { labelIds: info.labelIds } : {}) };
81
+ if (!run.tracker?.parent) {
82
+ const parent = await create({ ...base, title: run.objective || `agent-kit run ${run.id}`, description: parentDescription(run) });
83
+ run.tracker = { kind: "linear", teamKey: info.key, parent };
84
+ }
85
+ const created = [];
86
+ for (const id of run.order) {
87
+ const task = run.tasks[id];
88
+ if (task.tracker?.id) continue;
89
+ task.tracker = await create({
90
+ ...base,
91
+ title: `${task.id} ${task.title}`,
92
+ parentId: run.tracker.parent.id,
93
+ description: taskDescription(run, task),
94
+ stateId: stateId(info.states, task.state) || undefined,
95
+ });
96
+ created.push(task.id);
97
+ }
98
+ for (const id of created) {
99
+ for (const dep of run.tasks[id].dependsOn) {
100
+ await gql(M_RELATION, { input: { issueId: run.tasks[dep].tracker.id, relatedIssueId: run.tasks[id].tracker.id, type: "blocks" } });
101
+ }
102
+ }
103
+ return { created, parent: run.tracker.parent };
104
+ },
105
+
106
+ async sync(run) {
107
+ if (!run.tracker?.parent) return { synced: 0, pending: run.events.filter((event) => !event.synced).length, skipped: "plan not published" };
108
+ const info = await team();
109
+ let synced = 0;
110
+ for (const event of run.events.filter((item) => !item.synced)) {
111
+ const issueId = event.scope === "workflow" ? run.tracker.parent.id : run.tasks[event.id]?.tracker?.id;
112
+ if (issueId) {
113
+ if (event.scope === "task") {
114
+ const target = stateId(info.states, event.to);
115
+ if (target) await gql(M_UPDATE, { id: issueId, input: { stateId: target } });
116
+ }
117
+ await gql(M_COMMENT, { input: { issueId, body: eventComment(event) } });
118
+ }
119
+ event.synced = true;
120
+ synced += 1;
121
+ }
122
+ return { synced, pending: 0 };
123
+ },
124
+
125
+ async importPlan(identifier) {
126
+ const issue = (await gql(Q_PARENT, { id: identifier })).issue;
127
+ const tasks = [];
128
+ const completed = [];
129
+ const skipped = [];
130
+ const byIdentifier = new Map();
131
+ for (const child of issue.children.nodes) {
132
+ const spec = parseTaskBlock(child.description);
133
+ if (!spec) {
134
+ skipped.push(child.identifier);
135
+ continue;
136
+ }
137
+ byIdentifier.set(child.identifier, spec.id);
138
+ tasks.push({ child, spec });
139
+ }
140
+ const plan = {
141
+ objective: issue.title,
142
+ tracker: { kind: "linear", parent: { id: issue.id, identifier: issue.identifier, url: issue.url } },
143
+ tasks: tasks.map(({ child, spec }) => {
144
+ const blockers = child.inverseRelations.nodes
145
+ .filter((relation) => relation.type === "blocks" && byIdentifier.has(relation.issue.identifier))
146
+ .map((relation) => byIdentifier.get(relation.issue.identifier));
147
+ if (child.state?.type === "completed") completed.push(spec.id);
148
+ return {
149
+ ...spec,
150
+ title: spec.title || child.title.replace(new RegExp(`^${escape(spec.id)}\\s+`), ""),
151
+ dependsOn: [...new Set([...(spec.dependsOn || []), ...blockers])],
152
+ tracker: { id: child.id, identifier: child.identifier, url: child.url },
153
+ };
154
+ }),
155
+ };
156
+ return { plan, completed, skipped };
157
+ },
158
+ };
159
+ }
160
+
161
+ function escape(text) {
162
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
163
+ }
164
+
165
+ export function parseTaskBlock(description) {
166
+ const match = TASK_BLOCK.exec(String(description || ""));
167
+ if (!match) return null;
168
+ try {
169
+ const data = JSON.parse(match[1]);
170
+ return data && typeof data.id === "string" ? data : null;
171
+ } catch {
172
+ return null;
173
+ }
174
+ }
175
+
176
+ function parentDescription(run) {
177
+ return [
178
+ `Workflow \`${run.id}\` gerenciado pelo agent-kit.`,
179
+ "",
180
+ "As sub-issues são as tarefas; relações *blocks* são as dependências.",
181
+ "O estado de cada sub-issue é atualizado pelo coordenador a cada transição.",
182
+ ].join("\n");
183
+ }
184
+
185
+ export function taskDescription(run, task) {
186
+ const spec = { id: task.id, title: task.title };
187
+ for (const field of SPEC_FIELDS) if (task[field] !== undefined) spec[field] = task[field];
188
+ return [
189
+ `Tarefa \`${task.id}\` do workflow \`${run.id}\`.`,
190
+ "",
191
+ "**Critérios de aceite**",
192
+ ...task.acceptance.map((item) => `- ${item}`),
193
+ "",
194
+ "**Arquivos**",
195
+ ...task.files.map((file) => `- \`${file}\``),
196
+ "",
197
+ "Bloco lido pelo agent-kit (edite com cuidado — é a especificação da tarefa):",
198
+ "",
199
+ "```" + TASK_FENCE,
200
+ JSON.stringify(spec, null, 2),
201
+ "```",
202
+ ].join("\n");
203
+ }
204
+
205
+ function eventComment(event) {
206
+ if (event.scope === "workflow") return `agent-kit · workflow: ${event.from || "—"} → ${event.to}${event.reason ? ` — ${event.reason}` : ""}`;
207
+ if (event.scope === "attempt") return `agent-kit · ${event.reason}`;
208
+ return `agent-kit · ${event.from || "—"} → ${event.to}${event.reason ? ` — ${event.reason}` : ""}`;
209
+ }
@@ -1,159 +1,160 @@
1
1
  # AGENTS.md
2
2
 
3
- Operating contract for the **Antigravity implementation worker** (CLI `agy`) in this repository.
3
+ Shared contract for **every coding agent** in this repository, whatever the tool. It states what
4
+ the project is and how code is written here. It does not assign roles:
4
5
 
5
- You run inside an Orca-managed worktree, launched as `agy --model gemini-3.8-flash-high
6
- --dangerously-skip-permissions`, and you are supervised by a Claude orchestrator. `CLAUDE.md`
7
- governs the orchestrator; this file governs you. On any conflict, `CLAUDE.md` wins.
6
+ - the **coordinator** role lives in `CLAUDE.md`, which imports this file;
7
+ - the **worker** role (implementers and validators) lives in `docs/agents/worker.md`. **If you were
8
+ launched with a brief, you are a worker: follow that file and your brief, not `CLAUDE.md`;**
9
+ - coding standards live in `.claude/rules/` (see `.claude/rules/README.md`);
10
+ - the role pipeline, autonomy limits and protected actions live in `.agent-kit/` (`workflow.json`,
11
+ `autonomy.json`), and apply to every agent.
8
12
 
9
- Read `CLAUDE.md` and the applicable files in `.claude/rules/` before you start working.
13
+ On conflict: role file (`CLAUDE.md` or `docs/agents/worker.md`) > this file > `.claude/rules/`.
10
14
 
11
15
  ## Project
12
16
 
13
17
  **{{PROJECT_NAME}}** — {{PROJECT_DESCRIPTION}}
14
18
 
15
- ---
19
+ <!--IF:greenfield-->
20
+ ## Stack: not chosen yet
16
21
 
17
- ## 1. What you own
22
+ The repository is still a greenfield scaffold. Language, framework, package manager, directory
23
+ layout, and test tooling are **open decisions that belong to the user**. No agent picks them
24
+ unilaterally. If a task cannot proceed without one of them, ask.
18
25
 
19
- - Feature implementation
20
- - Routine refactoring
21
- - Tests
22
- - Documentation
23
- - Boilerplate
24
- - Straightforward debugging
25
- - Repetitive code changes
26
- - Applying fixes already diagnosed in `tasks/prd-<feature>/bugs.md`
26
+ `.claude/rules/` is split accordingly — see `.claude/rules/README.md`:
27
27
 
28
- ## 2. What you do not own
28
+ - **Always apply:** `code-standards.md`, `logging.md`, `tests.md` (principles, tool-agnostic).
29
+ - **Apply only if that technology is chosen:** `node.md`, `react.md`, `http.md`.
29
30
 
30
- - Architecture and technical decisions
31
- - Stack selection (see section 4)
32
- - Security-sensitive decisions
33
- - Difficult debugging and root-cause analysis
34
- - Planning and task decomposition
35
- - Final review
36
- - Commits, pushes, branch operations, and merges
31
+ Because no dependency manifest exists, there is **no runnable build, lint or test command yet**.
32
+ Never report a validation as passing when its command does not exist. Once the stack is chosen,
33
+ add its commands here and to the `checks` of `.agent-kit/config.json`.
34
+ <!--END-->
35
+ <!--IF:existing-->
36
+ ## Stack
37
37
 
38
- If a task pushes you into any of these, stop and escalate. Do not decide it yourself.
38
+ Detected manifest: `{{STACK_MANIFEST}}`.
39
39
 
40
- ---
40
+ `.claude/rules/` is split into two tiers — see `.claude/rules/README.md`:
41
41
 
42
- ## 3. Orca orchestration protocol
42
+ - **Always apply:** `code-standards.md`, `logging.md`, `tests.md` (principles, tool-agnostic).
43
+ - **Apply only if that technology is part of this project:** `node.md`, `react.md`, `http.md`.
43
44
 
44
- You receive work as a dispatched task carrying an injected `task_id` and `dispatch_id`. Never
45
- invent, guess, or reuse stale IDs. You are a worker: you do not dispatch sub-workers.
45
+ The code examples in the rules are illustrative and do not authorize adding a technology the
46
+ project does not have. Adding or replacing a language, framework, package manager or test tool is a
47
+ **user decision**.
46
48
 
47
- Report completion **exactly once**:
49
+ ### Commands
48
50
 
49
- ```bash
50
- orca orchestration send --type worker_done \
51
- --subject "<short status>" \
52
- --body "<what you did, what you found, what remains>" \
53
- --task-id <task_id> --dispatch-id <dispatch_id> \
54
- --outcome succeeded --files-modified "path/a,path/b" --json
55
- ```
51
+ The single source of truth for how to build, test and lint. Agents run exactly what is listed here;
52
+ if the one you need is missing, ask instead of guessing. Never report a validation as passing when
53
+ its command does not exist or was not executed.
54
+
55
+ | Purpose | Command |
56
+ |---|---|
57
+ | Install | `{{CMD_INSTALL}}` |
58
+ | Build | `{{CMD_BUILD}}` |
59
+ | Test | `{{CMD_TEST}}` |
60
+ | Lint | `{{CMD_LINT}}` |
61
+ | Typecheck | `{{CMD_TYPECHECK}}` |
62
+ | Single test | `{{CMD_TEST_ONE}}` |
63
+
64
+ The commands that gate a workflow (lint, typecheck, test, build) are mirrored in the `checks` of
65
+ `.agent-kit/config.json`. Keep both in sync.
66
+ <!--END-->
67
+
68
+ Design decisions and their rejected alternatives belong in `docs/adr/`, and the domain glossary in
69
+ `CONTEXT.md`, once they exist. Read both before planning or implementing: they explain why the
70
+ code looks the way it does.
71
+
72
+ ## Environment pitfalls
56
73
 
57
- - Encode failure with `--outcome failed`. Never signal failure in prose alone, and never exit
58
- silently.
59
- - Blocking question to the coordinator:
60
- `orca orchestration ask --question "<q>" --options "<a,b>" --timeout-ms 600000`.
61
- Never use an interactive local prompt — the coordinator cannot see or answer it.
62
- - Blocked before completion: `--type escalation`.
63
- - Long runs: `--type heartbeat` every 5 minutes, or `--type status` for progress.
64
- - Read coordinator messages with `orca orchestration check --terminal <your handle>`.
74
+ Facts about this machine and toolchain that cost a debugging session once. Keep them short; the
75
+ `/fechar-ciclo` command adds to this list.
65
76
 
66
- After `worker_done`, your turn is over. Stop, return to an idle prompt, and start nothing new.
67
- Do not exit the shell — the coordinator reviews your work and then closes this terminal itself.
77
+ - (none yet)
68
78
 
69
79
  ---
70
80
 
71
- ## 4. Stack constraints
81
+ ## Engineering rules
72
82
 
73
- <!--IF:greenfield-->
74
- The stack is **not chosen**. This repository has no source code, no package manager, no dependency
75
- manifest, no build system, no test suite, and no CI.
83
+ These bias toward caution over speed. For trivial tasks, use judgment.
76
84
 
77
- Hard rules:
85
+ ### Think before acting
78
86
 
79
- - Do not pick the language, framework, package manager, directory layout, or test tooling.
80
- - Do not scaffold a project structure on your own initiative.
81
- - Do not run or claim to have run a command that does not exist yet.
87
+ Do not assume, do not hide confusion, surface tradeoffs. State assumptions explicitly; if multiple
88
+ interpretations exist, present them instead of silently picking one. If something is unclear: a
89
+ worker reports `blocked`; the coordinator follows the escalation rules in `CLAUDE.md` (decide and
90
+ record a reversible assumption, or ask).
82
91
 
83
- If a task cannot proceed without one of those decisions, send an `ask` or an `escalation`. Never
84
- assume a default.
85
- <!--END-->
86
- <!--IF:existing-->
87
- This project already has a stack. The commands table in `CLAUDE.md` is the single source of truth
88
- for how to build, test and lint it.
92
+ ### Simplicity first
89
93
 
90
- Hard rules:
94
+ Minimum code that solves the problem, nothing speculative. No features beyond what was asked, no
95
+ abstractions for single-use code, no unrequested configurability, no error handling for impossible
96
+ scenarios. Simplicity governs **how** each item is implemented, never **whether** it is
97
+ implemented. Cutting scope is not simplification.
91
98
 
92
- - Use only the commands listed in `CLAUDE.md`. If the one you need is missing there, ask — do not
93
- guess an invocation.
94
- - Do not add, replace or upgrade a language, framework, package manager or test tool. That is a
95
- user decision, even when it looks like the obvious fix.
96
- - Do not introduce a new dependency unless the brief names it.
97
- - Do not run or claim to have run a command that does not exist or that you did not execute.
99
+ ### Surgical changes
98
100
 
99
- If a task cannot proceed without one of those decisions, send an `ask` or an `escalation`. Never
100
- assume a default.
101
- <!--END-->
101
+ Touch only what the task requires. Do not improve adjacent code, comments, or formatting. Do not
102
+ refactor what is not broken. Match existing style. Mention unrelated dead code instead of deleting
103
+ it. Remove only the imports and symbols your own change orphaned.
102
104
 
103
- `.claude/rules/README.md` says which rule files always apply and which only apply when the matching
104
- technology is part of the project. The code examples in the rules are illustrative, not a stack
105
- mandate.
105
+ ### Goal-driven execution
106
106
 
107
- ---
107
+ Turn every task into a verifiable goal before starting: "add validation" becomes "write tests for
108
+ invalid inputs, then make them pass". Weak success criteria ("make it work") guarantee rework.
108
109
 
109
- ## 5. Development workflow
110
+ ### The spec is the request
110
111
 
111
- 1. Read `CLAUDE.md`, this file, and the applicable `.claude/rules/` files.
112
- 2. Read the brief in full: objective, context, constraints, files involved, acceptance criteria,
113
- validation.
114
- 3. Work **only** inside the files the brief names. Touch nothing else.
115
- 4. Prefer small, reviewable diffs. Match the existing style.
116
- 5. Run the validation the brief specifies and observe the real output.
117
- 6. Report honestly — including what you did not do and why.
112
+ A PRD, TechSpec, or task file is a contract. Every item gets implemented. Never silently drop,
113
+ defer, merge, or "phase" items; if one looks unnecessary, ask before skipping. Before declaring a
114
+ multi-item task done, enumerate every item and its status:
118
115
 
119
- Never commit, push, stage, or switch branches. The coordinator reviews the working tree as-is.
116
+ ```
117
+ - [Item 1] -> done
118
+ - [Item 2] -> partial - what is missing and why
119
+ - [Item 3] -> skipped - reason, surfaced earlier
120
+ ```
120
121
 
121
- ---
122
+ ### Honesty about validation
122
123
 
123
- ## 6. Engineering rules
124
+ Never fabricate command output, test results, file paths, or dependencies. A validation counts only
125
+ when its output was observed in this session. Missing output means it did not run.
124
126
 
125
- The full set is in `CLAUDE.md` section 6 and `.claude/rules/`. The ones that most often go wrong:
127
+ ### Language
126
128
 
127
- - **Simplicity first** — minimum code that solves the problem. No speculative features,
128
- abstractions for single-use code, or unrequested configurability. Simplicity governs *how* you
129
- implement each item, never *whether* you implement it.
130
- - **Surgical changes** — do not improve adjacent code, comments, or formatting. Do not refactor
131
- what is not broken. Remove only the symbols your own change orphaned; mention other dead code
132
- instead of deleting it.
133
- - **The spec is the request** — implement every item in the brief. Never silently drop, defer, or
134
- merge items. Ambiguity is a question, not a licence to omit.
135
- - **Language** — code, identifiers, and comments in English; process documents
136
- (`prd.md`, `techspec.md`, `tasks.md`, `bugs.md`) in Portuguese.
137
- - **Comments** — prefer self-explanatory code. Comment only when the *why* is non-obvious.
129
+ - **English:** source code, identifiers, comments, commit messages, PR descriptions, `AGENTS.md`,
130
+ `CLAUDE.md`, `docs/agents/`.
131
+ - **Portuguese:** `.claude/commands/`, `.claude/templates/`, `.claude/rules/`, and every generated
132
+ process document (`prd.md`, `techspec.md`, `tasks.md`, `*_task.md`, `bugs.md`).
133
+ - Conversation with the user follows the user's language.
138
134
 
139
- ---
135
+ ### Comments
136
+
137
+ Prefer self-explanatory code. No restating what the code does, no TODOs, no section headers, no
138
+ "added for X" notes. Comment only when the *why* is non-obvious.
140
139
 
141
- ## 7. Definition of done
140
+ ### Commits
142
141
 
143
- A task is done only when all of the following hold:
142
+ - [Conventional Commits](https://www.conventionalcommits.org/): `type(scope): subject`, imperative,
143
+ lowercase, no trailing period.
144
+ - **Never add `Co-Authored-By:` trailers or any assistant attribution.**
145
+ - Only the coordinator commits, and only when the user asks or `permissions.localCommits` in
146
+ `.agent-kit/autonomy.json` is true. Pushing follows `permissions.push`.
144
147
 
145
- - Every acceptance criterion in the brief is met.
146
- - Every item in the brief is implemented, or explicitly reported as partial or skipped with a
147
- reason.
148
- - The specified validation was actually executed and its output observed.
149
- - No unrequested scope was added and no unrelated file was touched.
150
- - Nothing is fabricated: no invented command output, test result, file path, or dependency.
148
+ ### Code quality
151
149
 
152
- Then, and only then, send `worker_done`.
150
+ Keep functions small and well under the complexity ceiling, modules focused, dependencies pointing
151
+ toward stable abstractions with no cycles. Tests cover the branches that can break, and their
152
+ assertions would fail if the logic were subtly wrong (`>` to `>=`, a flipped sign, a deleted line).
153
153
 
154
154
  ---
155
155
 
156
- ## 8. Maintenance
156
+ ## Maintaining this file
157
157
 
158
- Update this file whenever the stack lands or the worker protocol changes, in the same pass as
159
- `CLAUDE.md` and `.claude/rules/README.md`.
158
+ Generated by `agent-kit` as a starting point. Keep it true to what the project is: exact commands,
159
+ non-obvious relationships between modules, conventions a newcomer could not infer from one file.
160
+ Keep it under ~200 lines; move topic-specific rules into `.claude/rules/`.