xdrs-core 0.24.1 → 0.26.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 (34) hide show
  1. package/.xdrs/_core/adrs/index.md +19 -19
  2. package/.xdrs/_core/adrs/principles/001-xdrs-core.md +37 -37
  3. package/.xdrs/_core/adrs/principles/002-policy-standards.md +153 -0
  4. package/.xdrs/_core/adrs/principles/003-skill-standards.md +23 -22
  5. package/.xdrs/_core/adrs/principles/004-article-standards.md +23 -23
  6. package/.xdrs/_core/adrs/principles/{005-semantic-versioning-for-xdr-packages.md → 005-semantic-versioning-for-xdrs-packages.md} +11 -11
  7. package/.xdrs/_core/adrs/principles/006-research-standards.md +24 -24
  8. package/.xdrs/_core/adrs/principles/007-plan-standards.md +14 -14
  9. package/.xdrs/_core/adrs/principles/008-xdr-standards-structured.md +19 -19
  10. package/.xdrs/_core/adrs/principles/009-presentation-standards.md +11 -11
  11. package/.xdrs/_core/adrs/principles/articles/001-xdrs-overview.md +61 -50
  12. package/.xdrs/_core/adrs/principles/skills/{001-lint/001-lint.test.int.js → 001-review/001-review.test.int.js} +4 -4
  13. package/.xdrs/_core/adrs/principles/skills/{001-lint/001-lint.test.int.report → 001-review/001-review.test.int.report} +1 -1
  14. package/.xdrs/_core/adrs/principles/skills/001-review/SKILL.md +94 -0
  15. package/.xdrs/_core/adrs/principles/skills/002-write-policy/002-write-policy.test.int.js +24 -0
  16. package/.xdrs/_core/adrs/principles/skills/{002-write-xdr/002-write-xdr.test.int.report → 002-write-policy/002-write-policy.test.int.report} +2 -2
  17. package/.xdrs/_core/adrs/principles/skills/{002-write-xdr → 002-write-policy}/SKILL.md +40 -40
  18. package/.xdrs/_core/adrs/principles/skills/003-write-skill/SKILL.md +18 -18
  19. package/.xdrs/_core/adrs/principles/skills/004-write-article/SKILL.md +32 -32
  20. package/.xdrs/_core/adrs/principles/skills/005-write-research/SKILL.md +25 -25
  21. package/.xdrs/_core/adrs/principles/skills/006-write-plan/SKILL.md +17 -17
  22. package/.xdrs/_core/adrs/principles/skills/007-write-presentation/SKILL.md +14 -14
  23. package/.xdrs/_core/index.md +21 -26
  24. package/.xdrs/index.md +4 -4
  25. package/AGENTS.md +12 -12
  26. package/README.md +53 -40
  27. package/lib/lint.js +53 -48
  28. package/lib/lint.test.js +96 -96
  29. package/package.json +3 -3
  30. package/.xdrs/_core/adrs/principles/002-xdr-standards.md +0 -158
  31. package/.xdrs/_core/adrs/principles/skills/001-lint/SKILL.md +0 -94
  32. package/.xdrs/_core/adrs/principles/skills/002-write-xdr/002-write-xdr.test.int.js +0 -24
  33. package/.xdrs/_core/bdrs/index.md +0 -9
  34. package/.xdrs/_core/bdrs/principles/001-xdr-decisions-and-skills-usage.md +0 -52
@@ -1,39 +1,50 @@
1
- # _core-article-001: XDRs Overview
1
+ # _core-adr-article-001: XDRS Overview
2
2
 
3
3
  ## Overview
4
4
 
5
- This article introduces XDRs (Decision Records), explains their purpose and design, and guides
5
+ This article introduces XDRS, explains its purpose and design, and guides
6
6
  teams through adopting, extending, and distributing them. It is an entry point for anyone new to
7
- the framework and links out to the authoritative Decision Records for full details.
7
+ the framework and links out to the authoritative Policy documents for full details.
8
8
 
9
9
  ## Content
10
10
 
11
11
  ### What the central elements are
12
12
 
13
- The XDR framework is built around a small set of artifact types that play different roles in the
13
+ The XDRS framework is built around a small set of artifact types that play different roles in the
14
14
  same decision system.
15
15
 
16
- - **Decision Records (XDRs)** are the authoritative decisions. They answer a concrete question and
16
+ A standard Decision Record normally combines several concerns in the same document: a reason
17
+ (why, options considered), a policy (rules, core decision), a plan (consequences, implementation
18
+ approach), a how-to (step-by-step procedure), and a view on a topic. The XDRS framework separates
19
+ these concerns into different document types: Policies as the source of truth, Research for
20
+ reasoning and evidence, Plans for implementation approach, Skills for execution procedures, and
21
+ Articles for topic overviews. Supporting artifacts may explain, justify, or operationalize the
22
+ policy, but they do not replace it. The compilation process of a raw Decision Record is to
23
+ distribute it into those different documents and create links between them. You can also use the
24
+ framework standalone, generating these elements individually directly during the writing process
25
+ without starting from a raw Decision Record.
26
+
27
+ - **Policies** are the authoritative decisions. They answer a concrete question and
17
28
  record the adopted direction. They are the central policy artifact of the framework for the
18
- scope and topic they cover. Three decision record types exist: **ADR** for architectural and
29
+ scope and topic they cover. Three policy types exist: **ADR** for architectural and
19
30
  technical decisions, **BDR** for business and operational decisions, and **EDR** for engineering
