Skip to content

Commit 708eefa

Browse files
blafourcadeclaude
andauthored
feat(aidd-context): assess existing rules before writing (#1006)
* feat(aidd-context): assess existing rules before writing Compare complete candidate policies and applicable project guidance before publication. Require an explicit resolution and preserve the approved body through the existing writer. Refs #791 * fix(aidd-context): include applicable claude project guidance Include local Claude policies and conditionally loaded AGENTS sources in the discovery contract. Record a Claude-only conflict assessment that leaves every project byte unchanged. Refs #791 * docs(aidd-context): record rule assessment review and evidence Record independent review and outcome challenge, mark the plan reviewed, and preserve reproducible native receipts and fixture teardown evidence. Refs #791 * docs(aidd-context): remove rule contract timestamp * docs(aidd-context): record concise skill verification * refactor(aidd-context): keep rule generation minimal Keep delivery evidence local; retain plugin-source writing separately from host publication. * refactor(aidd-context): remove duplicate publication guidance * refactor(aidd-context): simplify rule assessment actions * refactor(aidd-context): fold rule assessment into capture * fix(aidd-context): preserve rule capture contracts Keep category and workflow semantics lost during compression. Make assessed approval, explicit artifact language and host applicability unambiguous. Refs #791 * refactor(aidd-context): clarify rule generation handoffs Keep routing in the skill and detailed contracts in existing references. Give each action an explicit input and output without repeating the frame or assessment fields in its process. Refs #791 * fix(aidd-context): restore host selection discovery Preserve installed-tool discovery when destinations are unspecified. Shared AGENTS guidance alone cannot identify an installed host. Refs #791 * fix(aidd-context): clarify capture decision order Await missing destination confirmation before assessing candidates. Give unresolved applicability priority over conflict resolution so unknown Copilot interfaces cannot justify changing imported policies. Scope that uncertainty to existing-policy comparisons rather than requiring activation proof for future publications. Refs #791 * docs(aidd-context): name rule generation action files Resolve installed action filenames without guessing numeric prefixes. Refs #791 * docs(aidd-context): trim rule generation references Keep agent decisions and usable publication contracts concise while leaving mechanical diagnostics with the existing writer. Refs #791 * docs(aidd-context): restore concrete rule generation actions Keep the workflow in actions and reusable contracts in references so the agent can follow the process without chasing procedural redirects. Refs #791 * docs(aidd-context): clarify review before resolution Put clarification and reassessment before policy-change choices when comparison evidence is missing; keep label definitions in the reference. Refs #791 * docs(aidd-context): shorten rule actions and split responsibilities Keep the action flow readable while loading assessment, discovery and publication contracts only when needed. Preserve approval and host-format safeguards. Refs #791 * docs(aidd-context): align rule generation with the lean skill style Give each action a one-line purpose and bold-led imperative steps, keep the approval gate in the router, and phrase rules positively. References stay self-contained. Refs #791 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * feat(aidd-context): plan and verify rule publication in the writer Add --plan (dry run listing exact paths, same refusals) and --check --publish (drift report, non-zero on drift) to the standalone writer. Rule generation drops its validate action: capture plans before approval, write verifies after publishing. Refs #791 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(aidd-context): a resolution is not an approval in rule generation Present ends the turn, replans after any change and waits for a later explicit approval. The writer path is resolved absolute once, in capture. Refs #791 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(aidd-context): define approval where rule generation writes Write requires a user message that approves the displayed candidate unchanged; a choice, edit or rename is a resolution. Refs #791 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * docs(aidd-context): drop the redundant relative-path warning from write-rule Refs #791 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * refactor(aidd-context): lean rule-generate wording and single approval rule Drop redundant bold step labels and filler across the skill, state the approval rule once in the transversal rules, show description, scope and hosts in the presented candidate, and reuse the existing rule's hosts. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent 45a48d6 commit 708eefa

15 files changed

Lines changed: 235 additions & 175 deletions

File tree

‎aidd_docs/tasks/2026_10/2026_10_11_rule-contracts/official-contracts.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ Native instruction text guides model behavior; it does not guarantee compliance.
2222

2323
[6] [Codex 0.162.1 implementation](https://github.com/openai/codex/blob/092d3acd6bec3e3a14bdc7e7a2810ab628ab759d/codex-rs/core/src/agents_md.rs#L63) and [0.160.1 implementation](https://github.com/openai/codex/blob/d27764b82f7118f674371e6d6e76271d9d606edb/codex-rs/core/src/agents_md.rs#L63): separate global assembly and project budget. [HTTP receipts and hashes](evidence/official/http-receipts.json).
2424

25-
[7] [Skill host contract](../../../../plugins/aidd-context/skills/05-rule-generate/references/tool-paths.md) and [publication script](../../../../plugins/aidd-context/skills/05-rule-generate/scripts/write-rule.cjs): restricted serialization, body ownership and shared publication.
25+
[7] [Skill host contract](../../../../plugins/aidd-context/skills/05-rule-generate/references/rule-publication.md) and [publication script](../../../../plugins/aidd-context/skills/05-rule-generate/scripts/write-rule.cjs): restricted serialization, body ownership and shared publication.

‎docs/CATALOG.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Bootstrap, project init, context-artifact generation, diagrams, learning, and ex
2525
| `02-project-memory` | Give the AI a memory of the project, wired into the tools you use | `01-scan`, `02-write`, `03-check`, `04-sync` |
2626
| `03-context-generate` | Router that dispatches an artifact-generation request to the dedicated generator below | delegates to `04`–`08` (and plugins / marketplaces) |
2727
| `04-skill-generate` | Generate a router-based skill across the host AI tool(s) | `01-scope`, `02-plan`, `03-write`, `04-validate` |
28-
| `05-rule-generate` | Generate a coding rule that governs editor and agent behavior | `01-capture-rule`, `02-write-rule`, `03-validate` |
28+
| `05-rule-generate` | Generate a coding rule that governs editor and agent behavior | `01-capture-rule`, `02-write-rule` |
2929
| `06-agent-generate` | Generate an agent across the host AI tool(s) | `01-capture-agent`, `02-write-agent`, `03-validate` |
3030
| `07-command-generate` | Generate a flat slash command across the host AI tool(s) | `01-capture-command`, `02-write-command`, `03-validate` |
3131
| `08-hook-generate` | Generate a lifecycle hook across the host AI tool(s) | `01-capture-hook`, `02-write-hook`, `03-validate` |

‎plugins/aidd-context/CATALOG.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,11 @@ Auto-generated index of skills, agents, references and assets shipped by the `ai
118118
|-------|------|---|
119119
| `actions` | [01-capture-rule.md](skills/05-rule-generate/actions/01-capture-rule.md) | - |
120120
| `actions` | [02-write-rule.md](skills/05-rule-generate/actions/02-write-rule.md) | - |
121-
| `actions` | [03-validate.md](skills/05-rule-generate/actions/03-validate.md) | - |
122121
| `assets` | [rule-template.md](skills/05-rule-generate/assets/rule-template.md) | - |
122+
| `references` | [rule-assessment.md](skills/05-rule-generate/references/rule-assessment.md) | - |
123123
| `references` | [rule-authoring.md](skills/05-rule-generate/references/rule-authoring.md) | - |
124-
| `references` | [tool-paths.md](skills/05-rule-generate/references/tool-paths.md) | - |
124+
| `references` | [rule-discovery.md](skills/05-rule-generate/references/rule-discovery.md) | - |
125+
| `references` | [rule-publication.md](skills/05-rule-generate/references/rule-publication.md) | - |
125126
| `-` | [SKILL.md](skills/05-rule-generate/SKILL.md) | `Create, update, publish or delete a coding rule across host AI tools. Use when adding, changing or removing a rule, convention or coding standard. Not for skills, agents or hooks.` |
126127

127128
#### `skills/06-agent-generate`

‎plugins/aidd-context/skills/05-rule-generate/SKILL.md‎

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,32 @@ argument-hint: topic | auto
66

77
# Rule Generate
88

9-
Manage canonical rules and their active publications per confirmed host, or author a plugin source.
9+
```mermaid
10+
flowchart TD
11+
request[Rule request] --> capture-rule
12+
capture-rule -->|create/update| decision[Assessed candidate]
13+
decision -->|revise/clarify| capture-rule
14+
decision -->|keep/cancel| stop
15+
decision -->|approved| write-rule
16+
capture-rule -->|publish/delete confirmed| write-rule
17+
write-rule -->|revised| capture-rule
18+
write-rule -->|refused| stop
19+
write-rule -->|verified| result
20+
```
1021

1122
## Actions
1223

13-
| # | Action | Role | Input |
14-
| --- | -------------- | ----------------------------------------- | ------------ |
15-
| 01 | `capture-rule` | Capture the topic, pick category and slug | user request |
16-
| 02 | `write-rule` | Write the rule file per supported tool | the topic |
17-
| 03 | `validate` | Check each rule file | the files |
24+
Follow the flow. Read only the next action and its references.
1825

19-
Run the actions in order, `01 → 03`, and run each action's `## Test` before the next.
20-
Before running an action, read its file in `actions/`, not only the table or assets.
26+
| Action | Does |
27+
| --- | --- |
28+
| capture-rule | frame, compare, plan, decide |
29+
| write-rule | write the approved result, verify |
2130

22-
## References
31+
## Transversal rules
2332

24-
- `references/rule-authoring.md`: the contract (taxonomy, naming, frontmatter, content).
25-
- `references/tool-paths.md`: per-tool rules path, frontmatter, unsupported tools, the gate.
26-
27-
## Assets
28-
29-
- `assets/rule-template.md`: rule file scaffold.
33+
- Report unsupported hosts with alternatives; a lone AGENTS file identifies no installed host.
34+
- Stop and name any installed reference that cannot be read.
35+
- Change existing sources or publications only with explicit permission naming them.
36+
- Write only after the user approves the candidate shown last. A choice, merge, edit or rename is not an approval: show the revision and wait.
37+
- Keep or cancel leaves project bytes unchanged.
Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11
# 01 - Capture rule
22

3-
Settle the rule's topic and place before writing.
3+
Frame the request, compare it with existing policies, plan the publication, decide with the user.
44

55
## Input
66

7-
A rule topic (e.g. "TypeScript naming"), or `auto` to scan the codebase and propose rules. Empty means manual.
7+
Request: a topic, `auto`, or a publish/delete. Default manual.
88

99
## Output
1010

11-
In-context: the topic, its category and slug, the file scope, a one-line description, and the write mode (host with supported tools, or plugin source).
11+
Approved candidates with planned paths, or confirmed sources, operation and destinations.
1212

1313
## Process
1414

15-
1. **Gate.** Run the asset-access precheck ([tool-paths.md](../references/tool-paths.md)).
16-
For an explicitly confirmed host publish/delete, identify the existing rule or rule set and hosts, then continue to Render in action 02; no new topic or body is needed.
17-
2. **Auto or manual.** Ask whether to run auto or manual mode:
18-
- **Auto**: scan the codebase, propose a rules architecture, wait for approval.
19-
- **Manual**: ask the topic (blocking). Confirm any candidate first.
20-
3. **Place.** Pick the category and slug from [rule-authoring.md](../references/rule-authoring.md). The category index drives the slug prefix.
21-
4. **Scope.** State the glob the rule applies to, or note it applies to all files. Note a one-line description of what the rule governs, for tools whose scope frontmatter needs it.
22-
5. **Write mode.** Ask where the rule goes:
23-
- **Host project**: detect the installed tools ([tool-paths.md](../references/tool-paths.md)), propose the supported ones, and confirm which to target. Never pick one silently.
24-
- **Plugin source**: confirm or create `plugins/<plugin>/rules/`.
25-
26-
## Test
27-
28-
- The topic, category and slug, or existing publish/delete selection, are confirmed in writing.
29-
- Unsupported tools are named with what to do instead.
15+
1. Confirm the operation and [destination](../references/rule-publication.md).
16+
- Hosts: reuse the existing rule's hosts, else ask. Missing hosts: detect, propose installation, await selection before drafting.
17+
2. Frame the topic.
18+
- Manual: ask for it.
19+
- Auto: scan, propose topics, await selection.
20+
- Publish/delete: confirm sources and whole publications, then plan.
21+
3. Draft with the [template](../assets/rule-template.md) and [authoring](../references/rule-authoring.md), once topic and [fields](../references/rule-publication.md#operations) are confirmed.
22+
4. Compare: [discover policies](../references/rule-discovery.md) read-only in the project and loaded ancestors, never home or account scans, then [assess](../references/rule-assessment.md) each candidate.
23+
5. Plan: for a host, resolve the installed writer to an absolute path, write the request outside the destinations, run it with `--plan` per [publication](../references/rule-publication.md). A refusal returns to step 3.
24+
6. Present each candidate in full (body, description, scope, hosts), the planned paths and every finding (new rules too), then end the turn.
25+
- Needs review: ask for evidence, reassess before offering source changes.
26+
- Resolved: replan, present the revised candidate, end the turn again.
Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
# 02 - Write rule
22

3-
Build one canonical rule and publish it for each confirmed supported host.
3+
Write the approved result and verify it.
44

55
## Input
66

7-
From 01: the topic, category, slug, scope, and write mode.
7+
Approval: a user message approving the last displayed candidate unchanged.
8+
9+
Capture: the approved capture and its request.
810

911
## Output
1012

11-
The canonical source, generated targets, and any unsupported tool with its reason.
13+
The written files, verified, or the refusal.
1214

1315
## Process
1416

15-
1. **Build.** For create/update, use [rule-template.md](../assets/rule-template.md); strip the scaffold. For publish/delete, skip to Render.
16-
2. **Request.** For host create/update, put category, slug, description, optional paths and complete Markdown body into the JSON request in [tool-paths.md](../references/tool-paths.md). Keep YAML frontmatter out of the body.
17-
3. **Render.** Per the write mode ([tool-paths.md](../references/tool-paths.md)):
18-
- **Host**: resolve `scripts/write-rule.cjs` beside the loaded installed `SKILL.md`. Invoke its absolute path with explicit project, tools and the operation's arguments in [tool-paths.md](../references/tool-paths.md). Use it for create/update, publish and delete; never replace or remove generated files manually. It preflights all outputs. Report refusals verbatim; skip unsupported tools with their reason.
19-
- **Plugin source**: write one canonical `.md` rule. No per-tool fan-out.
20-
4. **Split.** When examples warrant it, write several rule files rather than one crowded one.
21-
5. **Validate.** Check the script's reported targets against [tool-paths.md](../references/tool-paths.md). It must not require the AIDD CLI.
17+
1. Match: for create/update, require that approval and compare body, fields, paths, resolution and evidence with the approved candidate. Without approval or on any difference, return to capture-rule, present the revision, end the turn, write nothing.
18+
2. Write the approved result.
19+
- Host: run the writer by the absolute path resolved in capture-rule, with the approved request.
20+
- Plugin: write or delete the approved source only.
21+
3. Verify: for a host, run the same absolute writer with `--check --publish`. Require no drift, deletions included.
22+
4. Report the written files. On refusal or drift, stop and quote it verbatim.
2223

23-
## Test
24+
## Rules
2425

25-
- Create/update/publish: canonical sources and active publications exist with the intended scope.
26-
- Delete: the selected source and its publications are absent; remaining rules and user bytes survive.
26+
- Leave generated files to the writer: canonical metadata and outputs are writer-owned, legacy rules unchanged.
27+
- Claim consumption only with matching and nonmatching file evidence from fresh host sessions.

‎plugins/aidd-context/skills/05-rule-generate/actions/03-validate.md‎

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
# <Rule title>
1+
<!-- Replace placeholders; delete this comment and unused lines. -->
22

3-
<One line: what this rule enforces.>
3+
# <Title>
44

5-
- <Concise rule preserving exact requirements.>
6-
- <Another.>
7-
8-
<!-- Several themes? Group the bullets under `## headings` (skip groups for a short rule). One tiny example per group, only if it removes ambiguity. -->
5+
- <Requirement.>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Rule assessment
2+
3+
## Labels
4+
5+
| Label | Means |
6+
| --- | --- |
7+
| needs review | uncertainty that could change the comparison; overrides every other label |
8+
| new | no coverage, overlap or conflict |
9+
| covered | existing policies supply every obligation throughout the scope |
10+
| overlap | compatible partial repetition or extension |
11+
| conflict | incompatible obligations, or an unjustified weakening |
12+
13+
## Comparison
14+
15+
- Compare obligations, prohibitions, scopes, conditions, exceptions and priority, prior sources on update and future files included.
16+
- Exclude only scopes proven disjoint.
17+
- Cite source paths, decisive quotes and scope reasons in every finding.
18+
19+
## Choices
20+
21+
- Offer create, keep, update, merge, scope, priority or cancel as applicable.
22+
- Needs review: request evidence, reassess before offering source changes. Keep and cancel stay available.
Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,30 @@
11
# Rule authoring
22

3-
The contract every generated rule must satisfy. A rule governs editor and agent behavior for a set of files.
4-
53
## Rules
64

7-
- **R1.** One rule file, one topic. Split a crowded rule into several files.
8-
- **R2.** Bullets only. Keep each concise; preserve requested literals, conditions and exceptions over word limits.
9-
- **R3.** Scope every rule to the files it applies to, or mark it as applying to all.
10-
- **R4.** English only, regardless of conversation language.
11-
- **R5.** Do not add a rule bullet that repeats, weakens, or contradicts another active bullet in the same rule.
12-
13-
## File naming
14-
15-
Format `#-slug[@version][-specificity]`. The `#` is the category index, single digit, no zero-pad. Examples: `2-typescript-naming`, `3-react@19-hooks`.
5+
- R1. One topic per file; split multiple topics.
6+
- R2. Concise bullets; keep literals, conditions and exceptions.
7+
- R3. Explicit scope or all files.
8+
- R4. English unless asked otherwise.
9+
- R5. Distinct bullets: none repeats, weakens or contradicts another.
1610

17-
## Category taxonomy
11+
## Naming
1812

19-
| # | Category | Covers |
20-
| --- | -------------------------- | --------------------------------------------- |
21-
| 00 | `architecture` | system patterns (Clean, Hexagonal, API design) |
22-
| 01 | `standards` | code style, naming (camelCase, imports) |
23-
| 02 | `programming-languages` | language-specific rules (TS strict mode) |
24-
| 03 | `frameworks-and-libraries` | framework/lib patterns (React, Prisma) |
25-
| 04 | `tooling` | tool/infra config (ESLint, Docker, CI) |
26-
| 05 | `testing` | test patterns (fixtures, mocking) |
27-
| 06 | `design-patterns` | code design (Repository, Factory) |
28-
| 07 | `quality` | perf and security (caching, auth) |
29-
| 08 | `domain` | business logic (entities, DTOs) |
30-
| 09 | `other` | miscellaneous |
13+
`#-slug[@version][-specificity]`: single-digit category prefix, no zero-padding.
3114

32-
Pick the most specific match: framework `03`, language syntax `02`, agnostic style `01`, architecture `00`, then `04`-`08` in order, else `09`.
15+
| Index | Category | Covers |
16+
| --- | --- | --- |
17+
| 00 | architecture | system design |
18+
| 01 | standards | style/naming |
19+
| 02 | programming-languages | language rules |
20+
| 03 | frameworks-and-libraries | framework/library patterns |
21+
| 04 | tooling | tools/configuration |
22+
| 05 | testing | test patterns |
23+
| 06 | design-patterns | code design patterns |
24+
| 07 | quality | performance/security |
25+
| 08 | domain | business logic |
26+
| 09 | other | miscellaneous |
3327

34-
## Content
28+
Pick in order: `03`, `02`, `01`, `00`, `04`–`08`, else `09`.
3529

36-
- Group related bullets under a `## group` heading when the rule has several themes. Skip groups for a short rule.
37-
- Add one tiny example per group only when it removes ambiguity. Good code only.
30+
- Themes: `## group`, at most one tiny good-code example each.

0 commit comments

Comments
 (0)