@ethlete/agent-rules 0.1.0-next.37 → 0.1.0-next.39

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 (62) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +43 -5
  3. package/content/hooks/away-mode.py +287 -0
  4. package/content/hooks/background-design-commands.py +42 -7
  5. package/content/hooks/context-warning.py +2 -44
  6. package/content/hooks/subagent-model-policy.py +90 -23
  7. package/content/mods/.claude-plugin/marketplace.json +5 -0
  8. package/content/mods/plugins/e2e-progress/.claude-plugin/plugin.json +1 -1
  9. package/content/mods/plugins/status-line/.claude-plugin/plugin.json +6 -0
  10. package/content/mods/plugins/status-line/hooks/hooks.json +1 -0
  11. package/content/mods/plugins/status-line/hooks/line.ts +73 -0
  12. package/content/mods/plugins/status-line/hooks/register.tsx +141 -0
  13. package/content/mods/plugins/status-line/types/index.d.ts +5 -0
  14. package/content/rules/subagent-models.md +9 -6
  15. package/content/skills/agent-sessions/SKILL.md +2 -2
  16. package/content/skills/agent-sessions/agent-sessions.mjs +30 -14
  17. package/content/skills/angular-patterns/SKILL.md +1 -1
  18. package/content/skills/codex-subagent/SKILL.md +1 -1
  19. package/content/skills/design-exploration/SKILL.md +5 -2
  20. package/content/skills/figma-export/SKILL.md +1 -1
  21. package/content/skills/handoff/SKILL.md +4 -187
  22. package/content/skills/handoff/save.md +187 -0
  23. package/content/skills/query/SKILL.md +1 -1
  24. package/content/skills/report/SKILL.md +26 -0
  25. package/content/skills/rxjs-signals/SKILL.md +1 -1
  26. package/content/skills/styleguide/SKILL.md +1 -1
  27. package/content/skills/styleguide/lint-rule-lookup.md +42 -41
  28. package/content/skills/theming/SKILL.md +1 -1
  29. package/content/skills/timetrack/SKILL.md +37 -1
  30. package/content/skills/verify-in-storybook/SKILL.md +1 -1
  31. package/package.json +1 -1
  32. package/src/index.js +13 -2
  33. package/src/index.js.map +1 -1
  34. package/src/lib/config.d.ts +13 -0
  35. package/src/lib/config.js +13 -3
  36. package/src/lib/config.js.map +1 -1
  37. package/src/lib/peer-path.d.ts +12 -0
  38. package/src/lib/peer-path.js +39 -0
  39. package/src/lib/peer-path.js.map +1 -0
  40. package/src/lib/plan.js +10 -2
  41. package/src/lib/plan.js.map +1 -1
  42. package/src/lib/render.d.ts +1 -0
  43. package/src/lib/render.js +3 -1
  44. package/src/lib/render.js.map +1 -1
  45. package/src/lib/report-command.d.ts +33 -0
  46. package/src/lib/report-command.js +312 -0
  47. package/src/lib/report-command.js.map +1 -0
  48. package/src/lib/targets/claude-mods.js +1 -1
  49. package/src/lib/targets/claude-mods.js.map +1 -1
  50. package/src/lib/targets/hooks-shared.js +6 -0
  51. package/src/lib/targets/hooks-shared.js.map +1 -1
  52. package/src/lib/targets/mcp.d.ts +6 -6
  53. package/src/lib/targets/mcp.js +9 -5
  54. package/src/lib/targets/mcp.js.map +1 -1
  55. package/src/lib/timetrack-command.js +240 -41
  56. package/src/lib/timetrack-command.js.map +1 -1
  57. package/src/lib/timetrack-snapshot.d.ts +11 -0
  58. package/src/lib/timetrack-snapshot.js +27 -1
  59. package/src/lib/timetrack-snapshot.js.map +1 -1
  60. package/src/lib/timetrack.d.ts +48 -2
  61. package/src/lib/timetrack.js +8 -2
  62. package/src/lib/timetrack.js.map +1 -1
@@ -1,16 +1,15 @@
1
1
  #!/usr/bin/env python3
2
- """PreToolUse hook: make a subagent's model an explicit choice.
2
+ """PreToolUse hook: run a subagent on sonnet unless its call names a model.
3
3
 
4
4
  A `Task` call that passes no `model` runs the subagent on the parent session's
5
5
  model. A session led by an expensive model therefore spends that model on every
6
6
  grep and every file read it delegates, which burns a usage limit in minutes for
7
7
  work a small model does just as well.
8
8
 
9
- So this hook gates the tool call rather than only advising:
9
+ So this hook rewrites or gates the tool call:
10
10
 
11
- * No `model` at all - denied, with the model table returned to the agent. The
12
- agent then repeats the call with a model, so the cost of the mistake is one
13
- tool call, not a whole subagent run.
11
+ * No `model` at all - allowed with `model: sonnet` filled in, and a short note
12
+ that names the models to pick explicitly instead.
14
13
  * `model: fable` - the user is asked. Fable is the right pick for planning,