20
- implementation decisions. See [_core-adr-001](../001-xdrs-core.md).
31
+ implementation decisions. See [_core-adr-policy-001](../001-xdrs-core.md).
21
32
  - **Research** captures exploration before or around a decision: constraints, findings, options,
22
33
  pros, and cons. Research supports elaboration, discussion, and updates,
23
34
  but it is not the final rule. A single Research document may inform multiple downstream ADRs,
24
- BDRs, or EDRs. If Research and an XDR disagree, the XDR wins. See
25
- [_core-adr-006](../006-research-standards.md).
35
+ BDRs, or EDRs. If Research and a Policy disagree, the Policy wins. See
36
+ [_core-adr-policy-006](../006-research-standards.md).
26
37
  - **Skills** describe how to execute work under the constraints of the decisions. They add the
27
- procedural detail that XDRs intentionally avoid. A Skill may be used by a human, an AI agent, or
38
+ procedural detail that Policies intentionally avoid. A Skill may be used by a human, an AI agent, or
28
39
  both. Skills are task-based, should end in a verifiable outcome, and are only mandatory when a
29
- policy such as an XDR makes them mandatory. See [_core-adr-003](../003-skill-standards.md).
30
- - **Articles** are synthetic views, like this one. They explain a topic across multiple XDRs,
40
+ policy such as a Policy document makes them mandatory. See [_core-adr-policy-003](../003-skill-standards.md).
41
+ - **Articles** are synthetic views, like this one. They explain a topic across multiple Policies,
31
42
  Research documents, and Skills, helping readers understand the system without making new
32
- decisions. See [_core-adr-004](../004-article-standards.md).
43
+ decisions. See [_core-adr-policy-004](../004-article-standards.md).
33
44
  - **Plans** describe a problem, a proposed solution, and the approach and activities needed to
34
45
  solve it. They have a clear start and end and a well-defined scope. Plans are ephemeral: they
35
- must be deleted after full implementation, with lasting outputs captured as Decisions, Skills,
36
- Articles, or other artifacts. See [_core-adr-007](../007-plan-standards.md).
46
+ must be deleted after full implementation, with lasting outputs captured as Policies, Skills,
47
+ Articles, or other artifacts. See [_core-adr-policy-007](../007-plan-standards.md).
37
48
  - **Indexes and folder structure** are the discovery layer. They do not make decisions by
38
49
  themselves, but they determine how people and agents find the right artifacts, how scopes
39
50
  override one another, and how a large set of decisions remains navigable.
@@ -42,7 +53,7 @@ same decision system.
42
53
 
43
54
  The easiest way to distinguish the central elements is by asking what job each one performs.
44
55
 
45
- - **XDR**: "What did we decide?"
56
+ - **Policy**: "What did we decide?"
46
57
  - **Research**: "What did we learn while evaluating options?"
47
58
  - **Skill**: "How do we carry out work under this decision?"
48
59
  - **Article**: "How do these artifacts fit together for a reader?"
@@ -52,13 +63,13 @@ The easiest way to distinguish the central elements is by asking what job each o
52
63
  This separation matters because mixing these jobs into one file makes the system harder to search,
53
64
  harder to update, and harder for agents to apply correctly.
54
65
 
55
- ### How to decide whether an XDR should be used
66
+ ### How to decide whether a Policy should be used
56
67
 
57
- Before treating an XDR as a rule for the current case, check its metadata first. All documents present in the collection are considered active — if a document exists, it is current.
68
+ Before treating a Policy as a rule for the current case, check its metadata first. All documents present in the collection are considered active — if a document exists, it is current.
58
69
 
59
70
  - **Valid first**: if present, the convergence date indicates when full adoption is expected. New implementations SHOULD adopt the decision immediately; compliance is not enforced during reviews until the date.
60
71
  - **Applied to second**: if present, the current codebase, workflow, system, or audience must fit that scope.
61
- - **Decision text last**: the XDR's own context and implementation details still determine the final boundaries and exceptions.
72
+ - **Decision text last**: the Policy's own context and implementation details still determine the final boundaries and exceptions.
62
73
  - **Then enforce**: only decisions that pass those checks should be used as active requirements. The rest may still be useful context.
63
74
 
64
75
  Documents that are no longer relevant should be removed from the collection. Historical versions are available via versioned packages or git history.
@@ -70,21 +81,21 @@ The framework is easiest to understand as a lifecycle rather than a static folde
70
81
  1. **Explore** — A team starts with a problem, constraints, and uncertainty. Research is the best
71
82
  place to compare options, record findings, and keep tradeoffs visible. That same research may
72
83
  later support more than one decision record.
73
- 2. **Decide** — Once a direction is chosen, an XDR captures the final answer in concise,
74
- authoritative form. The XDR should make clear when the decision applies, and may link back to
84
+ 2. **Decide** — Once a direction is chosen, a Policy captures the final answer in concise,
85
+ authoritative form. The Policy should make clear when the decision applies, and may link back to
75
86
  the Research that informed its considered options.
76
87
  3. **Execute** — If the decision affects daily work, a Skill explains how to apply it in practice.
77
- The Skill operationalizes the decision without turning the XDR into a procedure manual.
78
- 4. **Explain** — When the topic becomes broad or cross-cutting, an Article synthesizes the XDR,
88
+ The Skill operationalizes the decision without turning the Policy into a procedure manual.
89
+ 4. **Explain** — When the topic becomes broad or cross-cutting, an Article synthesizes the Policy,
79
90
  Research, and Skills into a navigable explanation for humans and agents.
80
91
  5. **Distribute and override** — Canonical indexes and scope ordering make the artifacts
