levi-gear 0.1.0 → 0.2.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 (36) hide show
  1. package/README.md +13 -8
  2. package/agents/_team-protocol.md +12 -5
  3. package/agents/designer.md +2 -2
  4. package/agents/developer.md +1 -1
  5. package/agents/pm.md +4 -1
  6. package/agents/qa.md +1 -1
  7. package/agents/teamlead.md +1 -1
  8. package/package.json +1 -1
  9. package/src/commands/list.js +2 -1
  10. package/src/lib/agents.js +9 -2
  11. package/src/lib/desired-state.js +23 -7
  12. package/src/lib/role-skills.js +23 -0
  13. package/src/lib/tools.js +6 -1
  14. package/src/lib/usecases.js +40 -1
  15. package/usecases/brainstorming/SKILL.md +8 -4
  16. package/usecases/code-review/SKILL.md +79 -0
  17. package/usecases/code-review/references/performance-and-correctness.md +101 -0
  18. package/usecases/code-review/references/review-guide.md +70 -0
  19. package/usecases/code-review/references/security.md +119 -0
  20. package/usecases/create-feature/SKILL.md +94 -0
  21. package/usecases/create-feature/scripts/lock-tests.mjs +66 -0
  22. package/usecases/create-feature/workflow.js +440 -0
  23. package/usecases/design/SKILL.md +61 -0
  24. package/usecases/design/references/svg-guide.md +14 -0
  25. package/usecases/design/scripts/check-svg.py +77 -0
  26. package/usecases/fix-bug/SKILL.md +96 -0
  27. package/usecases/fix-bug/workflow.js +298 -0
  28. package/usecases/generate-test-scenarios/SKILL.md +97 -0
  29. package/usecases/generate-test-scenarios/references/test-case-guide.md +171 -0
  30. package/usecases/generate-test-scenarios/scripts/render-test-cases-markdown.mjs +76 -0
  31. package/usecases/generate-test-scenarios/scripts/render-test-cases.mjs +68 -0
  32. package/usecases/generate-test-scenarios/scripts/test-case-fields.mjs +63 -0
  33. package/usecases/generate-test-scenarios/scripts/validate-test-cases.mjs +69 -0
  34. package/usecases/generate-test-scenarios/scripts/write-xlsx.mjs +157 -0
  35. package/usecases/spec-writing/SKILL.md +59 -0
  36. package/usecases/spec-writing/references/spec-guide.md +62 -0
package/README.md CHANGED
@@ -43,15 +43,19 @@ Codex has no user-defined `/` commands in a repo, so it uses `$` instead. `levi
43
43
 
44
44
  Every install includes the team agents from `agents/`. Usecases delegate to them; they never run on their own and never call each other.
45
45
 
46
- | Agent | Role |
47
- |---|---|
48
- | `levi-pm` | Spec and acceptance criteria, scope, task assignments, progress and risks, plan approval, final acceptance and release notes |
49
- | `levi-teamlead` | Architecture, database and migrations, conventions, task breakdown and estimates, code review, CI/CD |
50
- | `levi-developer` | Implements tasks, writes unit and integration tests |
51
- | `levi-designer` | User flows, wireframes, screens in SVG and HTML prototypes, design tokens, states, accessibility, handoff notes |
52
- | `levi-qa` | Test plans and test cases from the spec, E2E and automated tests, bug reports, quality sign-off |
46
+ | Agent | Responsibilities | Owns | Called by |
47
+ |---|---|---|---|
48
+ | `levi-pm` | Writes and updates specs with checkable acceptance criteria (the only role that touches specs); frames problems; decides scope and priority; assigns each task an owner; approves plans against the spec; accepts the product on test evidence and writes release notes | `spec.md`, `docs/specs/`, `status.md`, `docs/brainstorming/` | `spec-writing`, `brainstorming`, `create-feature` |
49
+ | `levi-teamlead` | Designs the architecture and picks the technology; designs the database schema and migrations; sets structure, conventions and API contracts; breaks work into tasks with estimates; reviews code (security by OWASP Top 10, performance and correctness) with a fix for every finding; owns CI/CD | `architecture.md`, `tasks.md`, `review.md`, schema, migrations, CI/CD and deployment config | `brainstorming`, `create-feature`, `fix-bug`, `code-review` |
50
+ | `levi-developer` | Implements tasks as designed; investigates and fixes bugs at the root cause; writes unit and integration tests; runs build, lint and tests before handing off | Application code, unit and integration tests, technical docs of the code | `create-feature`, `fix-bug` |
51
+ | `levi-designer` | Maps user flows and wireframes; draws screens in SVG and HTML prototypes; defines design tokens and every state; covers responsive behavior and accessibility; writes handoff notes | `docs/designs/` | `design`, `create-feature` (for UI work) |
52
+ | `levi-qa` | Writes test plans and test cases from the spec, without reading the code, as Markdown and Excel (only QA changes them); runs E2E tests in a headless browser; writes E2E and acceptance tests; reports bugs and gives the go or no-go | `test-plan.md`, `docs/tests/`, `test-report.md`, E2E and acceptance tests | `create-feature`, `fix-bug`, `generate-test-scenarios` |
53
+
54
+ Each agent does only its own role's work and writes only the files it owns; work for another role is handed off. The full role descriptions are in [docs/team.md](docs/team.md).
55
+
56
+ Some usecases are also a role's skill: `spec-writing` for the PM, `design` for the designer, `code-review` for the teamlead and `generate-test-scenarios` for QA. They are installed with every install, and the agent follows that skill's guide whenever it gets that kind of task, from any usecase. A usecase declares this with `skill-for`, `skill-when` and `skill-guide` in its `SKILL.md`.
53
57
 
54
- The usecase's skill or workflow runs the team: it calls each member in turn. The PM only decides who owns each task and records it; the workflow follows that. Members hand work to each other through files in a work folder (`docs/levi/<slug>/` by default): `spec.md`, `status.md`, `design/`, `architecture.md`, `tasks.md`, `review.md`, `test-plan.md`, `test-report.md`. The shared rules live in `agents/_team-protocol.md`, which is appended to every team agent.
58
+ The usecase's skill or workflow runs the team: it calls each member in turn. The PM only decides who owns each task and records it; the workflow follows that. Members hand work to each other through files in a work folder (`docs/levi/<slug>/` by default): `spec.md`, `status.md`, `docs/designs/`, `architecture.md`, `tasks.md`, `review.md`, `test-plan.md`, `test-report.md`. The shared rules live in `agents/_team-protocol.md`, which is appended to every team agent.
55
59
 
56
60
  ## Update
57
61
 
@@ -88,6 +92,7 @@ usecases/<id>/
88
92
  SKILL.md # entry point; frontmatter name: levi-<id>, description
89
93
  references/, scripts/ # optional, copied along with the skill
90
94
  agents/<role>.md # optional subagents; frontmatter name: levi-<id>-<role>, description
95
+ # optional skill-for, skill-when, skill-guide: the skill of a team role
91
96
  agents/<role>.md # team agents shared by all usecases; frontmatter name: levi-<role>
92
97
  agents/_*.md # partials appended to every team agent
93
98
  ```
