Commit 6852ca2
Add integration test for directive rule example fixtures (#274)
* Enforce bad/good/fixed examples for directive rules
Every rule that implements gensection.Directive (MDS019 catalog,
MDS021 include, MDS038 toc, MDS039 build) must ship bad/, good/,
and — when fixable — fixed/ example folders. A new integration test
in internal/integration/directive_examples_test.go walks rule.All()
and fails when any of those folders are missing or when bad/ has a
fix-able entry with no matching fixed/ counterpart. Non-fixable bad
fixtures (cycle detection, build validation) opt out via a
bad/.nofix sentinel file.
Backfills MDS019-catalog/fixed/ so the loop tests the catalog
fix path, and adjusts the MDS019 bad fixture so the post-fix
body satisfies the default-enabled blank-line-around-lists rule.
The markdown-audit skill (.claude/skills/markdown-audit/) now
points at these example folders as the single source of truth
for the <?catalog?> and <?include?> fix recipes. Check 6
(kind without schema) gains an inline-schema vs proto.md
section that links to the four MDS020 example flavors so the
audit reader picks the right shape per kind.
https://claude.ai/code/session_01K7ZGjbkxFHTdTekshbN3kP
* Add pattern/ folders showing authored→directive transformations
The bad/good folders under each rule test diagnostics —
bad/* must fire a diagnostic, good/* must pass all rules.
That layer is the wrong shape for "what does the
hand-maintained anti-pattern look like before someone
adopts this directive?", which is what the markdown-audit
skill needs to show users.
Each directive rule (MDS019 catalog, MDS021 include,
MDS038 toc, MDS039 build) now ships a separate
pattern/bad/ and pattern/good/ pair:
- pattern/bad — the user-authored Markdown someone would
write today without the directive (hand-maintained
index, duplicated section, hand-maintained TOC,
hand-maintained build output snippet).
- pattern/good — the same content rewritten with the
directive, plus any sibling files the directive needs.
The four directive rule READMEs grew a ## Pattern
section that <?include?>s the new fixtures. A new
directive-rule-readme kind (with proto at
internal/rules/directive-proto.md) layers a stricter
schema over rule-readme that requires that Pattern
section with Without/With subsections. Until kind-schema
composition lands (plan/156_kind-schema-composition.md),
the directive-rule-readme schema duplicates rule-readme's
structure and the four directive READMEs are excluded
from the rule-readme glob so only one schema resolves
per file.
TestDirectiveRulesHaveExamples now also requires
pattern/bad/*.md and pattern/good/*.md for every
gensection.Directive rule. The markdown-audit skill
patterns.md + SKILL.md point at pattern/ as the
canonical before/after pair.
https://claude.ai/code/session_01K7ZGjbkxFHTdTekshbN3kP
* Plan 157: catalog filter by front matter property
Files the use case (a "Directive rules" listing
inside internal/rules/index.md that selects on a
nature property) and the proposed surface (a
where: parameter on the catalog directive that
reuses the CUE expression matcher from
mdsmith list query).
https://claude.ai/code/session_01K7ZGjbkxFHTdTekshbN3kP
* Inline ## Pattern snippets in directive rule READMEs
Copilot flagged that <?include?> on pattern/bad and
pattern/good rewrote relative link targets so the
displayed paths (e.g. pattern/bad/data/alpha.md)
did not match the source files (data/alpha.md).
The rewrite is stable so mdsmith fix did not flag
the body as stale, but the cosmetic mismatch
confuses a reader trying to copy the snippet
verbatim.
Drop the include directives from the ## Pattern
sections. The snippets in each directive README
now match the source pattern/ files
character-for-character, and the prose points to
pattern/bad and pattern/good as the canonical
folders the integration test still enforces.
Also add bad/.nofix on MDS019 for the new dotdot.md
fixture from main (#275). The dotdot escape is a
validation-only diagnostic with no auto-fix.
https://claude.ai/code/session_01K7ZGjbkxFHTdTekshbN3kP
* Inline ## Examples snippets in MDS019 README
Copilot flagged that the <?include?> for bad/default.md
in the ## Examples section displayed paths with a `bad/`
prefix (`[data/alpha.md](bad/data/alpha.md)`), while the
source fixture uses `[data/alpha.md](data/alpha.md)`.
The displayed body IS what `mdsmith fix` produces — the
include rule's adjustLinks rewrites relative link
targets so they resolve from the host file's directory.
The body is stable, not stale.
But the cosmetic mismatch makes the example misleading,
and the row template `{filename}` placeholder gets the
same rewrite applied. Replace both <?include?> blocks
with inline snippets that match the fixture files
character-for-character; link to good/default.md and
bad/default.md by path for readers who want the source.
https://claude.ai/code/session_01K7ZGjbkxFHTdTekshbN3kP
* Add where: filter to catalog directive
Extend <?catalog?> with a `where:` parameter that
evaluates a CUE expression against each matched file's
parsed front matter, dropping non-matching files before
sort and render. Reuses the matcher from
internal/query/ so the catalog and `mdsmith list query`
accept the same grammar.
Invalid CUE expressions emit an MDS019 diagnostic on
the directive's opening line; missing fields and type
mismatches silently exclude the file, matching
list-query semantics.
Covers tasks 1, 5, and 6 from plan/157.
https://claude.ai/code/session_01K7ZGjbkxFHTdTekshbN3kP
* Add nature key to rule-readme schema and backfill READMEs
Add a required `nature` front-matter key to the rule-readme
schema (internal/rules/proto.md) and the directive-rule-readme
schema (internal/rules/directive-proto.md). The field labels
each rule's kind so the catalog directive can filter listings
by it. Allowed values: directive, generator, content, style,
structure.
Backfill `nature:` on every MDS rule README and add a fixture
under MDS020 (bad/nature-missing.md) that exercises the new
schema requirement.
Covers tasks 2 and 3 from plan/157.
https://claude.ai/code/session_01K7ZGjbkxFHTdTekshbN3kP
* Add Directive rules section to internal/rules/index.md
Uses the new catalog where: filter (plan 157
task 1) and the nature front-matter property
(plan 157 tasks 2 + 3) to surface a filtered
listing of just the four directive rules.
Closes the remaining acceptance criterion in
plan/157.
https://claude.ai/code/session_01K7ZGjbkxFHTdTekshbN3kP
* Use catalog where: filter in markdown-audit SKILL
Replace the hand-maintained list of four directive
rule pattern folders with a <?catalog?> directive
that selects every rule README with nature:
directive in its front matter. The list now stays
in sync with the rule catalog automatically — a
new directive rule starts showing up once its
README declares nature: directive.
https://claude.ai/code/session_01K7ZGjbkxFHTdTekshbN3kP
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 872435a commit 6852ca2
96 files changed
Lines changed: 1453 additions & 77 deletions
File tree
- .claude/skills/markdown-audit
- docs/guides/directives
- editors/claude-code-audit/skills/markdown-audit
- internal
- integration
- rules
- MDS001-line-length
- MDS002-heading-style
- MDS003-heading-increment
- MDS004-first-line-heading
- MDS005-no-duplicate-headings
- MDS006-no-trailing-spaces
- MDS007-no-hard-tabs
- MDS008-no-multiple-blanks
- MDS009-single-trailing-newline
- MDS010-fenced-code-style
- MDS011-fenced-code-language
- MDS012-no-bare-urls
- MDS013-blank-line-around-headings
- MDS014-blank-line-around-lists
- MDS015-blank-line-around-fenced-code
- MDS016-list-indent
- MDS017-no-trailing-punctuation-in-heading
- MDS018-no-emphasis-as-heading
- MDS019-catalog
- bad
- fixed
- data
- good
- where-data
- pattern
- bad
- data
- good
- data
- MDS020-required-structure
- bad
- MDS021-include
- bad
- pattern
- bad
- good
- snippets
- MDS022-max-file-length
- MDS023-paragraph-readability
- MDS024-paragraph-structure
- MDS025-table-format
- MDS026-table-readability
- MDS027-cross-file-reference-integrity
- MDS028-token-budget
- MDS029-conciseness-scoring
- MDS030-empty-section-body
- MDS031-unclosed-code-block
- MDS032-no-empty-alt-text
- MDS033-directory-structure
- MDS034-markdown-flavor
- MDS035-toc-directive
- MDS036-max-section-length
- MDS037-duplicated-content
- MDS038-toc
- pattern
- bad
- good
- MDS039-build
- bad
- pattern
- bad
- good
- MDS040-recipe-safety
- MDS041-no-inline-html
- MDS042-emphasis-style
- MDS043-no-reference-style
- MDS044-horizontal-rule-style
- MDS045-list-marker-style
- MDS046-ordered-list-numbering
- MDS047-ambiguous-emphasis
- MDS048-git-hook-sync
- MDS049-no-space-in-link-text
- MDS050-proper-names
- MDS051-single-h1
- MDS052-no-space-in-code-spans
- MDS053-no-unused-link-definitions
- MDS054-no-undefined-reference-labels
- catalog
- plan
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
119 | 143 | | |
120 | 144 | | |
121 | 145 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
157 | 154 | | |
158 | 155 | | |
159 | 156 | | |
| |||
211 | 208 | | |
212 | 209 | | |
213 | 210 | | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
235 | 271 | | |
236 | 272 | | |
237 | 273 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
| 261 | + | |
261 | 262 | | |
262 | 263 | | |
263 | 264 | | |
| |||
290 | 291 | | |
291 | 292 | | |
292 | 293 | | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
293 | 298 | | |
294 | 299 | | |
295 | 300 | | |
| |||
391 | 396 | | |
392 | 397 | | |
393 | 398 | | |
394 | | - | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
395 | 405 | | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
396 | 418 | | |
397 | 419 | | |
398 | 420 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
| 88 | + | |
87 | 89 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
110 | 138 | | |
111 | 139 | | |
112 | 140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
123 | 148 | | |
124 | 149 | | |
125 | 150 | | |
| |||
0 commit comments