81
92
  discoverable across teams. Broader scopes can be reused, and more specific scopes can extend or
82
93
  override them.
83
94
 
84
- This gives XDRs a timeline feel:
95
+ This gives Policies a timeline feel:
85
96
 
86
97
  - Research usually appears before or around a decision.
87
- - The XDR marks the adopted outcome.
98
+ - The Policy marks the adopted outcome.
88
99
  - Skills appear when the decision must be executed repeatedly.
89
100
  - Articles appear when the ecosystem around the decision needs explanation or onboarding support.
90
101
 
@@ -121,8 +132,8 @@ guidance, and the explanatory overview close together without collapsing them in
121
132
  ### Why this separation works
122
133
 
123
134
  - **Small focused files** keep decisions readable and agent-friendly.
124
- - **Research beside the XDR** preserves why options were accepted or rejected.
125
- - **Skills beside the XDR** reduce drift between decisions and execution.
135
+ - **Research beside the Policy** preserves why options were accepted or rejected.
136
+ - **Skills beside the Policy** reduce drift between decisions and execution.
126
137
  - **Articles above the artifacts** help readers understand the whole topic without replacing the
127
138
  source of truth.
128
139
  - **Indexes and scopes** let the framework scale across teams while preserving override behavior.
@@ -131,25 +142,25 @@ guidance, and the explanatory overview close together without collapsing them in
131
142
 
132
143
  1. Create or open a project workspace.
133
144
  2. Run `npx xdrs-core` in the workspace root. This installs:
134
- - `AGENTS.md` — instructs AI agents to always consult XDRs.
145
+ - `AGENTS.md` — instructs AI agents to always consult XDRS.
135
146
  - `.xdrs/index.md` — root index (editable, `keepExisting` mode).
136
- - `_core` XDRs, Research documents, and skills under `.xdrs/_core/`.
147
+ - `_core` Policies, Research documents, and skills under `.xdrs/_core/`.
137
148
  3. Start a conversation with your AI agent:
138
149
  > Create an ADR about our decision to use Python for AI projects.
139
150
 
140
151
  ### Guidelines
141
152
 
142
- Follow [_core-adr-001](../001-xdrs-core.md) and [_core-adr-002](../002-xdr-standards.md) strictly. Key rules:
153
+ Follow [_core-adr-policy-001](../001-xdrs-core.md) and [_core-adr-policy-002](../002-policy-standards.md) strictly. Key rules:
143
154
 
144
155
  - Use **mandatory language** (`must`, `never`, `required`) for non-negotiable rules and
145
156
  **advisory language** (`should`, `recommended`) for guidance.
146
- - Before citing an XDR as a requirement, check `Valid` first, then `Applied to`, and finally the decision text to confirm the decision is in scope for the current case.
157
+ - Before citing a Policy as a requirement, check `Valid` first, then `Applied to`, and finally the decision text to confirm the decision is in scope for the current case.
147
158
  - All documents present in the collection are considered active. Remove documents that are no longer relevant.
148
- - Keep XDRs under 1300 words as a rule of thumb (exceptions up to 2600 words for templates or more elaborate decisions). Move procedural detail to a co-located Skill.
149
- - Keep exploratory option analysis in a co-located Research document instead of bloating the XDR.
150
- - Always update the scope+type index and the root index after adding or changing an XDR.
159
+ - Keep Policies under 1300 words as a rule of thumb (exceptions up to 2600 words for templates or more elaborate decisions). Move procedural detail to a co-located Skill.
160
+ - Keep exploratory option analysis in a co-located Research document instead of bloating the Policy.
161
+ - Always update the scope+type index and the root index after adding or changing a Policy.
151
162
  - Use `_local` scope when a decision is project-specific and must not be shared.
152
- - Never reuse a number once it has been assigned, even if the XDR is deleted.
163
+ - Never reuse a number once it has been assigned, even if the Policy is deleted.
153
164
 
154
165
  ### How to extend
155
166
 
@@ -157,18 +168,18 @@ Follow [_core-adr-001](../001-xdrs-core.md) and [_core-adr-002](../002-xdr-stand
157
168
  - **New subject** — create the subject folder under the existing scope+type path. Add an
158
169
  allowed subject or use `principles` if none fits (propose a new subject via a `_core` ADR).
159
170
  - **New research** — add a `researches/[number]-[short-title].md` inside the relevant subject
160
- folder, following [_core-adr-006](../006-research-standards.md).
171
+ folder, following [_core-adr-policy-006](../006-research-standards.md).
161
172
  - **New skill** — add a `skills/[number]-[skill-name]/SKILL.md` inside the relevant subject
162
- folder, following [_core-adr-003](../003-skill-standards.md).
173
+ folder, following [_core-adr-policy-003](../003-skill-standards.md).
163
174
  - **New article** — add an `articles/[number]-[short-title].md` inside the relevant subject
164
- folder, following [_core-adr-004](../004-article-standards.md).
175
+ folder, following [_core-adr-policy-004](../004-article-standards.md).
165
176
  - **New plan** — add a `plans/[number]-[short-title].md` inside the relevant subject
166
- folder, following [_core-adr-007](../007-plan-standards.md).
177
+ folder, following [_core-adr-policy-007](../007-plan-standards.md).
167
178
 
168
- ### Using XDRs in your own project
179
+ ### Using XDRS in your own project
169
180
 
170
181
  1. **Install** — add the scope package as a dependency and run `npx xdrs-core extract` (or
171
- `pnpm exec xdrs-core extract`) to unpack XDR files into `.xdrs/` in your workspace.
182
+ `pnpm exec xdrs-core extract`) to unpack XDRS files into `.xdrs/` in your workspace.
172
183
  2. **Pins and upgrades** — update the npm dependency version to pull in the latest decisions