15
14
  design, cross-cutting review and leading other subagents, and the wrong pick
16
15
  for the twentieth mechanical lookup; only the user knows which this is.
@@ -21,6 +20,12 @@ Two cases are left alone, because the tool's `model` would change nothing:
21
20
  * `subagent_type: fork`, which always inherits the parent model.
22
21
  * An agent type whose own definition under `.claude/agents/` sets a model.
23
22
 
23
+ Every subagent start, whatever the decision, appends one JSON line to
24
+ `<git common dir>/ethlete/subagent-starts.jsonl`: time, session, HEAD, branch,
25
+ the model it will run on, effort, agent type, description, the prompt's head and
26
+ the file paths the prompt names. It lives inside `.git`, so it is never committed,
27
+ and HEAD plus the paths join it with later commits.
28
+
24
29
  Can be disabled per machine via a gitignored ethlete-agents.config.local.json at
25
30
  the repo root: {"disableHooks": true} or {"disableHooks": ["subagent-model-policy"]}.
26
31
 
@@ -30,7 +35,10 @@ because it could not read its own input.
30
35
 
31
36
  import json
32
37
  import os
38
+ import re
39
+ import subprocess
33
40
  import sys
41
+ from datetime import datetime, timezone
34
42
 
35
43
  HOOK_NAME = "subagent-model-policy"
36
44
  LOCAL_CONFIG_FILE = "ethlete-agents.config.local.json"
@@ -38,9 +46,15 @@ LOCAL_CONFIG_FILE = "ethlete-agents.config.local.json"
38
46
  # The tool that spawns a subagent, under both names it has carried.
39
47
  SUBAGENT_TOOLS = ("Task", "Agent")
40
48
 
41
- POLICY = """A subagent's model is a choice, not an inheritance. This call passes no `model`, so the subagent \
42
- would run on the model leading this session - which is how one expensive model ends up doing every small job. \
43
- Call the tool again with `model` set:
49
+ DEFAULT_MODEL = "sonnet"
50
+
51
+ LOG_FILE = os.path.join("ethlete", "subagent-starts.jsonl")
52
+ PROMPT_HEAD_CHARS = 300
53
+ MAX_LOGGED_FILES = 50
54
+ FILE_PATH = re.compile(r"(?<![\w/.-])(?:\.?[\w@-][\w@.-]*/)+[\w@.-]*\.[A-Za-z0-9]{1,8}(?![\w/])")
55
+
56
+ POLICY = """This call passed no `model`, so the subagent runs on sonnet, the default. Name a model on the next \
57
+ call when the task fits another one:
44
58
 
45
59
  - `haiku` - lookups and small, fully specified jobs: grep, find, read and summarize files or a CI log, run a command and report, a mechanical edit in named files.
46
60
  - `sonnet` - scoped work with a clear target: a fix in a named file, a spec, a docs page, a lint cleanup, \
@@ -135,17 +149,68 @@ def definition_sets_model(root, subagent_type):
135
149
 
136
150
 
137
151
  def decision_for(tool_input, root):
138
- """The (decision, reason) this call needs, or None when it may run untouched."""
152
+ """The (decision, reason, updated input or None) this call needs, or None when it may run untouched."""
139
153
  subagent_type = str(tool_input.get("subagent_type") or "").strip().lower()
140
154
  model = str(tool_input.get("model") or "").strip().lower()
141
155
 
142
156
  if "fable" in model:
143
- return "ask", FABLE_REASON
157
+ return "ask", FABLE_REASON, None
144
158
  if model:
145
159
  return None
146
160
  if subagent_type == "fork" or definition_sets_model(root, subagent_type):
147
161
  return None