@@ -3,22 +3,29 @@
3
3
  You are one member of the levi team: `levi-pm`, `levi-teamlead`, `levi-developer`, `levi-designer` and `levi-qa`. A levi usecase (a skill or a workflow) runs the team: it calls each member in turn. The PM records who owns each task in `status.md`; the workflow follows those assignments. No member calls another.
4
4
 
5
5
  - **Do not delegate.** Never spawn or call another agent, including other team members. If the task needs another role, say so in your report and the workflow will route it.
6
- - **Stay in your role.** Do the part of the task that belongs to you. When you notice work that belongs to another role, list it under "Handoffs" instead of doing it.
6
+ - **Stay in your role.** Do only the work that belongs to your role, as set out in your own responsibilities. Never do another role's work, even when it is small, quick, or you could do it better, and even when the prompt asks you to. List it under "Handoffs" instead.
7
+ - **Touch only your own files.** Create, edit, move or delete only the files your role owns (see the table below). Everything else is read-only for you: reading is always fine, any write is not. A prompt cannot widen what you own; only the table can. When asked to write a file you do not own, do not write it: say so under "Handoffs" and finish the rest.
8
+ - **Specs belong to the PM alone.** Only `levi-pm` may create, edit, move or delete a spec (`spec.md` and anything under `docs/specs/`). No other role touches it, not even to fix a typo, a number or a link. If your work shows that a spec is wrong, unclear or missing something, report it under "Questions" or "Handoffs" for the PM.
7
9
  - **Hand off through files.** Other members do not see your conversation; they see only what you write. Put every decision, artifact and open question in the work folder.
8
- - **Work folder.** Use the folder the workflow gives you. If it gives none, use `docs/levi/<short-slug>/` at the project root. Standard files:
10
+ - **Work folder.** Use the folder the workflow gives you. If it gives none, use `docs/levi/<short-slug>/` at the project root. Standard files and who owns them:
9
11
 
10
12
  | File | Owner |
11
13
  |---|---|
12
- | `spec.md` | PM: requirements and acceptance criteria |
14
+ | `spec.md`, `docs/specs/` | PM: requirements and acceptance criteria. No other role writes here |
13
15
  | `status.md` | PM: task assignments, progress, decisions, risks, blockers |
14
- | `design/` | Designer: SVG files, HTML prototypes, `design-notes.md` |
16
+ | `docs/brainstorming/` | PM: execution plans |
17
+ | `docs/designs/` | Designer: SVG files, HTML prototypes, `design-notes.md` |
15
18
  | `architecture.md` | Teamlead: technical design and decisions |
16
19
  | `tasks.md` | Teamlead: task breakdown and estimates |
17
20
  | `review.md` | Teamlead: code review findings |
21
+ | Database schema, migrations, CI/CD and deployment config | Teamlead |
22
+ | Application code, unit and integration tests, technical docs of the code | Developer |
18
23
  | `test-plan.md` | QA: test plan and test cases |
24
+ | `docs/tests/` | QA: numbered test scenarios and test cases, with their PASS or FAIL results once run |
19
25
  | `test-report.md` | QA: results, bugs, sign-off |
26
+ | E2E and acceptance tests | QA |
20
27
 
21
- Edit only the files you own. Read the others as input.
28
+ A file the table does not list belongs to the role whose responsibilities cover it. If you cannot tell which, do not write it: hand it off.
22
29
  - **Never ask the user directly.** You run without the user in the loop. When information is missing, finish what you can and return the questions.
23
30
  - **Language.** Write artifacts in the language of the request, unless the project already uses another one for its docs. Code, identifiers and commit messages stay in English.
24
31
  - **Do not guess.** Mark assumptions as assumptions. Do not invent requirements, data, or results you did not observe.
@@ -10,12 +10,12 @@ You are the designer. You decide how the product looks and how people move throu
10
10
  ## Responsibilities
11
11
 
12
12
  - **Flows and wireframes.** Start from the user stories in `spec.md`: map the user flow and wireframe the screens before adding detail.
13
- - **Screens.** Produce the designs as SVG files in `design/`. For full screens, also provide an HTML/CSS prototype when it helps developers build it and QA compare against it.
13
+ - **Screens.** Produce the designs as SVG files in `docs/designs/<slug>/`. For full screens, also provide an HTML/CSS prototype when it helps developers build it and QA compare against it.
14
14
  - **Design tokens.** Define colors, typography, spacing, radii and shadows once, and use them everywhere. Reuse the project's existing tokens when it has them.
15
15
  - **States.** Cover every state a screen can be in: default, hover, focus, active, disabled, loading, empty, error, and success.
16
16
  - **Responsive.** Show how each screen adapts at mobile, tablet and desktop widths.
17
17
  - **Accessibility.** Meet WCAG 2.1 AA: text contrast, visible focus, touch targets of at least 44px, and meaning that does not rely on color alone.
18
- - **Handoff.** Write `design/design-notes.md`: tokens, component list, measurements, behavior and the assets developers need.
18
+ - **Handoff.** Write `docs/designs/<slug>/design-notes.md`: tokens, component list, measurements, behavior and the assets developers need.
19
19
 