173
184
  for a scope. The `filedist` mechanism tracks managed files in `.filedist` and keeps
174
185
  `.xdrs/index.md` in `keepExisting` mode so local edits are preserved.
@@ -181,15 +192,15 @@ Follow [_core-adr-001](../001-xdrs-core.md) and [_core-adr-002](../002-xdr-stand
181
192
 
182
193
  ## References
183
194
 
184
- - [_core-adr-001](../001-xdrs-core.md) - XDR elements: types, scopes, subjects, folder structure
185
- - [_core-adr-002](../002-xdr-standards.md) - XDR document standards and mandatory template
186
- - [_core-adr-003](../003-skill-standards.md) - Skill standards and co-location rules
187
- - [_core-adr-004](../004-article-standards.md) - Article standards
188
- - [_core-adr-006](../006-research-standards.md) - Research standards
189
- - [_core-adr-007](../007-plan-standards.md) - Plan standards
190
- - [001-lint skill](../skills/001-lint/SKILL.md) - Linting code against XDRs
191
- - [002-write-xdr skill](../skills/002-write-xdr/SKILL.md) - Writing a new XDR
195
+ - [_core-adr-policy-001](../001-xdrs-core.md) - XDRS elements: types, scopes, subjects, folder structure
196
+ - [_core-adr-policy-002](../002-policy-standards.md) - Policy document standards and mandatory template
197
+ - [_core-adr-policy-003](../003-skill-standards.md) - Skill standards and co-location rules
198
+ - [_core-adr-policy-004](../004-article-standards.md) - Article standards
199
+ - [_core-adr-policy-006](../006-research-standards.md) - Research standards
200
+ - [_core-adr-policy-007](../007-plan-standards.md) - Plan standards
201
+ - [001-review skill](../skills/001-review/SKILL.md) - Reviewing code against Policies
202
+ - [002-write-policy skill](../skills/002-write-policy/SKILL.md) - Writing a new Policy
192
203
  - [003-write-skill skill](../skills/003-write-skill/SKILL.md) - Writing a new skill
193
204
  - [004-write-article skill](../skills/004-write-article/SKILL.md) - Writing a new article
194
205
  - [005-write-research skill](../skills/005-write-research/SKILL.md) - Writing a new research document
195
- - [_core-adr-005](../005-semantic-versioning-for-xdr-packages.md) - Semantic versioning rules for XDR packages
206
+ - [_core-adr-policy-005](../005-semantic-versioning-for-xdrs-packages.md) - Semantic versioning rules for XDRS packages
@@ -15,7 +15,7 @@ test('smoke test', async () => {
15
15
  ...copilotCmd(REPO_ROOT),
16
16
  },
17
17
  'Reply ONLY with "READY" after checking if SKILL 001 has any contents',
18
- 'Verify that the final output is ONLY "READY" and that it read file 001-lint/SKILL.md',
18
+ 'Verify that the final output is ONLY "READY" and that it read file 001-review/SKILL.md',
19
19
  null,
20
20
  true
21
21
  );
@@ -23,15 +23,15 @@ test('smoke test', async () => {
23
23
  expect(err).toBe('');
24
24
  });
25
25
 
26
- test('001-lint outputs the required review template', async () => {
26
+ test('001-review outputs the required review template', async () => {
27
27
  const err = await testPrompt(
28
28
  {
29
29
  workspaceRoot: REPO_ROOT,
30
30
  workspaceMode: 'copy',
31
31
  ...copilotCmd(REPO_ROOT),
32
32
  },
33
- 'Review xdr 001-xdrs-core',
34
- 'Verify that the skill 001-lint was used, contains "## Findings", and "## Summary", includes an "Outcome: PASS", and that it read file 001-lint/SKILL.md and 001-xdrs-core.md.',
33
+ 'Review XDRS Policy 001-xdrs-core',
34
+ 'Verify that the skill 001-review was used, contains "## Findings", and "## Summary", includes an "Outcome: PASS", and that it read file 001-review/SKILL.md and 001-xdrs-core.md.',
35
35
  null,
36
36
  true
37
37
  );
@@ -1,5 +1,5 @@
1
1
  {
2
- "Review xdr 001-xdrs-core-ac1c8339": {
2
+ "Review XDRS Policy 001-xdrs-core-ac1c8339": {
3
3
  "result": "success",
4
4
  "contextFiles": [
5
5
  ".github/skills/001-lint/SKILL.md",
@@ -0,0 +1,94 @@
1
+ ---
2
+ name: _core-adr-skill-001-review
3
+ description: >
4
+ Reviews code changes or files against applicable Policies and reports violations as structured findings.
5
+ Activate this skill when the user asks to review, lint, or audit code or Policies, or when you identify a need to check compliance with Policies during implementation.
6
+ metadata:
7
+ author: flaviostutz
8
+ version: "1.0"
9
+ ---
10
+
11
+ ## Overview
12
+
13
+ Performs a structured review of code changes or files against the Policies in the repository, categorizing findings by severity and type, and reporting them without modifying any code.
14
+
15
+ ## Instructions
16
+
17
+ ### Phase 1: Code Gathering
18
+
19
+ 1. Identify changes based on requested scope:
20
+ - For diffs: run and parse `git diff refs/remotes/origin/HEAD`
21
+ - For files: analyze file contents directly
22
+
23
+ ### Phase 2: Policy Compilation
24
+
25
+ 1. Gather all Policies from the Policy root `index.md` (default: `.policies/index.md`) starting from the working directory.
26
+ - Policy scopes are controlled by nested folders; some are broad, others domain-specific.
27
+ - Extract frontmatter first to decide whether each Policy should be used for the current review context.
28
+ - All documents present in the collection are considered active.
29
+ - Check `valid-from:` first. If a date is present and has not yet been reached, the decision SHOULD be adopted for new implementations but is not enforced during reviews.
30
+ - Check `apply-to:` second. Keep only Policies whose stated scope fits the files, systems, or workflows under review.
31
+ - Check the decision text itself last for additional boundaries or exceptions that metadata does not encode.
32
+ 2. Filter relevance based on file types, domains, and architectural patterns in scope.
33
+
34
+ ### Phase 3: Policy Review
35
+
36
+ 1. Cross-reference each file in scope against active, applicable Policies.
37
+ - **Drop any finding that cannot be traced to a specific rule in an Accepted Policy.** General good-practice observations, personal opinions, or inferred issues without an explicit Policy backing must not be reported.
38
+ - Classify as ERROR (mandatory) or WARNING (advisory).
39
+ - Include: location, description, Policy reference (file + line), suggestion.
40
+ 2. Reduce false positives:
41
+ - Evaluate ERROR findings for mandatory language in the Policy ("must", "always", "never", "required", "mandatory"). Drop or downgrade to WARNING if the language is advisory ("should", "recommended", "advised").
42
+ - Remove findings unrelated to actual changes.
43
+ - Consolidate duplicates.
44
+ - Consider context (existing style, legacy sections, etc.).
45
+ 3. For related Policies and files, lookup for the specific line number in both the Policy and the code that are related to the finding. This will be used in the reporting phase to provide precise references and actionable suggestions.
46
+
47
+ ### Phase 4: Judgment
48
+ 1. Judgment criteria (all must be true to keep a finding):
49
+ - Is the violation explicitly stated as a rule in an Accepted Policy using mandatory or advisory language? Templates, examples, and diagrams in Policies are illustrative only — they do not constitute rules. If the only evidence for the violation is an implicit pattern in a code sample or template, drop it.
50
+ - Is there concrete evidence in the code or diff?
51
+ - Is the finding actionable?
52
+ - Would fixing it meaningfully improve compliance with the Policies?
53
+
54
+ ### Phase 5: Reporting
55
+
56
+ **Report template**
57
+ ```text
58
+ ### Code Review Against Policies
59
+ Scope: [scope identifier]
60
+
61
+ ## Findings
62
+ ### 1. [ERROR|WARNING] - [filename:line_number](filename:line_number)
63
+ - Title of the finding (<=15 words)
64
+ - Policy reference: [policy-file:line_number](policy-file:line_number)
65
+ - Why: Brief description of the issue in 20 words
66
+ - Fix: Specific action to fix this issue in 15 words
67
+ - Relevance: Why this matters / What to watch for in 15 words
68
+
69
+ ### 2. [second finding etc]
70
+
71
+ ## Summary
72
+ - Errors: [count]
73
+ - Warnings: [count]
74
+ - Outcome: [PASS|FAIL]
75
+ ```
76
+
77
+ ### Constraints
78
+ - MUST NOT include any text or explanations outside the required output format.
79
+ - MUST NOT edit code. Instruct the user on how to request code changes in suggestions.
80
+
81
+ ## Examples
82
+ - A Policy mentions that "Every code MUST have a header comment with author name", if you find a codebase without the author name, report as ERROR.
83
+ - A Policy mentions that "Functions SHOULD be no longer than 50 lines", if you find a function with 80 lines, report as WARNING.
84
+
85
+ ## Edge Cases
86
+ - If no Policies apply to the scope, output "No applicable Policies found" and skip reporting.
87
+ - If a potential violation is in pre-existing code outside the diff, report it as WARNING only.
88
+
89
+ ## References
90
+
91
+ - [_core-adr-policy-001 - Policies core](../../001-xdrs-core.md)
92
+ - [_core-adr-policy-002 - Policy standards](../../002-policy-standards.md)
93
+ - [_core-adr-policy-003 - Skill standards](../../003-skill-standards.md)
94
+
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const { copilotCmd, testPrompt } = require('xdrs-core');
5
+
6
+ const REPO_ROOT = path.resolve(__dirname, '..', '..', '..', '..', '..', '..');
7
+
8
+ jest.setTimeout(300000);
9
+
10
+ test('002-write-policy creates a local EDR policy', async () => {
11
+ const err = await testPrompt(
12
+ {
13
+ workspaceRoot: REPO_ROOT,
14
+ workspaceMode: 'copy',
15
+ ...copilotCmd(REPO_ROOT),
16
+ },
17
+ 'Create a very small XDRS Policy deciding to use pnpm for Node.js monorepos',
18
+ 'Verify that an XDRS Policy markdown file was created under .xdrs/_local/edrs/devops/, that it contains "## Context and Problem Statement" and "## Decision Outcome", that it read file 002-write-policy/SKILL.md and has the decision of using pnpm for Node.js monorepos.',
19
+ null,
20
+ true
21
+ );
22
+
23
+ expect(err).toBe('');
24
+ });
@@ -1,10 +1,10 @@
1
1
  {
2
- "Create a very small XDR deciding to use -8b1a2ddd": {
2
+ "Create a very small XDRS Policy deciding to -8b1a2ddd": {
3
3
  "result": "success",
4
4
  "contextFiles": [
5
5
  ".xdrs/_core/adrs/index.md",
6
6
  ".xdrs/_core/adrs/principles/002-xdr-standards.md",
7
- ".xdrs/_core/adrs/principles/skills/002-write-xdr/SKILL.md",
7
+ ".xdrs/_core/adrs/principles/skills/002-write-policy/SKILL.md",
8
8
  ".xdrs/index.md",
9
9
  "AGENTS.md"
10
10
  ],
@@ -1,8 +1,8 @@
1
1
  ---
2
- name: 002-write-xdr
2
+ name: _core-adr-skill-002-write-policy
3
3
  description: >
4
- Creates a new XDR (Decision Record) interactively: selects type, scope, subject, and writes a focused, conflict-checked decision document.
5
- Activate this skill when the user asks to create, add, or write a new XDR, ADR, BDR, or EDR.
4
+ Creates a new Policy interactively: selects type, scope, subject, and writes a focused, conflict-checked policy document.
5
+ Activate this skill when the user asks to create, add, or write a new Policy (ADR, BDR, or EDR).
6
6
  metadata:
7
7
  author: flaviostutz
8
8
  version: "1.0"
@@ -10,16 +10,16 @@ metadata:
10
10
 
11
11
  ## Overview
12
12
 
13
- Guides the creation of a well-structured XDR by following the standards in `_core-adr-001`, consulting `xdr-standards` for every core element definition, researching existing records for conflicts, checking redundancy across related artifacts, and iterating until the document is concise, decision-focused, and clear about when the decision should be used.
13
+ Guides the creation of a well-structured Policy by following the standards in `_core-adr-policy-001`, consulting `policy-standards` for every core element definition, researching existing policies for conflicts, checking redundancy across related artifacts, and iterating until the document is concise, decision-focused, and clear about when the decision should be used.
14
14
 
15
15
  ## Instructions
16
16
 
17
17
  ### Phase 1: Understand the Decision
18
18
 
19
- 1. Read the XDR root `index.md` (default: `.xdrs/index.md`) to discover all active scopes and their canonical indexes.
20
- 2. Read `.xdrs/_core/adrs/principles/001-xdrs-core.md` in full to internalize structure rules, mandatory language, and the XDR framework elements.
21
- 3. Read `.xdrs/_core/adrs/principles/002-xdr-standards.md` in full to internalize the XDR template and document writing rules.
22
- 4. Treat `001-xdrs-core` as the canonical source for all core XDR element definitions (type, scope, subject, numbering, placement). Treat `002-xdr-standards` as the canonical source for how to write and structure the document itself.
19
+ 1. Read the XDRS root `index.md` (default: `.xdrs/index.md`) to discover all active scopes and their canonical indexes.
20
+ 2. Read `.xdrs/_core/adrs/principles/001-xdrs-core.md` in full to internalize structure rules, mandatory language, and the XDRS framework elements.
21
+ 3. Read `.xdrs/_core/adrs/principles/002-policy-standards.md` in full to internalize the Policy template and document writing rules.
22
+ 4. Treat `001-xdrs-core` as the canonical source for all core XDRS element definitions (type, scope, subject, numbering, placement). Treat `002-policy-standards` as the canonical source for how to write and structure the document itself.
23
23
  5. Ask the user (or infer from context) the topic of the decision. Do NOT proceed to Phase 2 without a clear topic.
24
24
  - Ask one focused clarifying question at a time. Wait for the answer before asking the next question.
25
25
  - Each answer may reveal new ambiguities; ask follow-up questions as needed until the topic, intent, and scope are unambiguous.
@@ -44,47 +44,47 @@ Consult `001-xdrs-core` while making each choice in this phase. The summaries be
44
44
 
45
45
  When type, scope, or subject cannot be confidently inferred, ask the user a clarifying question before proceeding. Ask one question at a time and wait for the answer; follow up if the response introduces new ambiguity.
46
46
 
47
- **XDR ID** — format: `[scope]-[type]-[next available number]`
47
+ **Policy ID** — format: `[scope]-[type]-[next available number]`
48
48
  - Scan `.xdrs/[scope]/[type]/` for the highest existing number in that scope+type and increment by 1.
49
- - Never reuse numbers from deleted XDRs.
49
+ - Never reuse numbers from deleted Policies.
50
50
 
51
51
  ### Phase 3: Choose the Title
52
52
 
53
- Choose a title that clearly states the question this XDR answers, not the answer itself. The title should let a reader know at a glance what decision scope this record covers.
53
+ Choose a title that clearly states the question this Policy answers, not the answer itself. The title should let a reader know at a glance what decision scope this record covers.
54
54
 
55
55
  - Good: "Package manager for Node.js projects", "Phone marketing procedures", "Integration patterns for systems connectivity"
56
56
  - Avoid: "Use pnpm", "We chose pnpm", or overly vague titles like "Tooling decisions"
57
57
 
58
- ### Phase 4: Research Related XDRs
58
+ ### Phase 4: Research Related Policies
59
59
 
60
- 1. Read all existing XDRs relevant to the topic across all scopes listed in the XDR root `index.md`.
61
- 2. Evaluate XDR metadata before treating any decision as a current constraint. All documents present in the collection are considered active. `valid-from:` determines the convergence date for adoption, `apply-to:` determines whether it fits the current topic, and the decision text defines any remaining boundaries. Treat out-of-window or out-of-scope XDRs as background only when assessing overlaps and conflicts.
60
+ 1. Read all existing Policies relevant to the topic across all scopes listed in the Policy root `index.md`.
61
+ 2. Evaluate Policy metadata before treating any decision as a current constraint. All documents present in the collection are considered active. `valid-from:` determines the convergence date for adoption, `apply-to:` determines whether it fits the current topic, and the decision text defines any remaining boundaries. Treat out-of-window or out-of-scope Policies as background only when assessing overlaps and conflicts.
62
62
  3. Identify decisions that already address the topic (full or partial overlap).
63
63
  4. Note decisions that might conflict with the intended outcome.
64
64
  5. Read related `researches/` documents when they exist, especially if they contain constraints, findings, or option tradeoffs that should influence the decision.
65
- 6. Collect XDR IDs and file paths for cross-references.
65
+ 6. Collect Policy IDs and file paths for cross-references.
66
66
 
67
67
  ### Phase 5: Check Redundancy Across Related Artifacts
68
68
 
69
- 1. Review the related XDRs, research documents, skills, articles, and guides connected to the same decision thread.
69
+ 1. Review the related Policies, research documents, skills, articles, and guides connected to the same decision thread.
70
70
  2. Identify content that is repeated across those files, especially decision statements, applicability boundaries, mandatory rules, and rationale.
71
- 3. Prioritize the final decision, core boundaries, and short key instructions in the XDR itself.
71
+ 3. Prioritize the final decision, core boundaries, and short key instructions in the Policy itself.
72
72
  4. When another document already explains details well, link to it instead of re-explaining the same content in full.
73
- 5. Copy only short instructions or key excerpts when they materially help a reader apply the decision without leaving the XDR.
73
+ 5. Copy only short instructions or key excerpts when they materially help a reader apply the decision without leaving the Policy.
74
74
  6. Avoid repeating the same decision text across multiple related documents whenever a link or short reference is enough.
75
75
 
76
76
  ### Phase 6: Write the First Draft
77
77
 
78
- Use the mandatory template from `002-xdr-standards`:
78
+ Use the mandatory template from `002-policy-standards`:
79
79
 
80
80
  **Check if the decision requires a structured set of rules:**
81
- If the decision defines strong rules or policies that must be stated explicitly, or if other documents, skills, or agents have a clear need to reference individual rules, you MUST apply the structured rule format from `_core-adr-008-xdr-standards-structured`. This means:
81
+ If the decision defines strong rules or policies that must be stated explicitly, or if other documents, skills, or agents have a clear need to reference individual rules, you MUST apply the structured rule format from `_core-adr-policy-008-policy-standards-structured`. This means:
82
82
  - Place each rule as a numbered heading block inside `### Details`.
83
83
  - Use the format:
84
84
  #### [NN]-[short-descriptive-title-in-kebab-case]
85
85
  [Rule body with mandatory/advisory language.]
86
86
  - Ensure each rule is uniquely numbered (two digits, zero-padded) and never reuse numbers if a rule is removed.
87
- - Other documents must cite rules using the canonical dot-notation: `[xdr-name].[NN-short-descriptive-title-in-kebab-case]`.
87
+ - Other documents must cite rules using the canonical dot-notation: `[policy-name].[NN-short-descriptive-title-in-kebab-case]`.
88
88
 
89
89
  **Example of a structured set of rules:**
90
90
 
@@ -101,7 +101,7 @@ Access logs must be retained for at least 90 days and reviewed monthly for suspi
101
101
  All external integrations should be reviewed annually for compliance with current security standards.
102
102
  ```
103
103
 
104
- Refer to `_core-adr-008-xdr-standards-structured` for full requirements and citation syntax.
104
+ Refer to `_core-adr-policy-008-policy-standards-structured` for full requirements and citation syntax.
105
105
 
106
106
  ```
107
107
  ---
@@ -135,14 +135,14 @@ Mandatory rules to apply while drafting:
135
135
  - Include frontmatter `apply-to:` only when it adds value by narrowing the decision scope; omit it when the decision applies broadly.
136
136
  - Include frontmatter `valid-from:` only when there is a specific future enforcement date; omit it when the decision is immediately effective.
137
137
  - Keep `apply-to:` under 40 words and use `valid-from:` only with `YYYY-MM-DD` ISO format.
138
- - When frontmatter metadata is present, write it so a reader can decide whether the XDR should be used for the current case without guessing. `valid-from:` sets a convergence date for adoption, `apply-to:` narrows the contexts where the decision applies, and the decision text defines any remaining boundaries.
138
+ - When frontmatter metadata is present, write it so a reader can decide whether the Policy should be used for the current case without guessing. `valid-from:` sets a convergence date for adoption, `apply-to:` narrows the contexts where the decision applies, and the decision text defines any remaining boundaries.
139
139
  - Use mandatory language ("must", "always", "never") only for hard requirements; use advisory language ("should", "recommended") for guidance.
140
- - Do not duplicate content already in referenced XDRs — link instead.
141
- - Keep the decision itself authoritative in the XDR. Supporting artifacts may elaborate, but they should not restate the full decision when a short reference is enough.
140
+ - Do not duplicate content already in referenced Policies — link instead.
141
+ - Keep the decision itself authoritative in the Policy. Supporting artifacts may elaborate, but they should not restate the full decision when a short reference is enough.
142
142
  - Make clear when the decision applies and any important exception boundaries.
143
143
  - Keep exploratory option analysis in a related Research document when it would distract from the final decision text.
144
144
  - Prefer plain Markdown, tables, Mermaid.js (sequence, state, activity, entity diagrams), or ASCII art for simple structure, flow, layout, or relationship indications.
145
- - If the XDR genuinely needs local images or supporting files, store them in `.xdrs/[scope]/[type]/[subject]/.assets/` and link them using a same-folder relative path (e.g., `.assets/image.png`).
145
+ - If the Policy genuinely needs local images or supporting files, store them in `.xdrs/[scope]/[type]/[subject]/.assets/` and link them using a same-folder relative path (e.g., `.assets/image.png`).
146
146
  - Use relative paths for all links; never use absolute paths starting with `/`.
147
147
  - No emojis. Lowercase filenames.
148
148
  - Target under 1300 words total; under 2600 words for complex decisions.
@@ -152,23 +152,23 @@ Mandatory rules to apply while drafting:
152
152
  Check every item before finalizing:
153
153
 
154
154
  1. **Length**: Is it under 1300 words? Trim verbose explanations. Move detailed skills to a separate file and link.
155
- 2. **Frontmatter**: Are `apply-to:` and `valid-from:` present only when they add value, omitted entirely when not needed, and specific enough for a reader to decide whether the XDR is currently valid and applicable?
155
+ 2. **Frontmatter**: Are `apply-to:` and `valid-from:` present only when they add value, omitted entirely when not needed, and specific enough for a reader to decide whether the Policy is currently valid and applicable?
156
156
  3. **Originality**: Does every sentence add value that cannot be found in a generic web search? Remove obvious advice. Keep only the project-specific decision.
157
157
  4. **Clarity**: Is the chosen option unambiguous? Is the "why" clear in one reading?
158
- 5. **Redundancy**: Is the XDR the primary source for the decision itself, with related documents linked instead of duplicated wherever possible?
158
+ 5. **Redundancy**: Is the Policy the primary source for the decision itself, with related documents linked instead of duplicated wherever possible?
159
159
  6. **Conflicts section**: Is it present and filled if Phase 3 found any conflicts?
160
- 7. **Index entries**: Will the new XDR be added to `[scope]/[type]/index.md` and the XDR root `index.md`?
160
+ 7. **Index entries**: Will the new Policy be added to `[scope]/[type]/index.md` and the Policy root `index.md`?
161
161
 
162
162
  If any check fails, revise and re-run this phase before proceeding.
163
163
 
164
164
  ### Phase 8: Write Files
165
165
 
166
- 1. Create the XDR file at `[xdrs-root]/[scope]/[type]/[subject]/[number]-[short-title].md` (default root: `.xdrs/`).
166
+ 1. Create the Policy file at `[xdrs-root]/[scope]/[type]/[subject]/[number]-[short-title].md` (default root: `.xdrs/`).
167
167
  2. Add an entry to `[xdrs-root]/[scope]/[type]/index.md` (create the file if it does not exist).
168
- 3. Add or verify the scope entry in the XDR root `index.md`.
169
- 4. If significant research was produced or already exists, link it from the XDR `## Considered Options` section.
170
- 5. If concise rules, examples, or do/don't bullets help readers apply the decision correctly, add them inside `### Details` without turning the XDR into a long procedure.
171
- 6. Evaluate whether the scope index at `[xdrs-root]/[scope]/index.md` should be updated to reflect the new content. If the scope index does not exist, create it following article standards and the scope index rules in `_core-adr-001`.
168
+ 3. Add or verify the scope entry in the Policy root `index.md`.
169
+ 4. If significant research was produced or already exists, link it from the Policy `## Considered Options` section.
170
+ 5. If concise rules, examples, or do/don't bullets help readers apply the decision correctly, add them inside `### Details` without turning the Policy into a long procedure.
171
+ 6. Evaluate whether the scope index at `[xdrs-root]/[scope]/index.md` should be updated to reflect the new content. If the scope index does not exist, create it following article standards and the scope index rules in `_core-adr-policy-001`.
172
172
 
173
173
  ### Phase 9: Verify Package structure with Lint
174
174
 
@@ -181,16 +181,16 @@ If any check fails, revise and re-run this phase before proceeding.
181
181
 
182
182
  ### Constraints
183
183
 
184
- - MUST follow the XDR template from `002-xdr-standards` exactly.
185
- - MUST consult `001-xdrs-core` as the canonical source for element definitions (type, scope, subject, ID, numbering, naming, placement) and `002-xdr-standards` for document writing rules and template.
184
+ - MUST follow the Policy template from `002-policy-standards` exactly.
185
+ - MUST consult `001-xdrs-core` as the canonical source for element definitions (type, scope, subject, ID, numbering, naming, placement) and `002-policy-standards` for document writing rules and template.
186
186
  - MUST NOT add personal opinions or general best-practice content not tied to a decision.
187
- - MUST NOT create an XDR that duplicates a decision already captured in another XDR — extend or reference instead.
187
+ - MUST NOT create a Policy that duplicates a decision already captured in another Policy — extend or reference instead.
188
188
  - MUST prefer links and short references over repeating the same decision content across related documents.
189
189
  - MUST keep scope `_local` unless the user explicitly states otherwise.
190
190
  - MUST NOT create documents in external scopes (scopes whose files appear in the workspace root `.filedist`).
191
191
 
192
192
  ## References
193
193
 
194
- - [_core-adr-001 - XDRs core](../../001-xdrs-core.md)
195
- - [_core-adr-002 - XDR standards](../../002-xdr-standards.md)
196
- - [_core-adr-003 - Skill standards](../../003-skill-standards.md)
194
+ - [_core-adr-policy-001 - XDRS core](../../001-xdrs-core.md)
195
+ - [_core-adr-policy-002 - Policy standards](../../002-policy-standards.md)
196
+ - [_core-adr-policy-003 - Skill standards](../../003-skill-standards.md)