148
- return "deny", POLICY
162
+ return "allow", POLICY, {**tool_input, "model": DEFAULT_MODEL}
163
+
164
+
165
+ def git(root, *args):
166
+ result = subprocess.run(["git", "-C", root, *args], capture_output=True, text=True, timeout=3)
167
+ return result.stdout.strip() if result.returncode == 0 else ""
168
+
169
+
170
+ def prompt_files(prompt):
171
+ files = []
172
+ for match in FILE_PATH.findall(prompt):
173
+ path = match.split(":")[0]
174
+ if path not in files:
175
+ files.append(path)
176
+ return files[:MAX_LOGGED_FILES]
177
+
178
+
179
+ def run_model(tool_input, outcome):
180
+ """The model the subagent will run on, or how it is chosen when the call does not name one."""
181
+ if outcome and outcome[2] is not None:
182
+ return outcome[2].get("model")
183
+ model = str(tool_input.get("model") or "").strip().lower()
184
+ if model:
185
+ return model
186
+ subagent_type = str(tool_input.get("subagent_type") or "").strip().lower()
187
+ return "inherit" if subagent_type == "fork" else "definition"
188
+
189
+
190
+ def log_start(data, tool_input, root, outcome):
191
+ common_dir = git(root, "rev-parse", "--path-format=absolute", "--git-common-dir")
192
+ if not common_dir:
193
+ return
194
+ prompt = str(tool_input.get("prompt") or "")
195
+ entry = {
196
+ "time": datetime.now(timezone.utc).isoformat(timespec="seconds"),
197
+ "session": data.get("session_id"),
198
+ "toolUseId": data.get("tool_use_id"),
199
+ "head": git(root, "rev-parse", "HEAD"),
200
+ "branch": git(root, "rev-parse", "--abbrev-ref", "HEAD"),
201
+ "model": run_model(tool_input, outcome),
202
+ "decision": outcome[0] if outcome else "untouched",
203
+ "effort": tool_input.get("effort"),
204
+ "subagentType": tool_input.get("subagent_type"),
205
+ "description": tool_input.get("description"),
206
+ "prompt": prompt[:PROMPT_HEAD_CHARS],
207
+ "promptChars": len(prompt),
208
+ "files": prompt_files(prompt),
209
+ }
210
+ path = os.path.join(common_dir, LOG_FILE)
211
+ os.makedirs(os.path.dirname(path), exist_ok=True)
212
+ with open(path, "a", encoding="utf-8") as f:
213
+ f.write(json.dumps(entry) + "\n")
149
214
 
150
215
 
151
216
  def main():
@@ -169,21 +234,23 @@ def main():
169
234
 
170
235
  outcome = decision_for(tool_input, root)
171
236
 
237
+ try:
238
+ log_start(data, tool_input, root, outcome)
239
+ except Exception:
240
+ pass
241
+
172
242
  if not outcome:
173
243
  return
174
244
 
175
- decision, reason = outcome
176
- print(
177
- json.dumps(
178
- {
179
- "hookSpecificOutput": {
180
- "hookEventName": "PreToolUse",
181
- "permissionDecision": decision,
182
- "permissionDecisionReason": reason,
183
- }
184
- }
185
- )
186
- )
245
+ decision, reason, updated_input = outcome
246
+ output = {
247
+ "hookEventName": "PreToolUse",
248
+ "permissionDecision": decision,
249
+ "permissionDecisionReason": reason,
250
+ }
251
+ if updated_input is not None:
252
+ output["updatedInput"] = updated_input
253
+ print(json.dumps({"hookSpecificOutput": output}))
187
254
 
188
255
 
189
256
  if __name__ == "__main__":
@@ -6,6 +6,11 @@
6
6
  "name": "e2e-progress",
7
7
  "source": "./plugins/e2e-progress",
8
8
  "description": "Live Playwright e2e progress from a run log, as a status line entry and a pane"
9
+ },
10
+ {
11
+ "name": "status-line",
12
+ "source": "./plugins/status-line",
13
+ "description": "Always-visible band with the running task, its duration, the open queue, open questions and a CI blocked mark"
9
14
  }
10
15
  ]
11
16
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "e2e-progress",
3
- "version": "0.1.0-next.37",
3
+ "version": "0.1.0-next.39",
4
4
  "description": "Live Playwright e2e progress from a run log, as a status line entry and a pane",
5
5
  "types": "./types/index.d.ts"
