ai-runtime-kit 0.5.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.
- package/LICENSE +21 -0
- package/README.md +307 -0
- package/bin/cli.js +52 -0
- package/package.json +40 -0
- package/runtime/BOOTSTRAP.md +230 -0
- package/runtime/CAPABILITIES.md +166 -0
- package/runtime/INDEX.md +397 -0
- package/runtime/PRIORITIES.md +84 -0
- package/runtime/RUNTIME_HEALTH.md +87 -0
- package/runtime/RUNTIME_MODE.md +109 -0
- package/runtime/RUNTIME_TRANSITIONS.md +141 -0
- package/runtime/RUNTIME_VERSION.md +17 -0
- package/runtime/SAFETY.md +156 -0
- package/runtime/adr/0000-template.md +55 -0
- package/runtime/agents/executor.md +19 -0
- package/runtime/agents/verifier.md +83 -0
- package/runtime/hooks/README.md +163 -0
- package/runtime/hooks/_template/HOOK.md +87 -0
- package/runtime/hooks/pre-executor/runtime-scoped-preflight/HOOK.md +189 -0
- package/runtime/memory/architecture/principles.md +107 -0
- package/runtime/memory/engineering/principles.md +102 -0
- package/runtime/memory/runtime/context-loading.md +107 -0
- package/runtime/plans/_template.md +81 -0
- package/runtime/prds/_template.md +73 -0
- package/runtime/reviews/_template.md +37 -0
- package/runtime/rules/README.md +101 -0
- package/runtime/rules/_template/RULE.md +75 -0
- package/runtime/skills/README.md +96 -0
- package/runtime/skills/_template/SKILL.md +61 -0
- package/runtime/specs/_template/spec.md +50 -0
- package/runtime/specs/_template-bug-fix/spec.md +120 -0
- package/runtime/tasks/TASK_STATUS.md +58 -0
- package/runtime/tasks/_template.md +73 -0
- package/runtime/workflows/branching.md +128 -0
- package/runtime/workflows/bug-fix.md +169 -0
- package/runtime/workflows/feature-development.md +238 -0
- package/src/diff.js +81 -0
- package/src/git.js +38 -0
- package/src/init.js +166 -0
- package/src/prompt.js +17 -0
- package/src/snapshot.js +84 -0
- package/src/templates.js +96 -0
- package/src/upgrade.js +179 -0
- package/src/version.js +42 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Context Loading Strategy
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Define what context AI agents should load for different workflow actions.
|
|
6
|
+
|
|
7
|
+
## Always Load
|
|
8
|
+
|
|
9
|
+
- `.ai/runtime/INDEX.md`
|
|
10
|
+
- `.ai/runtime/memory/engineering/principles.md`
|
|
11
|
+
- `.ai/project/memory/engineering/conventions.md`
|
|
12
|
+
- `.ai/project/memory/core/tech-stack.md`
|
|
13
|
+
- `.ai/project/STATE.md`
|
|
14
|
+
|
|
15
|
+
## Feature Implementation
|
|
16
|
+
|
|
17
|
+
Load:
|
|
18
|
+
|
|
19
|
+
- relevant feature spec
|
|
20
|
+
- relevant plan
|
|
21
|
+
- relevant task
|
|
22
|
+
- related contracts
|
|
23
|
+
- related skills from BOTH `.ai/runtime/skills/**` (kit) and
|
|
24
|
+
`.ai/project/skills/**` (project)
|
|
25
|
+
- related rules from BOTH `.ai/runtime/rules/<language>/*.md`
|
|
26
|
+
(kit) and `.ai/project/rules/<language>/*.md` (project), for
|
|
27
|
+
any language whose files the task touches
|
|
28
|
+
- related hooks from BOTH `.ai/runtime/hooks/<phase>-<agent>/*/HOOK.md`
|
|
29
|
+
(kit) and `.ai/project/hooks/<phase>-<agent>/*/HOOK.md`
|
|
30
|
+
(project), matching the current agent transition and
|
|
31
|
+
`appliesWhen`
|
|
32
|
+
- executor agent
|
|
33
|
+
|
|
34
|
+
Project-side files take precedence on path collision.
|
|
35
|
+
|
|
36
|
+
Avoid loading unrelated specs, plans, or completed tasks.
|
|
37
|
+
|
|
38
|
+
## Review
|
|
39
|
+
|
|
40
|
+
Load:
|
|
41
|
+
|
|
42
|
+
- feature spec
|
|
43
|
+
- plan if available
|
|
44
|
+
- related contracts
|
|
45
|
+
- git diff
|
|
46
|
+
- verification result
|
|
47
|
+
- reviewer agent
|
|
48
|
+
- `pre-reviewer/*` and `post-reviewer/*` hooks from BOTH
|
|
49
|
+
`.ai/runtime/hooks/` (kit) and `.ai/project/hooks/` (project)
|
|
50
|
+
matching the spec's `appliesWhen`
|
|
51
|
+
|
|
52
|
+
## Verification
|
|
53
|
+
|
|
54
|
+
Load:
|
|
55
|
+
|
|
56
|
+
- verifier agent
|
|
57
|
+
- related contracts
|
|
58
|
+
- verification command result
|
|
59
|
+
- changed files summary
|
|
60
|
+
|
|
61
|
+
## Task Discovery
|
|
62
|
+
|
|
63
|
+
Load:
|
|
64
|
+
|
|
65
|
+
- `.ai/runtime/INDEX.md`
|
|
66
|
+
- `.ai/project/tasks/TASK_STATUS.md`
|
|
67
|
+
- task files only when needed
|
|
68
|
+
- related plans/specs only for candidate TODO tasks
|
|
69
|
+
|
|
70
|
+
## Rules
|
|
71
|
+
|
|
72
|
+
- Prefer narrow context over broad context.
|
|
73
|
+
- Do not load all `.ai/**` unless doing repository-wide workflow audit.
|
|
74
|
+
- Load contracts before modifying public APIs.
|
|
75
|
+
- Load ADRs before reversing architecture decisions.
|
|
76
|
+
|
|
77
|
+
## Memory Layer Loading
|
|
78
|
+
|
|
79
|
+
### Feature Development
|
|
80
|
+
|
|
81
|
+
Load:
|
|
82
|
+
|
|
83
|
+
- core/
|
|
84
|
+
- engineering/
|
|
85
|
+
- product/
|
|
86
|
+
|
|
87
|
+
### Refactor Work
|
|
88
|
+
|
|
89
|
+
Load:
|
|
90
|
+
|
|
91
|
+
- architecture/
|
|
92
|
+
- engineering/
|
|
93
|
+
- runtime/
|
|
94
|
+
|
|
95
|
+
### Governance Work
|
|
96
|
+
|
|
97
|
+
Load:
|
|
98
|
+
|
|
99
|
+
- governance/
|
|
100
|
+
- runtime/
|
|
101
|
+
|
|
102
|
+
### Runtime Maintenance
|
|
103
|
+
|
|
104
|
+
Load:
|
|
105
|
+
|
|
106
|
+
- runtime/
|
|
107
|
+
- governance/
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Plan: <FEATURE_NAME>
|
|
2
|
+
|
|
3
|
+
## Goal
|
|
4
|
+
|
|
5
|
+
Describe the overall engineering goal.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Related Spec
|
|
10
|
+
|
|
11
|
+
-
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Related ADRs
|
|
16
|
+
|
|
17
|
+
-
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Supersedes
|
|
22
|
+
|
|
23
|
+
<!-- Optional. Only include if this plan replaces an earlier
|
|
24
|
+
plan (e.g. after scope expansion or SUPERSEDED status on
|
|
25
|
+
the prior). Otherwise delete this section entirely. -->
|
|
26
|
+
|
|
27
|
+
-
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Strategy
|
|
32
|
+
|
|
33
|
+
Describe the implementation strategy.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Task Graph
|
|
38
|
+
|
|
39
|
+
### Task 1
|
|
40
|
+
|
|
41
|
+
- Goal:
|
|
42
|
+
- Dependencies:
|
|
43
|
+
- Risk:
|
|
44
|
+
|
|
45
|
+
### Task 2
|
|
46
|
+
|
|
47
|
+
- Goal:
|
|
48
|
+
- Dependencies:
|
|
49
|
+
- Risk:
|
|
50
|
+
|
|
51
|
+
### Task 3
|
|
52
|
+
|
|
53
|
+
- Goal:
|
|
54
|
+
- Dependencies:
|
|
55
|
+
- Risk:
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Execution Order
|
|
60
|
+
|
|
61
|
+
1.
|
|
62
|
+
2.
|
|
63
|
+
3.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Verification Strategy
|
|
68
|
+
|
|
69
|
+
-
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Rollback Strategy
|
|
74
|
+
|
|
75
|
+
-
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Status
|
|
80
|
+
|
|
81
|
+
PLANNED | IN_PROGRESS | DONE
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# PRD: <Feature Name>
|
|
2
|
+
|
|
3
|
+
## Status
|
|
4
|
+
|
|
5
|
+
DRAFT
|
|
6
|
+
<!-- Allowed: DRAFT | APPROVED | REJECTED | SUPERSEDED.
|
|
7
|
+
PRDs follow the same lifecycle as specs but answer
|
|
8
|
+
"what & why," not "how." Engineering details (architecture,
|
|
9
|
+
data flow, code contracts) belong in the downstream spec. -->
|
|
10
|
+
|
|
11
|
+
## Problem
|
|
12
|
+
|
|
13
|
+
<!-- One paragraph. What user-facing or business problem is
|
|
14
|
+
being solved? What evidence makes this problem real
|
|
15
|
+
(data, support tickets, user quotes, missed opportunities)? -->
|
|
16
|
+
|
|
17
|
+
## Target Users
|
|
18
|
+
|
|
19
|
+
<!-- Who feels this problem, how often, in what context?
|
|
20
|
+
Be specific — "developers" is too broad; "first-time kit
|
|
21
|
+
consumers running `init` in an unfamiliar repo" is useful. -->
|
|
22
|
+
|
|
23
|
+
-
|
|
24
|
+
|
|
25
|
+
## Success Metrics
|
|
26
|
+
|
|
27
|
+
<!-- Observable signals that the PRD has been satisfied
|
|
28
|
+
POST-SHIP. Not "the code compiles" — actual product-level
|
|
29
|
+
outcomes. Quantitative when possible; qualitative when not.
|
|
30
|
+
Examples: "time-to-first-spec drops from 2h to 15min",
|
|
31
|
+
"60% of v0.5 consumers run `npm publish` within 7 days of
|
|
32
|
+
adopting," "operator no longer hand-edits CLAUDE.md after
|
|
33
|
+
init." -->
|
|
34
|
+
|
|
35
|
+
-
|
|
36
|
+
|
|
37
|
+
## User Stories
|
|
38
|
+
|
|
39
|
+
<!-- At least two. Format: "As a <role>, I want <capability>,
|
|
40
|
+
so that <outcome>." Stories drive the spec's Requirements
|
|
41
|
+
downstream — write them tight enough to test against. -->
|
|
42
|
+
|
|
43
|
+
- As a , I want , so that .
|
|
44
|
+
- As a , I want , so that .
|
|
45
|
+
|
|
46
|
+
## Out of Scope
|
|
47
|
+
|
|
48
|
+
<!-- Explicit non-goals. What this PRD will NOT cover, and why.
|
|
49
|
+
Items here often become future PRDs. -->
|
|
50
|
+
|
|
51
|
+
-
|
|
52
|
+
|
|
53
|
+
## Open Questions
|
|
54
|
+
|
|
55
|
+
<!-- Decisions blocking sign-off. Each entry should name the
|
|
56
|
+
decider and the deadline (or "TBD"). Move resolved entries
|
|
57
|
+
into Stakeholders or strike them. -->
|
|
58
|
+
|
|
59
|
+
-
|
|
60
|
+
|
|
61
|
+
## Stakeholders
|
|
62
|
+
|
|
63
|
+
- **Owner**:
|
|
64
|
+
- **Reviewer(s)**:
|
|
65
|
+
- **Consumer(s) of the output**:
|
|
66
|
+
|
|
67
|
+
## Downstream Spec
|
|
68
|
+
|
|
69
|
+
<!-- Once a spec is written against this PRD, reference it here
|
|
70
|
+
by path. The spec should reciprocally cite this PRD in §1
|
|
71
|
+
Goal. -->
|
|
72
|
+
|
|
73
|
+
`.ai/project/specs/YYYY-MM-DD-<slug>/spec.md` (pending)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Review: <Feature Name>
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## Verification
|
|
8
|
+
|
|
9
|
+
<!-- What was verified? Typical contents:
|
|
10
|
+
- `npm run verify` result
|
|
11
|
+
- gate scripts from the spec's §5 (Acceptance Criteria)
|
|
12
|
+
- runtime-scoped preflight hook PASS/FAIL notes if §2 Scope
|
|
13
|
+
touched .ai/runtime/**
|
|
14
|
+
-->
|
|
15
|
+
|
|
16
|
+
## Acceptance Criteria
|
|
17
|
+
|
|
18
|
+
<!-- Restate the spec's §5 Acceptance Criteria as a checklist
|
|
19
|
+
and mark each item with [x] (pass) or [ ] (fail). -->
|
|
20
|
+
|
|
21
|
+
- [ ]
|
|
22
|
+
|
|
23
|
+
## Blocking Issues
|
|
24
|
+
|
|
25
|
+
None.
|
|
26
|
+
|
|
27
|
+
## Non-blocking Issues
|
|
28
|
+
|
|
29
|
+
None.
|
|
30
|
+
|
|
31
|
+
## Suggested Fixes
|
|
32
|
+
|
|
33
|
+
None.
|
|
34
|
+
|
|
35
|
+
## Verdict
|
|
36
|
+
|
|
37
|
+
Approved.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Runtime Rules
|
|
2
|
+
|
|
3
|
+
This directory hosts language- and scope-scoped rules. Each rule is
|
|
4
|
+
a single `RULE.md` describing one always-on convention an agent
|
|
5
|
+
should follow when touching code in scope.
|
|
6
|
+
|
|
7
|
+
## Rules vs Skills
|
|
8
|
+
|
|
9
|
+
| | Skill | Rule |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| Trigger | Task type (Express endpoint, Drizzle migration) | Language / file scope (`.ts`, `.sql`) |
|
|
12
|
+
| Loaded when | The current task matches the skill's purpose | The current task touches a file in scope |
|
|
13
|
+
| Example | "How to add an Express endpoint" | "Use `interface` for exported object types" |
|
|
14
|
+
|
|
15
|
+
If a guideline is task-conditional, it belongs in `skills/`. If it
|
|
16
|
+
applies to all code in a language, it belongs in `rules/`.
|
|
17
|
+
|
|
18
|
+
## Directory layout
|
|
19
|
+
|
|
20
|
+
```txt
|
|
21
|
+
.ai/runtime/rules/
|
|
22
|
+
├── _template/
|
|
23
|
+
│ └── RULE.md # template — copy from here
|
|
24
|
+
├── <language>/ # e.g. typescript, sql, python
|
|
25
|
+
│ ├── README.md # index of rules for this language
|
|
26
|
+
│ └── <topic>.md # one rule per file
|
|
27
|
+
└── <scope>/ # non-language scopes (e.g. http-api)
|
|
28
|
+
└── <topic>.md
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Naming:
|
|
32
|
+
|
|
33
|
+
- `<language>` and `<scope>` use lowercase kebab-case.
|
|
34
|
+
- `<topic>` is a short noun phrase (`types.md`, `exports.md`,
|
|
35
|
+
`error-handling.md`).
|
|
36
|
+
- One rule per file. If a topic has multiple sub-rules, split into
|
|
37
|
+
multiple files; do not stuff a single file.
|
|
38
|
+
|
|
39
|
+
## When to create a rule
|
|
40
|
+
|
|
41
|
+
A new rule is worth authoring when:
|
|
42
|
+
|
|
43
|
+
- a review repeatedly catches the same violation across 2+ PRs, OR
|
|
44
|
+
- a new language / framework is adopted and its idioms need
|
|
45
|
+
capturing, OR
|
|
46
|
+
- a Biome rule does not encode a convention the project wants
|
|
47
|
+
enforced (semantic vs syntactic).
|
|
48
|
+
|
|
49
|
+
Do NOT create a rule for:
|
|
50
|
+
|
|
51
|
+
- something Biome already enforces (cite the Biome rule in the
|
|
52
|
+
config instead — keep the source of truth in `biome.json`),
|
|
53
|
+
- a project-specific convention tied to this codebase only (those
|
|
54
|
+
belong in `.ai/project/memory/engineering/conventions.md`),
|
|
55
|
+
- a one-off architectural preference (those belong in
|
|
56
|
+
`.ai/runtime/memory/architecture/principles.md` or in an ADR).
|
|
57
|
+
|
|
58
|
+
## How rules get loaded
|
|
59
|
+
|
|
60
|
+
Two loading paths, mirroring the skills system:
|
|
61
|
+
|
|
62
|
+
1. **Workflow file** — `.ai/runtime/workflows/feature-development.md`
|
|
63
|
+
tells executors to load language rules matching modified files.
|
|
64
|
+
Strongest.
|
|
65
|
+
2. **Context-loading rule** —
|
|
66
|
+
`.ai/runtime/memory/runtime/context-loading.md` lists language
|
|
67
|
+
rules under Feature Implementation. Weakest.
|
|
68
|
+
|
|
69
|
+
A spec whose work touches code in a rule's scope should let the
|
|
70
|
+
executor agent discover the rule automatically via path 1 or 2. No
|
|
71
|
+
explicit reference required in §2 Scope unless the spec ALSO
|
|
72
|
+
authors or modifies the rule itself.
|
|
73
|
+
|
|
74
|
+
## Severity convention
|
|
75
|
+
|
|
76
|
+
- **MUST** — violation blocks merge. Reviewer rejects.
|
|
77
|
+
- **SHOULD** — strong default. Requires explicit justification in
|
|
78
|
+
the PR description / review file to deviate.
|
|
79
|
+
- **MAY** — preference. Apply when convenient; document in the
|
|
80
|
+
review file when applied.
|
|
81
|
+
|
|
82
|
+
## Authoring a new rule — the workflow
|
|
83
|
+
|
|
84
|
+
1. **Open a spec** under `.ai/project/specs/YYYY-MM-DD-<name>/` whose
|
|
85
|
+
§2 Scope lists the new rule's path. Runtime-scoped governance
|
|
86
|
+
per `SAFETY.md` § Runtime Tree Protection.
|
|
87
|
+
2. **Copy the template**: `cp .ai/runtime/rules/_template/RULE.md
|
|
88
|
+
.ai/runtime/rules/<language>/<topic>.md`. Create parent dirs.
|
|
89
|
+
3. **Fill in template** sections. Cite a concrete "why" with at
|
|
90
|
+
least one incident or anti-pattern.
|
|
91
|
+
4. **Register** by adding a line to `INDEX.md`'s `## Rules`
|
|
92
|
+
section listing the new rule + its severity.
|
|
93
|
+
5. **Verify**: `npm run verify`.
|
|
94
|
+
6. **Review**: standard review file under
|
|
95
|
+
`.ai/project/reviews/`.
|
|
96
|
+
|
|
97
|
+
## Modifying an existing rule
|
|
98
|
+
|
|
99
|
+
Same as authoring. If severity changes (e.g. SHOULD → MUST), the
|
|
100
|
+
spec must list which existing code if any needs to be brought into
|
|
101
|
+
compliance and budget for that work.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# <Rule Name>
|
|
2
|
+
|
|
3
|
+
## Severity
|
|
4
|
+
|
|
5
|
+
MUST | SHOULD | MAY
|
|
6
|
+
<!-- MUST = lint-level violation; review must reject.
|
|
7
|
+
SHOULD = strong default; require justification to deviate.
|
|
8
|
+
MAY = preference; document when applied. -->
|
|
9
|
+
|
|
10
|
+
## When this rule applies
|
|
11
|
+
|
|
12
|
+
- Language: `<language>` (e.g. TypeScript, SQL, Python).
|
|
13
|
+
- File scope: `<glob>` (e.g. `src/**/*.ts`, `**/*.sql`).
|
|
14
|
+
- Trigger: any time a task modifies a file matching the scope.
|
|
15
|
+
|
|
16
|
+
Unlike skills, rules are NOT task-conditional — if a task touches a
|
|
17
|
+
file in scope, the rule applies.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Rule
|
|
22
|
+
|
|
23
|
+
State the rule in one sentence. Imperative form.
|
|
24
|
+
|
|
25
|
+
Example: "Use `interface` for object types that are part of a
|
|
26
|
+
module's exported surface; use `type` for unions, intersections, or
|
|
27
|
+
type-level computation."
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Why
|
|
32
|
+
|
|
33
|
+
Why this rule exists. Cite a concrete failure mode or prior incident
|
|
34
|
+
where ignoring the rule would have caused a problem. Without a
|
|
35
|
+
documented "why", the rule has no defense when a future contributor
|
|
36
|
+
challenges it.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Examples
|
|
41
|
+
|
|
42
|
+
### Compliant
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
// example of code that follows the rule
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Violating
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
// example of code that violates the rule
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
State briefly what's wrong with the violating example.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Detection
|
|
59
|
+
|
|
60
|
+
How a reviewer (human or agent) catches a violation:
|
|
61
|
+
|
|
62
|
+
- Biome rule: `<rule-name>` (if applicable)
|
|
63
|
+
- grep / AST pattern (if no lint encoding exists)
|
|
64
|
+
- Manual: "reviewer reads diff and flags"
|
|
65
|
+
|
|
66
|
+
If the rule is fully mechanically enforced by Biome, note that and
|
|
67
|
+
keep this file as the human-readable rationale.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Exceptions
|
|
72
|
+
|
|
73
|
+
(Optional.) Situations where the rule should not apply, with
|
|
74
|
+
justification. Each exception must be reproducible — vague "edge
|
|
75
|
+
cases may exist" is not an exception.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Runtime Skills
|
|
2
|
+
|
|
3
|
+
This directory hosts reusable implementation skills. Each skill is a
|
|
4
|
+
single `SKILL.md` documenting the rules an agent should follow when
|
|
5
|
+
implementing a specific kind of work.
|
|
6
|
+
|
|
7
|
+
## Directory layout
|
|
8
|
+
|
|
9
|
+
```txt
|
|
10
|
+
.ai/runtime/skills/
|
|
11
|
+
├── _template/
|
|
12
|
+
│ └── SKILL.md # template — copy from here
|
|
13
|
+
├── <stack>/ # tech-stack-scoped
|
|
14
|
+
│ └── <skill-name>/
|
|
15
|
+
│ └── SKILL.md
|
|
16
|
+
└── <domain>/ # domain-scoped (when stack-agnostic)
|
|
17
|
+
└── <skill-name>/
|
|
18
|
+
└── SKILL.md
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Naming:
|
|
22
|
+
|
|
23
|
+
- `<stack>` examples: `node-express`, `python-fastapi`, `react`,
|
|
24
|
+
`drizzle`. Use lowercase kebab-case.
|
|
25
|
+
- `<domain>` examples: `security`, `migrations`, `observability`.
|
|
26
|
+
- `<skill-name>` is a short noun phrase, lowercase kebab-case
|
|
27
|
+
(`express-endpoint`, `auth-token-rotation`).
|
|
28
|
+
|
|
29
|
+
## When to create a skill
|
|
30
|
+
|
|
31
|
+
A new skill is worth authoring when ANY of:
|
|
32
|
+
|
|
33
|
+
- the same pattern has appeared in 3+ specs and would benefit from
|
|
34
|
+
consolidation,
|
|
35
|
+
- a new tech stack is being adopted and its conventions differ from
|
|
36
|
+
existing skills,
|
|
37
|
+
- a single complex pattern (e.g. atomic refresh-token rotation) is
|
|
38
|
+
spec-relevant across multiple specs.
|
|
39
|
+
|
|
40
|
+
Do NOT create a skill for:
|
|
41
|
+
|
|
42
|
+
- a one-off implementation detail,
|
|
43
|
+
- a project-specific convention (those belong in
|
|
44
|
+
`.ai/project/memory/`),
|
|
45
|
+
- a pure documentation pointer (a link in `INDEX.md` is enough).
|
|
46
|
+
|
|
47
|
+
## How skills get loaded
|
|
48
|
+
|
|
49
|
+
There are three loading paths, in decreasing order of strength:
|
|
50
|
+
|
|
51
|
+
1. **Workflow file** — `.ai/runtime/workflows/feature-development.md`
|
|
52
|
+
tells executors to load "relevant skills". Strongest: the executor
|
|
53
|
+
agent decides which skill is relevant.
|
|
54
|
+
2. **Context-loading rule** — `.ai/runtime/memory/runtime/context-loading.md`
|
|
55
|
+
lists "related skills" under "Feature Implementation". Weaker:
|
|
56
|
+
relies on the agent reading the rule and recognizing the match.
|
|
57
|
+
3. **Frontmatter signals (declarative)** — the skill's YAML
|
|
58
|
+
frontmatter (`priority` / `pathPatterns` / `bashPatterns` /
|
|
59
|
+
`promptSignals`) is read by the agent during context-loading.
|
|
60
|
+
No runtime tooling reads or enforces it; it exists to help the
|
|
61
|
+
agent judge relevance. Weakest of the three paths.
|
|
62
|
+
|
|
63
|
+
A spec whose work falls under an existing skill should reference the
|
|
64
|
+
skill in its §2 Scope, so reviewers can confirm the executor loaded
|
|
65
|
+
the right rules.
|
|
66
|
+
|
|
67
|
+
## Authoring a new skill — the workflow
|
|
68
|
+
|
|
69
|
+
1. **Open a spec** under `.ai/project/specs/YYYY-MM-DD-<name>/` whose
|
|
70
|
+
§2 Scope lists the new skill's path (this is a runtime-scoped
|
|
71
|
+
governance change per `SAFETY.md` § Runtime Tree Protection).
|
|
72
|
+
2. **Copy the template**: `cp .ai/runtime/skills/_template/SKILL.md
|
|
73
|
+
.ai/runtime/skills/<stack>/<skill-name>/SKILL.md`. Make the
|
|
74
|
+
target directories first.
|
|
75
|
+
3. **Fill in the frontmatter and the body sections.** Remove any
|
|
76
|
+
optional body sections that don't apply. Pick a `priority`
|
|
77
|
+
proportional to how stack-specific the trigger is. Frontmatter
|
|
78
|
+
fields are declarative (see "How skills get loaded" path 3) —
|
|
79
|
+
they describe when the skill applies; they do not auto-load
|
|
80
|
+
anything.
|
|
81
|
+
4. **Register the skill** by adding a bullet to `INDEX.md`'s
|
|
82
|
+
`## Skills` section.
|
|
83
|
+
5. **Add tests if applicable** — if the skill makes assertions that
|
|
84
|
+
can be checked statically (e.g. "all routes return JSON"),
|
|
85
|
+
consider adding a check script under `scripts/`.
|
|
86
|
+
6. **Verify**: `npm run verify` plus any skill-specific assertions.
|
|
87
|
+
7. **Review**: standard review file at
|
|
88
|
+
`.ai/project/reviews/YYYY-MM-DD-<name>-review.md`.
|
|
89
|
+
|
|
90
|
+
## Modifying an existing skill
|
|
91
|
+
|
|
92
|
+
Same as authoring: a runtime-scoped spec, with §2 Scope listing the
|
|
93
|
+
modified SKILL.md path. If the modification changes how the skill is
|
|
94
|
+
applied to existing code (not just clarifying language), include in
|
|
95
|
+
the spec a note about whether existing code following the old skill
|
|
96
|
+
needs updating.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Skill template. Copy this file to
|
|
3
|
+
`.ai/runtime/skills/<stack-or-domain>/<skill-name>/SKILL.md` and
|
|
4
|
+
fill it in.
|
|
5
|
+
|
|
6
|
+
The YAML frontmatter below is DECLARATIVE: no runtime tool reads or
|
|
7
|
+
enforces it. Agents read it during context-loading to judge whether
|
|
8
|
+
this skill applies. See `.ai/runtime/skills/README.md` § "How
|
|
9
|
+
skills get loaded" for the three loading paths.
|
|
10
|
+
-->
|
|
11
|
+
---
|
|
12
|
+
name: <skill-name-kebab-case>
|
|
13
|
+
description: <one sentence: when this skill applies and what it produces>
|
|
14
|
+
metadata:
|
|
15
|
+
priority: <1-10, higher = stronger trigger>
|
|
16
|
+
pathPatterns:
|
|
17
|
+
- "<glob: e.g. src/**/*.ts>"
|
|
18
|
+
bashPatterns:
|
|
19
|
+
- "<regex: e.g. \\bnpm\\s+run\\s+build\\b>"
|
|
20
|
+
promptSignals:
|
|
21
|
+
phrases:
|
|
22
|
+
- "<exact phrase the user is likely to say>"
|
|
23
|
+
anyOf:
|
|
24
|
+
- "<keyword>"
|
|
25
|
+
minScore: <integer, e.g. 6>
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
# <Skill Name>
|
|
29
|
+
|
|
30
|
+
<One paragraph describing what the agent should do when this skill is loaded.>
|
|
31
|
+
|
|
32
|
+
## 目标
|
|
33
|
+
|
|
34
|
+
- <deliverable 1>
|
|
35
|
+
- <deliverable 2>
|
|
36
|
+
|
|
37
|
+
## 输入 / 输出
|
|
38
|
+
|
|
39
|
+
- **输入**:<source materials — files, user description, contracts>
|
|
40
|
+
- **输出**:<destination — file path convention or report shape>
|
|
41
|
+
|
|
42
|
+
## 工作方式
|
|
43
|
+
|
|
44
|
+
1. <step 1>
|
|
45
|
+
2. <step 2>
|
|
46
|
+
3. <step 3>
|
|
47
|
+
|
|
48
|
+
## 推荐输出结构
|
|
49
|
+
|
|
50
|
+
```md
|
|
51
|
+
<scaffold for the produced artifact>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## 约束
|
|
55
|
+
|
|
56
|
+
- <constraint 1>
|
|
57
|
+
- <constraint 2>
|
|
58
|
+
|
|
59
|
+
## 完成标准
|
|
60
|
+
|
|
61
|
+
<what "done" looks like — checkable criteria>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Feature Spec: <Feature Name>
|
|
2
|
+
|
|
3
|
+
## Status
|
|
4
|
+
|
|
5
|
+
DRAFT
|
|
6
|
+
<!-- Allowed: DRAFT | APPROVED | REJECTED | SUPERSEDED.
|
|
7
|
+
See .ai/runtime/workflows/feature-development.md for lifecycle rules. -->
|
|
8
|
+
|
|
9
|
+
## Goal
|
|
10
|
+
|
|
11
|
+
Describe the user or engineering outcome.
|
|
12
|
+
|
|
13
|
+
## Scope
|
|
14
|
+
|
|
15
|
+
<!-- If any in-scope path is under .ai/runtime/**, this is a
|
|
16
|
+
runtime-scoped governance change. Flag it explicitly in
|
|
17
|
+
"Includes:" and follow .ai/runtime/SAFETY.md § Runtime Tree
|
|
18
|
+
Protection. -->
|
|
19
|
+
|
|
20
|
+
Includes:
|
|
21
|
+
|
|
22
|
+
-
|
|
23
|
+
|
|
24
|
+
Excludes:
|
|
25
|
+
|
|
26
|
+
-
|
|
27
|
+
|
|
28
|
+
## Requirements
|
|
29
|
+
|
|
30
|
+
-
|
|
31
|
+
|
|
32
|
+
## Acceptance Criteria
|
|
33
|
+
|
|
34
|
+
-
|
|
35
|
+
|
|
36
|
+
## Test Checklist
|
|
37
|
+
|
|
38
|
+
-
|
|
39
|
+
|
|
40
|
+
## Verification Commands
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm run verify
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Rollback Plan
|
|
47
|
+
|
|
48
|
+
1.
|
|
49
|
+
2.
|
|
50
|
+
3.
|