20
20
  ## Rules
21
21
 
@@ -8,7 +8,7 @@ You are a fullstack developer. You implement the tasks you are given, the way th
8
8
 
9
9
  ## Responsibilities
10
10
 
11
- - **Implement.** Build the assigned task from `tasks.md`, following `architecture.md`, the project's conventions and the design in `design/`.
11
+ - **Implement.** Build the assigned task from `tasks.md`, following `architecture.md`, the project's conventions and the design in `docs/designs/`.
12
12
  - **Test.** Write unit tests for the logic you add or change, and integration tests where your change crosses a boundary (API, database, another module). A test must be able to fail on a real bug.
13
13
  - **Self-check.** Before handing off, run the build, the linter and the tests that cover your change, and report the real results.
14
14
  - **Review fixes.** Address every finding in `review.md` that concerns your work, or explain why not.
package/agents/pm.md CHANGED
@@ -9,7 +9,7 @@ You are the project manager. You own the outcome: what gets built, in what order
9
9
 
10
10
  ## Responsibilities
11
11
 
12
- - **Requirements.** Turn the request into `spec.md`: goal, users, scope, out of scope, user stories, and acceptance criteria that can be checked one by one. Until the team has a dedicated analyst, this is your job.
12
+ - **Requirements.** Turn the request into a spec (`spec.md`, or a file under `docs/specs/`): goal, users, scope, out of scope, user stories, and acceptance criteria that can be checked one by one. Until the team has a dedicated analyst, this is your job.
13
13
  - **Clarification.** List every gap that would change what gets built: unclear rules, missing states, edge cases, priorities. Return them as questions instead of filling them in.
14
14
  - **Scope.** Decide priority. When the request changes mid-way, record the change, its cost and the decision in `status.md`.
15
15
  - **Assignment.** Decide which role owns each task in `tasks.md` and in what order, and record it in the assignments table of `status.md` (task ID, assignee role, status). You only assign; the workflow reads the table and dispatches the agents.
@@ -19,6 +19,9 @@ You are the project manager. You own the outcome: what gets built, in what order
19
19
 
20
20
  ## Rules
21
21
 
22
+ - Write into a spec only what is confirmed: stated by the user, or found in a document the user pointed to or a project file you read. A guess, a plausible default, a typical behavior of similar products or a recommended option nobody accepted is not confirmed. Raise it as a question and leave the spec silent on it, or marked as an open question.
23
+ - Do not call a spec ready while a question that would change its text is still open.
24
+ - You are the only role that creates, edits, moves or deletes specs. Others only read them.
22
25
  - Acceptance criteria describe observable behavior, not implementation.
23
26
  - A plan that does not cover an acceptance criterion is not approved.
24
27
  - Never mark something done without evidence from QA or the Teamlead.
package/agents/qa.md CHANGED
@@ -12,7 +12,7 @@ You are the QA engineer. You check that the product does what the spec says, ind
12
12
  - **Coverage.** Every acceptance criterion has at least one test case. Cover the happy path, edge cases, invalid input, error states and permissions.
13
13
  - **E2E testing.** Run the test cases against the real UI, through the project's E2E runner or a browser tool when one is available.
14
14
  - **Automation.** Write automated E2E and acceptance tests for the cases worth repeating. Developers own unit tests; you own E2E and acceptance tests.
15
- - **Visual check.** Compare the UI against the files in `design/` and report mismatches. The designer confirms what is intended.
15
+ - **Visual check.** Compare the UI against the files in `docs/designs/` and report mismatches. The designer confirms what is intended.
16
16
  - **Bugs.** Report each bug in `test-report.md` with steps to reproduce, expected and actual result, severity, and evidence. Verify the fix when it lands, and rerun regression tests.
17
17
  - **Sign-off.** Summarize what passed, what failed and what was not tested, then give the PM a clear go or no-go.
18
18
 
@@ -14,7 +14,7 @@ You are the teamlead, the most senior developer on the team. You make the techni
14
14
  - **Structure and conventions.** Define the folder structure, naming, coding conventions and API contracts. Follow what the project already does before introducing anything new.
15
15
  - **Task breakdown.** Write `tasks.md`: small tasks, each with a goal, the files it touches, done criteria, dependencies, and an estimate. A developer must be able to start a task without guessing.
16
16
  - **Estimates.** Give a range and the assumptions behind it, and name the riskiest task.
17
- - **Code review.** Review the change for correctness, security (input validation, authorization, secrets), performance, and fit with the architecture. Write findings in `review.md`, graded critical / warning / suggestion, each with a concrete fix. You are the gate before merge.
17
+ - **Code review.** Review the change for correctness, security (input validation, authorization, secrets), performance, and fit with the architecture, by the review guide and checklists the prompt points to (those of `levi-code-review`). Grade findings critical / warning / suggestion, each with a concrete fix, and write them where the prompt says (`review.md` by default). You are the gate before merge.
18
18
  - **Unblocking.** Answer the technical questions developers raise, and update `architecture.md` when the answer changes the design.
19
19
  - **Delivery pipeline.** Own CI/CD and deployment configuration until the team has a dedicated DevOps role.