6
6
  }
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "status-line",
3
+ "version": "0.1.0-next.39",
4
+ "description": "Always-visible band with the running task, its duration, the open queue, open questions and a CI blocked mark",
5
+ "types": "./types/index.d.ts"
6
+ }
@@ -0,0 +1 @@
1
+ { "modules": ["./register.tsx"] }
@@ -0,0 +1,73 @@
1
+ const STALE_MS = 2 * 60 * 60 * 1000;
2
+ const QUEUE_HEADING = /^### Warteschlange(, Rest)?\s*$/;
3
+ const HEADING = /^#{1,6} /;
4
+ const QUEUE_ITEM = /^\d+\. \*\*(?:.+ \()?[A-Z]\d+b?\)?\*\*/;
5
+
6
+ export type StatusFields = {
7
+ task?: string;
8
+ minutes?: number;
9
+ queue?: number;
10
+ questions?: number;
11
+ isCiRot?: boolean;
12
+ };
13
+
14
+ export const lastSlice = (content: string, mtimeMs: number) => {
15
+ const blocks = content.split(/^(?=#\s*slice:)/m).filter((text) => /^#\s*slice:/m.test(text));
16
+ const block = blocks[blocks.length - 1];
17
+ if (block === undefined) return undefined;
18
+ const name = /^#\s*slice:\s*(.+)$/m.exec(block)?.[1]?.trim();
19
+ const written = /^#\s*written:\s*(\S+)/m.exec(block)?.[1];
20
+ const writtenAt = written && !Number.isNaN(Date.parse(written)) ? Date.parse(written) : mtimeMs;
21
+ return name ? { name, writtenAt } : undefined;
22
+ };
23
+
24
+ export const taskFields = (content: string, mtimeMs: number, nowMs: number): Pick<StatusFields, 'task' | 'minutes'> => {
25
+ const slice = lastSlice(content, mtimeMs);
26
+ if (slice === undefined) return {};
27
+ if (nowMs - slice.writtenAt > STALE_MS) return { task: 'kein Slice' };
28
+ return { task: slice.name, minutes: Math.max(0, Math.floor((nowMs - slice.writtenAt) / 60_000)) };
29
+ };
30
+
31
+ export const queueCount = (text: string) => {
32
+ let count = 0;
33
+ let isInQueue = false;
34
+ for (const line of text.split('\n')) {
35
+ if (HEADING.test(line)) isInQueue = QUEUE_HEADING.test(line);
36
+ else if (isInQueue && QUEUE_ITEM.test(line)) count++;
37
+ }
38
+ return count;
39
+ };
40
+
41
+ export const questionCount = (text: string) => text.split('\n').filter((line) => line.startsWith('- ')).length;
42
+
43
+ export const planFilesOf = (configText: string) => {
44
+ try {
45
+ const files = (JSON.parse(configText) as { report?: { planFiles?: unknown } }).report?.planFiles;
46
+ return Array.isArray(files) && files.every((f) => typeof f === 'string') ? (files as string[]) : undefined;
47
+ } catch {
48
+ return undefined;
49
+ }
50
+ };
51
+
52
+ export const isCiRotOf = (runJson: string) => {
53
+ try {
54
+ const [run] = JSON.parse(runJson) as { conclusion?: string; status?: string }[];
55
+ return run?.status === 'completed' && run.conclusion === 'failure';
56
+ } catch {
57
+ return false;
58
+ }
59
+ };
60
+
61
+ const durationOf = (minutes: number) =>
62
+ minutes < 60 ? `${minutes} min` : `${Math.floor(minutes / 60)} h ${minutes % 60} min`;
63
+
64
+ export const formatLine = (fields: StatusFields) => {
65
+ const parts = [
66
+ fields.task === undefined ? undefined : `▶ ${fields.task}`,
67
+ fields.minutes === undefined ? undefined : durationOf(fields.minutes),
68
+ fields.queue === undefined ? undefined : `${fields.queue} offen`,
69
+ fields.questions ? `❓${fields.questions}` : undefined,
70
+ fields.isCiRot ? '⛔ CI rot' : undefined,
71
+ ].filter((part): part is string => part !== undefined);
72
+ return parts.length === 0 ? null : parts.join(' · ');
73
+ };
@@ -0,0 +1,141 @@
1
+ import { atom, update } from 'claude-code';
2
+ import type { EngineInterface, Register } from 'claude-code';
3
+
4
+ import { formatLine, isCiRotOf, planFilesOf, questionCount, queueCount, taskFields } from './line';
5
+ import type { StatusFields } from './line';
6
+
7
+ const TICK_MS = 5000;
8
+ const CI_EVERY_MS = 2 * 60_000;
9
+ const CI_TIMEOUT_MS = 15_000;
10
+ const ROLE_SKILLS: Record<string, boolean> = { 'doc-agent': true, 'builder-agent': false };
11
+ const line = atom({ plugin: 'status-line', key: 'line' } as const, null);
12
+ const isDocSession = atom({ plugin: 'status-line', key: 'isDocSession' } as const, false);
13
+
14
+ async function markRole($: EngineInterface, skill: string | undefined) {
15
+ const isDoc = skill === undefined ? undefined : ROLE_SKILLS[skill];
16
+ if (isDoc !== undefined) await update($, isDocSession, () => isDoc);
17
+ }
18
+
19
+ type Source = { mtimeMs: number; text: string };
20
+
21
+ const cache = new Map<string, Source | null>();
22
+
23
+ async function readChanged($: EngineInterface, path: string) {
24
+ const stat = await $.fs.stat(path).catch(() => undefined);
25
+ if (stat === undefined) {
26
+ cache.delete(path);
27
+ return null;
28
+ }
29
+ const cached = cache.get(path);
30
+ if (cached && cached.mtimeMs === stat.mtimeMs) return cached;
31
+ const text = await $.fs.read(path).catch(() => undefined);
32
+ if (text === undefined) return null;
33
+ const source = { mtimeMs: stat.mtimeMs, text };
34
+ cache.set(path, source);
35
+ return source;
36
+ }
37
+
38
+ async function git($: EngineInterface, args: string[]) {
39
+ const result = await $.process.run(['git', ...args], { timeoutMs: 5000 }).catch(() => undefined);
40
+ return result?.exitCode === 0 ? result.stdout.trim() : undefined;
41
+ }
42
+
43
+ let isCiRot = false;
44
+ let lastCiMs = 0;
45
+ let isCiRunning = false;
46
+
47
+ async function refreshCi($: EngineInterface, nowMs: number) {
48
+ if (isCiRunning || nowMs - lastCiMs < CI_EVERY_MS) return;
49
+ isCiRunning = true;
50
+ lastCiMs = nowMs;
51
+ try {
52
+ const branch = await git($, ['branch', '--show-current']);
53
+ const result = branch
54
+ ? await $.process.run(['gh', 'run', 'list', '--branch', branch, '-L', '1', '--json', 'conclusion,status'], {
55
+ timeoutMs: CI_TIMEOUT_MS,
56
+ })
57
+ : undefined;
58
+ isCiRot = result?.exitCode === 0 && isCiRotOf(result.stdout);
59
+ } catch {
60
+ isCiRot = false;
61
+ } finally {
62
+ isCiRunning = false;
63
+ }
64
+ }
65
+
66
+ async function compute($: EngineInterface, nowMs: number): Promise<StatusFields> {
67
+ const paths = await git($, [
68
+ 'rev-parse',
69
+ '--path-format=absolute',
70
+ '--git-path',
71
+ 'slice-paths',
72
+ '--git-common-dir',
73
+ '--show-toplevel',
74
+ ]);
75
+ const [slicePath, commonDir, root] = paths?.split('\n') ?? [];
76
+ const fields: StatusFields = {};
77
+
78
+ if (slicePath) {
79
+ const slice = await readChanged($, slicePath);
80
+ if (slice) Object.assign(fields, taskFields(slice.text, slice.mtimeMs, nowMs));
81
+ }
82
+
83
+ if (root) {
84
+ const config = await readChanged($, `${root}/ethlete-agents.config.json`);
85
+ const planFiles = config ? planFilesOf(config.text) : undefined;
86
+ if (planFiles) {
87
+ const texts = await Promise.all(planFiles.map((file) => readChanged($, `${root}/${file}`)));
88
+ fields.queue = texts.reduce((sum, source) => sum + (source ? queueCount(source.text) : 0), 0);
89
+ }
90
+ }
91
+
92
+ if (commonDir) {
93
+ const questions = await readChanged($, `${commonDir}/ethlete/open-questions.md`);
94
+ if (questions) fields.questions = questionCount(questions.text);
95
+ }
96
+
97
+ fields.isCiRot = isCiRot;
98
+ return fields;
99
+ }
100
+
101
+ async function tick($: EngineInterface) {
102
+ try {
103
+ if (!(await $.state.get({ plugin: 'status-line', key: 'isDocSession' } as const)).value) return;
104
+ const nowMs = await $.clock.now();
105
+ void refreshCi($, nowMs);
106
+ const text = formatLine(await compute($, nowMs));
107
+ await update($, line, () => text);
108
+ } catch {
109
+ await update($, line, () => null).catch(() => undefined);
110
+ }
111
+ }
112
+
113
+ export const register: Register = (on) => {
114
+ on('session.start', async ($, e, next) => {
115
+ $.clock.every(TICK_MS, () => tick($));
116
+ await tick($);
117
+ return next(e);
118
+ });
119
+
120
+ on('tool.call', { tool: 'Skill' }, async ($, e, next) => {
121
+ await markRole($, e.skill).catch(() => undefined);
122
+ return next(e);
123
+ });
124
+
125
+ on('prompt.submit', async ($, e, next) => {
126
+ await markRole($, e.command?.name).catch(() => undefined);
127
+ return next(e);
128
+ });
129
+
130
+ on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
131
+ if (!(await $.state.get({ plugin: 'status-line', key: 'isDocSession' } as const)).value) return next(e);
132
+ const text = (await $.state.get({ plugin: 'status-line', key: 'line' } as const)).value;
133
+ if (!text) return next(e);
134
+ const { Box, Text } = $.ui.resolve(e);
135
+ return (
136
+ <Box>
137
+ <Text dimColor>{text}</Text>
138
+ </Box>
139
+ );
140
+ });
141
+ };
@@ -0,0 +1,5 @@
1
+ declare module 'claude-code' {
2
+ interface PluginState {
3
+ 'status-line': { line: string | null; isDocSession: boolean };
4
+ }
5
+ }
@@ -1,15 +1,16 @@
1
1
  ---