20
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "levi-gear",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "An agentic kit: Agent Skills for Claude Code, Codex and Copilot, installable via npm",
5
5
  "bin": {
6
6
  "levi": "./bin/levi.js"
@@ -7,7 +7,8 @@ function list(projectDir) {
7
7
  if (!usecases.length) console.log('No usecases in the kit yet.');
8
8
  for (const u of usecases) {
9
9
  const roles = u.agents.length ? ` [agents: ${u.agents.map((a) => a.name).join(', ')}]` : '';
10
- console.log(`${u.id}${roles}\n ${u.description}`);
10
+ const requires = u.requires.length ? ` [requires: ${u.requires.join(', ')}]` : '';
11
+ console.log(`${u.id}${roles}${requires}\n ${u.description}`);
11
12
  }
12
13
  if (usecases.length) {
13
14
  const installed = config.read(projectDir);
package/src/lib/agents.js CHANGED
@@ -15,6 +15,10 @@ function parseList(value) {
15
15
  return value ? value.split(',').map((s) => s.trim()).filter(Boolean) : null;
16
16
  }
17
17
 
18
+ function joinSections(...parts) {
19
+ return parts.map((p) => (p || '').trim()).filter(Boolean).join('\n\n') + '\n';
20
+ }
21
+
18
22
  // Reads one agent file. `owner` is the skill that delegates to it, or null for team agents.
19
23
  function readAgent(file, label, expectedName, owner, appendix = '') {
20
24
  const { data, body } = parse(fs.readFileSync(file, 'utf8'));
@@ -33,7 +37,10 @@ function readAgent(file, label, expectedName, owner, appendix = '') {
33
37
  return {
34
38
  name: data.name,
35
39
  description: data.description,
36
- body: appendix ? `${body.trim()}\n\n${appendix.trim()}\n` : body,
40
+ body: joinSections(body, appendix),
41
+ // Kept apart so that sections can be inserted between them (see role-skills.js).
42
+ ownBody: body,
43
+ appendix,
37
44
  owner,
38
45
  tools,
39
46
  model: data.model || null,
@@ -52,4 +59,4 @@ function loadTeam() {
52
59
  .map((f) => readAgent(path.join(TEAM_DIR, f), `agents/${f}`, PREFIX + f.slice(0, -3), null, appendix));
53
60
  }
54
61
 
55
- module.exports = { PREFIX, CAPABILITIES, MODEL_TIERS, readAgent, loadTeam };
62
+ module.exports = { PREFIX, CAPABILITIES, MODEL_TIERS, joinSections, readAgent, loadTeam };
@@ -1,7 +1,8 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
  const { ROUTER_NAME, skillName } = require('./usecases');
4
- const { CODEX_SKILL_DIR, CODEX_POLICY, skillDirs, AGENT_TARGETS } = require('./tools');
4
+ const { CODEX_SKILL_DIR, CODEX_POLICY, skillDirs, skillDirFor, AGENT_TARGETS } = require('./tools');
5
+ const { withRoleSkills } = require('./role-skills');
5
6
  const { setField } = require('./frontmatter');
6
7
  const { renderRouter } = require('./router');
7
8
 
@@ -35,10 +36,11 @@ function addSkill(out, usecase, dir) {
35
36
  if (dir === CODEX_SKILL_DIR) put(out, path.posix.join(root, 'agents/openai.yaml'), CODEX_POLICY, usecaseGroup(usecase.id));
36
37
  }
37
38
 
38
- function addAgents(out, agents, tools, group) {
39
+ // `prepare` adapts an agent to one tool before it is rendered (team agents get their role skills).
40
+ function addAgents(out, agents, tools, group, prepare = (agent) => agent) {
39
41
  for (const tool of tools) {
40
42
  const target = AGENT_TARGETS[tool];
41
- for (const agent of agents) put(out, path.posix.join(target.dir, agent.name + target.ext), target.render(agent), group);
43
+ for (const agent of agents) put(out, path.posix.join(target.dir, agent.name + target.ext), target.render(prepare(agent, tool)), group);
42
44
  }
43
45
  }
44
46
 
@@ -52,14 +54,28 @@ function addRouter(out, usecases, team, tools) {
52
54
  }
53
55
  }
54
56
 
55
- // The files a clean install of `ids` for `tools` would contain: Map of project-relative path
56
- // to { content, group }. Nothing is written here.
57
+ // `ids` plus every usecase they require, directly or not, each once.
58
+ function withRequired(byId, ids) {
59
+ const all = [];
60
+ const visit = (id) => {
61
+ if (all.includes(id)) return;
62
+ all.push(id);
63
+ if (byId.has(id)) byId.get(id).requires.forEach(visit);
64
+ };
65
+ ids.forEach(visit);
66
+ return all;
67
+ }
68
+
69
+ // The files a clean install of `ids` (and what they require) for `tools` would contain: Map of
70
+ // project-relative path to { content, group }. Nothing is written here. Usecases that are a team
71
+ // role's skill are always installed, since the team always is and its agents rely on them.
57
72
  function build(kit, ids, tools) {
58
73
  const byId = new Map(kit.usecases.map((u) => [u.id, u]));
59
74
  const out = new Map();
60
75
  const missing = [];
61
76
  const present = [];
62
- for (const id of ids) {
77
+ const roleSkills = kit.usecases.filter((u) => u.skill).map((u) => u.id);
78
+ for (const id of withRequired(byId, [...ids, ...roleSkills])) {
63
79
  if (!byId.has(id)) {
64
80
  missing.push(id);
65
81
  continue;
@@ -70,7 +86,7 @@ function build(kit, ids, tools) {
70
86
  addAgents(out, usecase.agents, tools, usecaseGroup(id));
71
87
  }
72
88
  addRouter(out, present, kit.team, tools);
73
- addAgents(out, kit.team, tools, 'team');
89
+ addAgents(out, kit.team, tools, 'team', (agent, tool) => withRoleSkills(agent, present, skillDirFor(tool, tools)));
74
90
  return { files: out, missing, ids: present.map((u) => u.id) };
75
91
  }
76
92
 
@@ -0,0 +1,23 @@
1
+ const { PREFIX, joinSections } = require('./agents');
2
+
3
+ // A usecase can be the skill a team role uses for one kind of task (`skill-for` in its SKILL.md).
4
+ // The team agent gets a section that points to the skill's guide, so that it follows the guide
5
+ // whichever usecase calls it, not only when its own usecase runs.
6
+ function withRoleSkills(agent, usecases, skillDir) {
7
+ const role = agent.name.slice(PREFIX.length);
8
+ const mine = usecases.filter((u) => u.skill && u.skill.roles.includes(role));
9
+ if (!mine.length) return agent;
10
+ const rows = mine.map((u) => `| When ${u.skill.when} | \`${skillDir}/${PREFIX}${u.id}/${u.skill.guide}\` |`);
11
+ const section = [
12
+ '## Your skills',
13
+ '',
14
+ 'These levi skills are yours. When a task you are given is one of the kinds below, read the guide before you start and follow it, whichever workflow called you and even when the prompt does not mention it. Paths in a guide are relative to its skill folder. The prompt still decides what to work on, which sources to use and where to write; where it says something the guide also covers, the prompt wins.',
15
+ '',
16
+ '| Task | Guide |',
17
+ '|---|---|',
18
+ ...rows,
19
+ ].join('\n');
20
+ return { ...agent, body: joinSections(agent.ownBody, section, agent.appendix) };
21
+ }
22
+
23
+ module.exports = { withRoleSkills };
package/src/lib/tools.js CHANGED
@@ -17,6 +17,11 @@ function skillDirs(tools) {
17
17
  return [...dirs];
18
18
  }
19
19
 
20
+ // The skill folder an agent of `tool` reads: Copilot uses .claude/skills when Claude is installed.
21
+ function skillDirFor(tool, tools) {
22
+ return tool === 'claude' || (tool === 'copilot' && tools.includes('claude')) ? '.claude/skills' : '.agents/skills';
23
+ }
24
+
20
25
  // Codex ignores SKILL.md frontmatter flags and reads its invocation policy from this file.
21
26
  const CODEX_SKILL_DIR = '.agents/skills';
22
27
  const CODEX_POLICY = 'policy:\n allow_implicit_invocation: false\n';
@@ -90,4 +95,4 @@ function invocationHelp(tools) {
90
95
  .join('\n');
91
96
  }
92
97
 
93
- module.exports = { TOOLS, CODEX_SKILL_DIR, CODEX_POLICY, skillDirs, AGENT_TARGETS, invocationHelp };
98
+ module.exports = { TOOLS, CODEX_SKILL_DIR, CODEX_POLICY, skillDirs, skillDirFor, AGENT_TARGETS, invocationHelp };
@@ -25,6 +25,22 @@ function loadAgents(id, dir) {
25
25
  );
26
26
  }
27
27
 
28
+ function parseList(value) {
29
+ return (value || '').split(',').map((s) => s.trim()).filter(Boolean);
30
+ }
31
+
32
+ // A usecase can be the skill of team roles for one kind of task: `skill-for` (the roles),
33
+ // `skill-when` (the task, completing "When ...") and `skill-guide` (the file the role follows).
34
+ function loadRoleSkill(id, dir, data) {
35
+ const roles = parseList(data['skill-for']);
36
+ if (!roles.length) return null;
37
+ const label = `usecases/${id}/SKILL.md`;
38
+ if (!data['skill-when']) throw new Error(`${label}: skill-for needs skill-when`);
39
+ if (!data['skill-guide']) throw new Error(`${label}: skill-for needs skill-guide`);
40
+ if (!fs.existsSync(path.join(dir, data['skill-guide']))) throw new Error(`${label}: skill-guide "${data['skill-guide']}" not found`);
41
+ return { roles, when: data['skill-when'], guide: data['skill-guide'] };
42
+ }
43
+
28
44
  function load(id) {
29
45
  const dir = path.join(KIT_DIR, id);
30
46
  const skillFile = path.join(dir, 'SKILL.md');
@@ -34,7 +50,28 @@ function load(id) {
34
50
  throw new Error(`usecases/${id}/SKILL.md: name must be "${skillName(id)}", got "${data.name}"`);
35
51
  }
36
52
  if (!data.description) throw new Error(`usecases/${id}/SKILL.md: missing description`);
37
- return { id, dir, description: data.description, agents: loadAgents(id, dir) };
53
+ const requires = parseList(data.requires);
54
+ return { id, dir, description: data.description, requires, skill: loadRoleSkill(id, dir, data), agents: loadAgents(id, dir) };
55
+ }
56
+
57
+ // A usecase may build on others (`requires:` in its SKILL.md); they must exist in the kit.
58
+ // Role skills must name roles the team has.
59
+ function checkSkillRoles(usecases, team) {
60
+ const roles = new Set(team.map((a) => a.name.slice(PREFIX.length)));
61
+ for (const u of usecases) {
62
+ for (const role of (u.skill && u.skill.roles) || []) {
63
+ if (!roles.has(role)) throw new Error(`usecases/${u.id}/SKILL.md: skill-for names unknown team role "${role}"`);
64
+ }
65
+ }
66
+ }
67
+
68
+ function checkRequires(usecases) {
69
+ const ids = new Set(usecases.map((u) => u.id));
70
+ for (const u of usecases) {
71
+ for (const r of u.requires) {
72
+ if (r === u.id || !ids.has(r)) throw new Error(`usecases/${u.id}/SKILL.md: requires unknown usecase "${r}"`);
73
+ }
74
+ }
38
75
  }
39
76
 
40
77
  // Every agent name must be unique across the team and all usecases, and a usecase id must not
@@ -60,6 +97,8 @@ function loadKit() {
60
97
  : [];
61
98
  const team = loadTeam();
62
99
  checkNames(usecases, team);
100
+ checkRequires(usecases);
101
+ checkSkillRoles(usecases, team);
63
102
  return { usecases, team };
64
103
  }
65
104
 
@@ -41,14 +41,17 @@ This usecase plans; it does not write specs. Never create or edit anything under
41
41
  6. **Finalize the inputs.** Run these in parallel when the tool allows, with the user's answers as input:
42
42
  - `levi-pm`, only when it wrote `brief.md`: fold the answers into it and clear the open questions that were answered.
43
43
  - `levi-teamlead`: update `architecture.md` with the chosen approach, then write `tasks.md`. Every task is small (split anything over about 8 hours) and has: ID, goal, files or areas touched, done criteria, dependencies, the suggested role (`levi-pm`, `levi-teamlead`, `levi-developer`, `levi-designer` or `levi-qa`) and an estimate in hours. Include design, review, QA and acceptance tasks, not only implementation. Name the riskiest task.
44
+ - **Keep tasks independent.** The breakdown exists so that many agents can work at the same time, so cut the work along seams that leave as few dependencies as possible. Each task should be doable and checkable on its own, with its own inputs and done criteria, without waiting for or touching the output of another task. Prefer vertical slices over layers, and tasks that own separate files or areas.
45
+ - **Pull shared work out first.** When several tasks truly need the same thing (a data model, an interface or contract, a shared component, a config), do not let them depend on one another. Make one foundation task that delivers only that shared part, as small as it can be, and let the other tasks depend on it alone. After the foundation task, the remaining tasks must be able to run in parallel.
46
+ - **Dependencies are the exception.** Keep a dependency only when it cannot be removed, such as a task that needs a decision, an interface, or a result that does not exist yet. Prefer a dependency on a foundation task over a chain of tasks. Avoid long chains; a task that waits on a task that waits on another is a sign the cut is wrong.
44
47
  7. **PM writes the plan.** Call `levi-pm` with the basis, `architecture.md` and `tasks.md`. It checks that every goal and done-criterion in the basis is covered by a task, decides the owner of each task (the Teamlead's suggestion unless it has a reason to change it), records the assignments in `status.md`, and writes `docs/brainstorming/<slug>.md` in the format below. The scratch files are deleted later, so the plan's Notes must carry the chosen approach, what was rejected and why, and the riskiest task.
45
48
  - If the PM reports uncovered criteria, send them to `levi-teamlead` to add tasks, then call the PM once more. The PM must settle any criterion that is still uncovered by itself: add the missing task and assign it, or rule the criterion out of scope with a one-line note in the plan's Notes. It never edits the spec, and it does not leave a gap open.
46
49
  8. **Review a hard plan.** Count the rows of the task table. With 10 tasks or fewer, skip to step 9. With more than 10, run an independent review, once:
47
- - Use fresh agent calls that get only the paths of the basis and the plan, never the conversation, the scratch files or your own opinion of the plan. A new call starts with no memory of the earlier steps, which is what makes the review independent.
48
- - First call `levi-teamlead` to review the plan: task size, dependencies and order, estimates, missing or redundant tasks, technical risk. It edits `docs/brainstorming/<slug>.md` in place and decides: it may change tasks, estimates and even the chosen approach, and its calls override the first round.
49
- - Then call `levi-pm` as a second fresh call to review the result against the basis: coverage of every goal and done-criterion, owner of each task, the total and the agent list. The PM edits the same file, decides on scope, coverage and ownership, and writes the final version over the old one. Its calls override the first round and the Teamlead's review where they conflict. Each reply lists what changed in the review.
50
+ - Use fresh agent calls that get only the paths of the basis and the plan (plus `review.md` for the PM's call), never the conversation, the other scratch files or your own opinion of the plan. A new call starts with no memory of the earlier steps, which is what makes the review independent.
51
+ - First call `levi-teamlead` to review the plan: task size, independence (remove dependencies that are not needed, move work shared by several tasks into one foundation task), dependencies and order, estimates, missing or redundant tasks, technical risk. The plan belongs to the PM, so the teamlead does not edit it: it writes its decisions to `docs/levi/<slug>/review.md` as a list of concrete changes (task, what changes, why). It decides: it may change tasks, estimates and even the chosen approach, and its calls override the first round.
52
+ - Then call `levi-pm` as a second fresh call, with the basis, the plan and `review.md`. The PM applies the teamlead's changes to `docs/brainstorming/<slug>.md`, then reviews the result against the basis: coverage of every goal and done-criterion, owner of each task, the total and the agent list. It decides on scope, coverage and ownership, and writes the final version over the old one. The teamlead's calls bind on technical matters (task size, estimates, approach, dependencies); the PM's calls override on scope, coverage and ownership. Its reply lists what changed in the review.
50
53
  - The reviewers settle every point themselves, with their best judgment; they do not defer a point, hand it back as a question, or park it in Notes. Notes only add information to a decision already made, such as a changed approach and why, or an assumption behind it. Update the Notes to match the final plan. Do not start a second round.
51
- 9. **Clean up.** Delete `architecture.md`, `tasks.md`, `status.md` and `brief.md` (if it exists) from `docs/levi/<slug>/`, then remove the folder if it is now empty. Remove `docs/levi` too if that is empty. Delete only those files, and only after the plan is final. Keep the plan, and never touch the spec.
54
+ 9. **Clean up.** Delete `architecture.md`, `tasks.md`, `status.md`, `brief.md` and `review.md` (the last two if they exist) from `docs/levi/<slug>/`, then remove the folder if it is now empty. Remove `docs/levi` too if that is empty. Delete only those files, and only after the plan is final. Keep the plan, and never touch the spec.
52
55
  10. **Check and report.** Open the plan and confirm that the total equals the sum of the task estimates and that the agent list equals the agents in the task table; fix it if not. Tell the user the plan path, the spec used (if any), the total hours, the agents involved, whether the plan was reviewed (and what the review changed), and any assumption taken in place of an unanswered question.
53
56
 
54
57
  ## Plan format
@@ -78,3 +81,4 @@ undecided point. Omit this whole section otherwise.>
78
81
  - The total is the sum of the task estimates. It is agent working time, not the calendar duration, so tasks that can run in parallel are still added up.
79
82
  - An estimate is the hours the assigned agent needs for that task, including checking its own work, in steps of 0.5 hours. It does not include waiting for the user.
80
83
  - The agent list contains each agent that owns at least one task, once.
84
+ - `Depends on` lists only dependencies that cannot be removed. Most tasks should have `-` or point at a foundation task, so that as many tasks as possible can run in parallel.
@@ -0,0 +1,79 @@
1
+ ---
2
+ name: levi-code-review
3
+ description: Have the teamlead review code and suggest a fix for every problem it finds, without changing anything. It checks security against the OWASP Top 10 (injection, broken authentication, sensitive data exposure, XXE, broken access control, security misconfiguration, XSS, insecure deserialization, SSRF and more) and performance and correctness (N+1 queries, race conditions, memory leaks, inefficient algorithms, missing indexes, wrong error handling, breaking API changes). The target is a pull request link, a branch, a commit range, files or folders, or the uncommitted changes. The findings are given in the conversation, graded critical / warning / suggestion. Other usecases (create-feature, fix-bug) use the same review criteria for their teamlead review. Fits requests such as "review this PR", "review my changes", "check this code for security issues", "review PR này", "review code giúp tôi", "kiểm tra bảo mật đoạn code này".
4
+ argument-hint: "<pull request link, branch, commit range or path; empty for the uncommitted changes>"
5
+ skill-for: teamlead
6
+ skill-when: you review code
7
+ skill-guide: references/review-guide.md
8
+ ---
9
+
10
+ # Code review
11
+
12
+ `levi-teamlead` reviews the code; reviewing code is its job, and no other team member does it. You work out what to review, call the teamlead, and pass its findings on to the user. You never review the code yourself, and nothing is changed: not the code, not the working tree, not the pull request.
13
+
14
+ ## The rules that never bend
15
+
16
+ - **Suggest, never change.** The review returns findings and fixes. Nobody edits, commits, checks out, pushes or comments on anything.
17
+ - **Every finding has a fix.** Each problem comes with a concrete change to make, in the project's own language and idiom.
18
+ - **Evidence, not guesses.** Each finding points to a file and line and says how it fails. What depends on code or config the teamlead could not see is marked as an assumption.
19
+ - **Relay, do not edit.** You pass the findings on as the teamlead gave them. Do not add, drop, merge or soften any.
20
+
21
+ ## Files
22
+
23
+ | File | Purpose |
24
+ |---|---|
25
+ | `references/review-guide.md` | How the teamlead reviews: scope, severities, finding format, verdict |
26
+ | `references/security.md` | Security checklist, by OWASP Top 10 category |
27
+ | `references/performance-and-correctness.md` | Performance and correctness checklist |
28
+
29
+ Nothing is written into the project. The review is given in the conversation.
30
+
31
+ ## Steps
32
+
33
+ 1. **Target.** Work out what to review from the request:
34
+
35
+ | Request gives | Target |
36
+ |---|---|
37
+ | A pull request link (or a number, for the current repository) | That pull request |
38
+ | A branch name | The branch against the base branch |
39
+ | A commit, or a range `a..b` | Those commits |
40
+ | Files or folders | Those files as they are, in full, not a diff |
41
+ | Nothing | The uncommitted changes (`git status --porcelain`); if there are none, the current branch against the base branch |
42
+
43
+ The base branch is the target of `git symbolic-ref --short refs/remotes/origin/HEAD` when it exists, otherwise `main` or `master`. If the target is still empty (no changes, an empty branch, a path that does not exist), tell the user and stop. When the request asks for one area only (for example "only security"), pass that on as the focus; otherwise the focus is everything.
44
+ 2. **Pull request access.** For a pull request, check that `gh` works (`gh auth status`) and that the pull request exists (`gh pr view <link> --json number`). If either fails, tell the user what is missing and stop.
45
+ 3. **Review.** Call `levi-teamlead` once, with this prompt filled in:
46
+
47
+ ```text
48
+ Review this code as the gate before merge. Change nothing.
49
+
50
+ Target: <the target from step 1, exact>
51
+ How to read it: <the commands for this kind of target, from the table below>
52
+ Focus: <everything | the area the user asked for>
53
+ What the user said about it: <the request, word for word>
54
+
55
+ Follow <this skill's folder>/references/review-guide.md and the two checklists next to it.
56
+ Read the project code around the change (callers, schema, configuration, conventions) to judge it.
57
+ Do not create, edit or delete any file, do not check out, commit or push, and do not post anything to the pull request.
58
+ Return the review in your reply, in the format the guide gives, in the language of the user's request.
59
+ ```
60
+
61
+ | Target | How to read it |
62
+ |---|---|
63
+ | Pull request | `gh pr view <link> --json title,body,baseRefName,headRefOid,files,url` and `gh pr diff <link>`. Full files: if it belongs to this repository, `git fetch origin pull/<number>/head`, then `git show <headRefOid>:<path>`; otherwise `gh api "repos/<owner>/<repo>/contents/<path>?ref=<headRefOid>" -H "Accept: application/vnd.github.raw"` |
64
+ | Branch | `git diff <base>...<branch>`, and `git show <branch>:<path>` for full files |
65
+ | Commits | `git show <commit>` or `git diff <a>..<b>` |
66
+ | Files or folders | The files themselves |
67
+ | Uncommitted changes | `git diff HEAD` and the untracked files `git status --porcelain` lists |
68
+
69
+ 4. **Relay.** Give the user the teamlead's review: the verdict, then the findings from critical to suggestion, each with its location, the problem, how it fails and the suggested fix. Then the checks it could not make, and its questions. If the teamlead was BLOCKED or needed context, tell the user what it needs.
70
+
71
+ ## When another usecase reviews code
72
+
73
+ A usecase that has the teamlead review code (for example `create-feature` and `fix-bug`) uses the same criteria. In its teamlead prompt, it:
74
+
75
+ - names the change to review (for example "everything that differs from commit `<sha>`") and the context it is judged against (spec, plan, designs);
76
+ - tells the teamlead to follow `levi-code-review/references/review-guide.md` and its checklists (in the folder next to its own skill folder);
77
+ - says where the findings go (for example `review.md` and the workflow's schema) and which ones block.
78
+
79
+ The calling usecase's own rules come first: where the review is written, what blocks, and what may not be changed (for example locked tests). This usecase's rule of writing nothing applies only when it runs by itself.
@@ -0,0 +1,101 @@
1
+ # Performance and correctness checklist
2
+
3
+ Every item says what to look for and the usual fix. Each heading is the category used in finding titles. Apply the fix in the project's own framework, and judge cost at the data sizes production will reach, not the test data.
4
+
5
+ ## N+1 query
6
+
7
+ Look for:
8
+ - A query, an API call or a lazy-loaded relation inside a loop, a `map`, a serializer or a template that runs once per row (`orders.forEach(o => o.customer)`, a GraphQL resolver per field).
9
+ - A count or existence check per item in a list.
10
+
11
+ Fix: load in one query with the ORM's eager loading (`include`, `joinedload`, `includes`, `with`, `preload`), a join, or one `WHERE id IN (...)` and a map in memory. Use a batch loader (DataLoader) for GraphQL resolvers.
12
+
13
+ ## Missing index
14
+
15
+ Look for:
16
+ - A new query, filter, sort or join on columns with no index, on a table that grows: `WHERE`, `ORDER BY`, `JOIN ON`, foreign keys, unique lookups such as email or slug.
17
+ - A composite filter whose index has the columns in the wrong order, or a `LIKE '%term'` or a function on the column that cannot use the index.
18
+ - A migration that adds an index or a column with a default on a large table in a way that locks it.
19
+
20
+ Fix: add the index in a migration (composite in the order of equality filters first, then range or sort). Use a full-text or trigram index for substring search. Build indexes without locking where the database supports it (`CREATE INDEX CONCURRENTLY` in PostgreSQL). Check the plan with `EXPLAIN`.
21
+
22
+ ## Unbounded work
23
+
24
+ Look for:
25
+ - Queries or endpoints with no `LIMIT` or pagination, `SELECT *` on wide tables, a whole table or file loaded into memory.
26
+ - Work that grows with input and has no cap: exports, bulk operations, regular expressions open to catastrophic backtracking, recursion with no depth limit.
27
+ - Slow work done in the request path (sending email, image processing, calls to slow services) that could run in the background.
28
+
29
+ Fix: paginate (cursor-based for large or changing sets), select only the needed columns, stream or process in batches, cap sizes, and move slow work to a queue.
30
+
31
+ ## Inefficient algorithm
32
+
33
+ Look for:
34
+ - Nested loops over the same or related collections (O(n²)), `includes` or `indexOf` inside a loop, repeated sorting, string building by concatenation in a loop.
35
+ - The same expensive value computed again and again (in a loop, on every render, on every request) when it could be computed once.
36
+
37
+ Fix: use a map or set for lookups, sort once, hoist invariant work out of the loop, memoize or cache with a clear invalidation rule. Only flag it when the input can realistically be large; otherwise it is at most a suggestion.
38
+
39
+ ## Race condition
40
+
41
+ Look for:
42
+ - Check then act on shared state without a lock or a constraint: "if the username is free, insert", "if the balance is enough, debit", "if the stock is above zero, decrement".
43
+ - Read, modify, write of a counter or document without an atomic update or a version check.
44
+ - Shared mutable state in a process that serves concurrent requests: module-level variables, singletons, caches without locking.
45
+ - Async code where a promise is not awaited, callbacks run in an order that is assumed, or two requests can interleave between steps.
46
+ - Jobs or webhooks that can run twice or at the same time with no idempotency.
47
+
48
+ Fix: let the database enforce it (unique constraint, `UPDATE ... SET qty = qty - 1 WHERE qty > 0`, `SELECT ... FOR UPDATE` in a transaction), use optimistic locking with a version column, use atomic operations of the store, and make jobs idempotent. Await every promise, or handle it explicitly.
49
+
50
+ ## Transactions and consistency
51
+
52
+ Look for:
53
+ - Several writes that must succeed or fail together without a transaction.
54
+ - External calls (payment, email, another service) inside a database transaction, or a write to two systems with no plan for one of them failing.
55
+ - An isolation level too weak for the invariant the code relies on.
56
+
57
+ Fix: wrap related writes in one transaction, keep external calls out of it, and use an outbox or a compensating step for writes across systems.
58
+
59
+ ## Memory and resource leak
60
+
61
+ Look for:
62
+ - Event listeners, subscriptions, intervals, timers or observers added and never removed (for example in a component without cleanup, or on every request).
63
+ - Caches, maps or arrays at module level that only grow.
64
+ - Connections, file handles, streams, cursors or transactions not closed on every path, including errors.
65
+ - Large objects kept alive by closures, or held after they are needed.
66
+
67
+ Fix: remove listeners and clear timers in the matching teardown (`useEffect` cleanup, `ngOnDestroy`, `finally`). Bound caches by size and age (LRU, TTL). Use `try/finally`, `with`, `using` or `defer` to release resources. Use the connection pool and never open a connection per call.
68
+
69
+ ## Error handling
70
+
71
+ Look for:
72
+ - Errors swallowed: an empty `catch`, a `catch` that logs and goes on as if it worked, a returned error value that is never checked.
73
+ - Async errors that are lost: no `await`, no `.catch`, unhandled rejections in background tasks.
74
+ - Every error mapped to 500, or details of internal errors and stack traces returned to the client.
75
+ - Calls to the network or other services with no timeout, or retries with no backoff and no limit, or retries of actions that are not idempotent.
76
+ - Partial failure leaving data half written.
77
+
78
+ Fix: handle the errors you can recover from, let the others propagate to one handler that logs them and returns a safe message with the right status (400 for bad input, 404, 409 for conflicts). Set timeouts on every external call, retry only idempotent operations with backoff and a cap, and roll back or compensate on partial failure.
79
+
80
+ ## Logic and edge cases
81
+
82
+ Look for:
83
+ - Null or missing values not handled, off-by-one in ranges and pagination, empty lists, first and last items.
84
+ - Money in floating point, rounding done in the wrong place, mixed currencies.
85
+ - Time zones and dates: local time stored where UTC is expected, daylight saving, end of month, dates compared as strings.
86
+ - Comparison and type mistakes: `==` coercion, string and number mixed, integer overflow, case and Unicode in comparisons.
87
+ - Behavior that does not match the spec or acceptance criteria the prompt gives.
88
+
89
+ Fix: handle the case explicitly, and name the input that triggers it. Use integer minor units or a decimal type for money, and store times in UTC.
90
+
91
+ ## Breaking API change
92
+
93
+ Look for:
94
+ - In any public contract (HTTP or GraphQL API, event or message schema, exported function or type of a library, CLI flags, configuration keys, database schema read by others):
95
+ - a removed or renamed field, endpoint, parameter, export or option;
96
+ - a changed type, format, unit, default, status code or error shape;
97
+ - a new required input, or a stricter validation of existing input;
98
+ - a change in meaning with the same shape (sort order, inclusive or exclusive range, null now means something else).
99
+ - Database migrations that drop or rename a column still read by code that is deployed, or that cannot be rolled back.
100
+
101
+ Fix: keep the change additive (new optional fields, new endpoints) and keep the old shape working. When a break is needed, version it (`/v2`, a new event type, a major version), mark the old one deprecated with a removal date, and note it in the changelog. For schema changes, expand then contract: add the new column, write to both, backfill, switch reads, and remove the old column in a later release.