2
2
  name: subagent-models
3
- description: A subagent's model is an explicit choice on every call - haiku for lookups and small specified jobs, sonnet for scoped work, opus for hard work, fable for judgment.
3
+ description: A subagent runs on sonnet unless its call names a model - haiku for lookups and small specified jobs, opus for hard work, fable for judgment.
4
4
  kind: rule
5
5
  scope: both
6
6
  ---
7
7
 
8
- ## Delegating: name the subagent's model
8
+ ## Delegating: sonnet by default
9
9
 
10
- A subagent spawned without a `model` runs on the model leading the session, so an expensive
11
- model ends up doing every small job it delegates. **Set `model` on every call**, matched to the
12
- task:
10
+ A subagent spawned without a `model` would run on the model leading the session, so an expensive
11
+ model would do every small job it delegates. The `subagent-model-policy` hook fills in **`sonnet`**
12
+ for such a call. Name another model only when the task matches its row below - `opus` only for the
13
+ work its row lists:
13
14
 
14
15
  | Model | The work it fits |
15
16
  | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -25,7 +26,9 @@ inherits the parent's model.
25
26
 
26
27
  A subagent starts cold: it loads the full start context (about 50k tokens) before its first step,
27
28
  and measured subagents cost as much as the sessions that spawn them. A lookup or job of under about 10 tool
28
- calls stays in the session. Give each subagent one large slice, not several small ones.
29
+ calls stays in the session. Give each subagent one large slice, not several small ones, and name the files and line ranges
30
+ in its prompt so it does not search for them. Stop each
31
+ background subagent with `TaskStop` once its result is in, so finished ones do not pile up.
29
32
 
30
33
  A subagent has the same context budget as the session, measured on its own transcript, and the
31
34
  context-warning hook tells it to hand back at the critical tier. Size each prompt to fit: one
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: agent-sessions
3
- description: Run agents in tmux sessions of one checkout, message them, wake idle ones, restart a session with a prompt (also your own, to clear yourself and resume after a handoff), and claim paths so two agents do not overwrite each other. Read before you edit a shared file while another agent may be active, and when the user says "mailbox", "coordinate with the other agent", "claim a file", "hand off to the other agent", or "restart the session".
3
+ description: 'Run agents in tmux sessions of one checkout: message, wake, restart them, claim paths. Read before editing a shared file while another agent may be active, or on "mailbox", "claim a file", "restart the session".'
4
4
  kind: skill
5
5
  scope: both
6
6
  ---
@@ -89,6 +89,6 @@ If the prompt of the agent holds typed text, the dispatcher waits until that tex
89
89
  4. After each larger step, run `inbox` again. Most agents cannot wake on new output, so you must pull messages yourself.
90
90
  5. When you finish, run `release`. A claim also expires after 4 hours, or after `--ttl` hours.
91
91
 
92
- In this repo commit with `yarn commit -m "..." -- <paths>`: it adds untracked paths and waits for `.git/index.lock`. Specs, lint and typecheck run in CI, not in the hook.
92
+ In this repo commit with `yarn commit -m "..." -- <paths>`: it adds untracked paths and waits for `.git/index.lock`. The hook lints staged files; typecheck and most specs run later.
93
93
 
94
94
  A claim is advisory, not a lock. `--force` claims over another agent: use it only after the holder agreed. Silence is not approval. Acknowledge each handoff in words. No agent starts automatically. The user starts each one.
@@ -31,6 +31,8 @@ const ENTER_DELAY_MS = 400;
31
31
  const WAKE_GRACE_MS = 1500;
32
32
  const DRAFT_RETRY_MS = 2000;
33
33
  const RESTART_AFTER_SECONDS = 5;
34
+ const RESTART_MARKER = ' [typed by agent-sessions]';
35
+ const restartPrompt = (words) => `${words.join(' ')}${RESTART_MARKER}`;
34
36
  const RESTART_CLEAR_MS = 2500;
35
37
  const RESTART_POLL_MS = 2000;
36
38
  const RESTART_WAIT_MS = Number(process.env.AGENT_RESTART_WAIT_MS ?? 30 * 60 * 1000);
@@ -108,6 +110,15 @@ const tmux = (...tmuxArgs) => spawnSync('tmux', tmuxArgs, { encoding: 'utf8' });
108
110
  const quote = (text) => `'${text.replaceAll("'", "'\\''")}'`;
109
111
  const BUILDER_PROMPT =
110
112
  'The user does not read this chat. Write no text between tool calls; end each turn with at most one line. Reports go to the grill session via SendMessage.';
113
+ const BUILDER_DENIED_TOOLS =
114
+ 'Artifact Workflow ScheduleWakeup SendFeedback ShareOnboardingGuide ReportFindings AskUserQuestion';
115
+ const builderFlags = () => [
116
+ '--append-system-prompt',
117
+ BUILDER_PROMPT,
118
+ '--strict-mcp-config',
119
+ `--mcp-config=${join(root, '.mcp.json')}`,
120
+ `--disallowedTools=${BUILDER_DENIED_TOOLS}`,
121
+ ];
111
122
  const claudeTmpDir = join(homedir(), '.cache', 'claude-tmp');
112
123
  const ensuredClaudeTmpDir = () => {
113
124
  mkdirSync(claudeTmpDir, { recursive: true });
@@ -116,7 +127,12 @@ const ensuredClaudeTmpDir = () => {
116
127
  const tempDirEnv = () => `CLAUDE_CODE_TMPDIR=${quote(ensuredClaudeTmpDir())} `;
117
128
  const withTempDir = (command) => (/(^|\s)CLAUDE_CODE_TMPDIR=/.test(command) ? command : `${tempDirEnv()}${command}`);
118
129
  const withRole = (words) =>
119
- role === 'builder' && basename(words[0]) === 'claude' ? [...words, '--append-system-prompt', BUILDER_PROMPT] : words;
130
+ role === 'builder' && basename(words[0]) === 'claude' ? [...words, ...builderFlags()] : words;
131
+ const roleEnvOf = (agentRole) =>
132
+ agentRole
133
+ ? { ETHLETE_AGENT_ROLE: agentRole, ...(agentRole === 'builder' ? { CLAUDE_CODE_SILENT_TURN_REMINDER: '0' } : {}) }
134
+ : {};
135
+ const roleEnvWords = (agentRole) => Object.entries(roleEnvOf(agentRole)).map(([key, value]) => `${key}=${value}`);
120
136
  const sessionExists = (name) => tmux('has-session', '-t', `=${name}`).status === 0;
121
137
  const ROLE_OPTION = '@ethlete_role';
122
138
  const COMMAND_OPTION = '@ethlete_command';
@@ -281,13 +297,13 @@ const commandWithRole = (command, agentRole) => {
281
297
  const kept = words.filter(
282
298
  (word, index) =>
283
299
  !(word === '--append-system-prompt' && words[index + 1] === BUILDER_PROMPT) &&
284
- !(word === BUILDER_PROMPT && words[index - 1] === '--append-system-prompt'),
300
+ !(word === BUILDER_PROMPT && words[index - 1] === '--append-system-prompt') &&
301
+ !/^(--strict-mcp-config|--mcp-config=.*|--disallowedTools=.*)$/.test(word),
285
302
  );
286
- const rule =
287
- agentRole === 'builder' && basename(kept[0] ?? '') === 'claude' ? ['--append-system-prompt', BUILDER_PROMPT] : [];
303
+ const rule = agentRole === 'builder' && basename(kept[0] ?? '') === 'claude' ? builderFlags() : [];
288
304
  return [
289
- ...env.filter((word) => !word.startsWith('ETHLETE_AGENT_ROLE=')),
290
- `ETHLETE_AGENT_ROLE=${agentRole}`,
305
+ ...env.filter((word) => !/^(ETHLETE_AGENT_ROLE|CLAUDE_CODE_SILENT_TURN_REMINDER)=/.test(word)),
306
+ ...roleEnvWords(agentRole),
291
307
  ...[...kept, ...rule].map(quote),
292
308
  ].join(' ');
293
309
  };
@@ -570,9 +586,7 @@ if (command === 'send' && sender) {
570
586
  process.stderr.write(`Unknown role ${role}. Only builder exists.\n`);
571
587
  process.exitCode = 1;
572
588
  } else if (command === 'run' && sender && words.length && dryRun) {
573
- process.stdout.write(
574
- `${withTempDir(`${role ? `ETHLETE_AGENT_ROLE=${role} ` : ''}${withRole(words).map(quote).join(' ')}`)}\n`,
575
- );
589
+ process.stdout.write(`${withTempDir([...roleEnvWords(role), ...withRole(words).map(quote)].join(' '))}\n`);
576
590
  } else if (command === 'run' && sender && words.length && !runsInSession(words.slice(1))) {
577
591
  const [program, ...programArgs] = withRole(words);
578
592
  process.exitCode =
@@ -581,7 +595,7 @@ if (command === 'send' && sender) {
581
595
  env: {
582
596
  ...process.env,
583
597
  CLAUDE_CODE_TMPDIR: ensuredClaudeTmpDir(),
584
- ...(role ? { ETHLETE_AGENT_ROLE: role } : {}),
598
+ ...roleEnvOf(role),
585
599
  },
586
600
  }).status ?? 1;
587
601
  } else if (command === 'run' && sender && words.length) {
@@ -589,7 +603,9 @@ if (command === 'send' && sender) {
589
603
  if (!sessionExists(DISPATCH_SESSION))
590
604
  startSession(DISPATCH_SESSION, `${withEnv}node ${quote(script)} dispatch`, true);
591
605
  const session = freeSessionFor(sender);
592
- const roleEnv = role ? `ETHLETE_AGENT_ROLE=${role} ` : '';
606
+ const roleEnv = roleEnvWords(role)
607
+ .map((word) => `${word} `)
608
+ .join('');
593
609
  const shellCommand = withTempDir(`${roleEnv}${withRole(words).map(quote).join(' ')}`);
594
610
  const baseCommand = withTempDir(`${roleEnv}${withRole(withoutPrompt(words)).map(quote).join(' ')}`);
595
611
  if (!hasTerminal) {
@@ -783,7 +799,7 @@ if (command === 'send' && sender) {
783
799
  root,
784
800
  shell,
785
801
  '-lic',
786
- `${bypassingShellFunction(base)} ${quote(words.join(' '))}`,
802
+ `${bypassingShellFunction(base)} ${quote(restartPrompt(words))}`,
787
803
  );
788
804
  tmux('set-option', '-p', '-t', pane, 'remain-on-exit', 'off');
789
805
  tmux('set-option', '-t', pane, COMMAND_OPTION, base);
@@ -795,13 +811,13 @@ if (command === 'send' && sender) {
795
811
  type('Enter');
796
812
  sleep(RESTART_CLEAR_MS);
797
813
  if (waitForQuiet(session, RESTART_CLEAR_WAIT_MS, true) && leavePanel(session)) {
798
- type('-l', words.join(' '));
814
+ type('-l', restartPrompt(words));
799
815
  sleep(ENTER_DELAY_MS);
800
816
  type('Enter');
801
817
  waitForFirstTurn(session);
802
818
  } else {
803
819
  const saved = join(dirname(mailbox), `restart.prompt.${session}.txt`);
804
- writeFileSync(saved, `${words.join(' ')}\n`);
820
+ writeFileSync(saved, `${restartPrompt(words)}\n`);
805
821
  restartNotice(
806
822
  `restart of ${session} gave up: prompt not empty ${RESTART_CLEAR_WAIT_MS / 1000}s after the clear, prompt not typed, saved to ${saved}`,
807
823
  );
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: angular-patterns
3
- description: How to build Angular pieces the Ethlete way - templates, lifecycle, and when to reach for a component/directive/service/pipe vs a plain function. Read when writing or restructuring a component, directive, service, or pipe, wiring up lifecycle, or binding values in a template.
3
+ description: 'Building Angular pieces the Ethlete way: templates, lifecycle, component vs directive vs service vs pipe vs plain function. Read when writing or restructuring one of those or binding values in a template.'
4
4
  kind: skill
5
5
  scope: both
6
6
  requires: ['@ethlete/core']
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: codex-subagent
3
- description: Delegate a task to a Codex agent (gpt-6-luna, gpt-6.1-terra, gpt-6.1-sol, gpt-6-astra) instead of a Claude subagent - a second opinion from another model family, a review, or a cheap parallel lookup. Read before spawning a subagent when another model would answer better, and whenever the user says codex, GPT, or "second opinion".
3
+ description: 'Delegate a task to a Codex agent instead of a Claude subagent: second opinion, review, cheap parallel lookup. Read before spawning a subagent when another model fits, or on "codex", "GPT", "second opinion".'
4
4
  kind: skill
5
5
  scope: both
6
6
  ---
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: design-exploration
3
- description: How a visual design exploration runs - the step size, what to put in front of the user at each stop, and when you may commit. Read BEFORE any visual design work on a sketch, a prototype, a theme, a palette, or the look of a component. The user is the designer; you find and frame, and you never pick the fix alone.
3
+ description: 'How a visual design exploration runs: step size, what to show the user at each stop, when you may commit. Read BEFORE any visual design work on a sketch, prototype, theme, palette or component look.'
4
4
  kind: skill
5
5
  scope: both
6
6
  vars: [storybookUrl]
@@ -11,6 +11,9 @@ vars: [storybookUrl]
11
11
  A design exploration is a dialog. **The user is the designer. You find and frame. The user
12
12
  chooses.** A finding is not a licence to pick the fix.
13
13
 
14
+ One exception: where the rules of the project give your role its own picks, build your recommendation, record the
15
+ pick with `--by <model id>` and report it. Do not stop for a choice then.
16
+
14
17
  The unit of work is one open question, with every answer drawn side by side at the same
15
18
  geometry: a **sketch** on a product, or a **call** in a repository with the old setup. A variant wins
16
19
  or loses only against the other variants of its question.
@@ -87,7 +90,7 @@ product. They take no picks and no new variants.
87
90
  - A change to a merged part, also a small one, is a **sketch**; never edit a merged part directly. When
88
91
  nothing is to choose, the sketch has one variant (`--variants a`). Variants are alternatives, never a state
89
92
  of another variant. Two to four variants, each with its cost; run `sketch check` before `sketch ready`.
90
- - **Never run `sketch merge` or `sketch discard`, and never pick a variant.** Studio merges on the user's
93
+ - **Never run `sketch merge` or `sketch discard`, and never pick a variant, unless your role has its own picks.** Studio merges on the user's
91
94
  click. After a pick or discard, do not merge. Run `sketch reject` or `reopen` only when the user did.
92
95
  - Mark a sketch `ready` only when no change to it waits on anything; otherwise `sketch hold`.
93
96
  - Every write command takes `--by <model id>`. **Never guess your id**: use the one your prompt names, or ask
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: figma-export
3
- description: Reconcile a component against a Figma export - which exports to ask the designer for (an .svg frame and its "copy as CSS" dump), how to dump the geometry out of each, which of their numbers are authoritative, and how to measure the real rendered result against them headlessly. Use whenever a design export is dropped next to a component and the component has to be matched to it.
3
+ description: Reconcile a component against a Figma export (.svg frame, "copy as CSS" dump) and measure the render against it. Use whenever a design export is dropped next to a component to be matched.
4
4
  kind: skill
5
5
  scope: both
6
6
  ---