docs: verify build output in the build, not by parsing it - #98
Merged
Conversation
Adds a Testing section to the code styleguide: an invariant about a build artifact belongs in the build, where it cannot be violated, rather than in a test that inspects the artifact afterwards, where it can only be detected. Tests that use a built artifact stay fine; tests that parse one do not. Folds in the related rule that a test needing a new parser dependency is a test in the wrong place, and uses the dist/prompts.js import-graph scan as the worked example. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Jwc9FFroR3mTZ4hLiSkkX3
Both styleguide pointers in the Code Standards section referenced .claude/, where neither file exists; the same document already links .conventions/STYLEGUIDE-CODE.md correctly under Code Quality Checks. Repoints both at .conventions/. Also drops the File Naming Conventions line: .claude/FILE-CONVENTIONS.md does not exist and nothing in the repo serves that role, so the instruction resolved to nothing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Jwc9FFroR3mTZ4hLiSkkX3
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates repository documentation to establish and clarify conventions around testing build artifacts, and to remove stale/incorrect references in contributor guidance.
Changes:
- Adds a new Testing section to
.conventions/STYLEGUIDE-CODE.mdrecommending enforcing build-artifact invariants inside the build (and avoiding tests that parse generated output). - Updates
CLAUDE.mdto point “Code Standards” links at the existing.conventions/style guides and removes a dead reference to a non-existent file-naming conventions doc.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
CLAUDE.md |
Fixes “Code Standards” links to reference the actual .conventions/ guides; removes a dead .claude/ reference. |
.conventions/STYLEGUIDE-CODE.md |
Documents a new testing convention: enforce build-output invariants at build time rather than regex/parsing generated artifacts. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Gives a complete self-contained example for the conventions doc Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two documentation changes, one commit each.
1. New convention: verify build output in the build (
.conventions/STYLEGUIDE-CODE.md)A new Testing section, stating the rule in three parts:
Folded in is the rule that prompted this: do not add a dependency in order to test an assertion. A test that needs a parser to make sense of an artifact is a test in the wrong place.
Worked example (the real case)
packages/cli/test/prompts.test.tsasserted that the builtdist/prompts.jschunk graph never reaches the CLI entry or a host capability, by regex-scanning the built JavaScript forfrom "…"to reconstruct the import graph. A built chunk embeds every help recipe as a string literal, and theengine-selectionrecipe contains the phrasea different axis from "which engine"— so the scan reporteddist/prompts.js graph imports which engine. Prose read as an import.The rejected fixes are in the section as a table:
differs from "static-tier"is a bare hyphenated name with no whitespace and would still have been reported. The guard held by luck of punctuation.es-module-lexerparsed the graph correctly but bought a dependency — and a second major version, since vite already pulls 1.7.0 transitively — to serve a single test.fromon the same line asimport. A future bundler wrapping a long import would silently stop detecting real imports — trading a loud false positive for a quiet false negative, in the guard whose entire job is catching a leak.The resolution: rollup's
OutputChunkalready exposesimportsanddynamicImports— the exact resolved graph. The check moves into a vite plugin that fails the build, and the test is deleted.The section generalizes past the anecdote: the same reasoning forbids a YAML parser to assert on generated config, or an HTML parser to assert on rendered output. In each case the generator knows the answer and the test is guessing at it.
This PR documents the convention only — no code changes.
2. Please look at this separately: a dead instruction removed from
CLAUDE.mdThe top Code Standards section pointed at three files under
.claude/. None of the three exist. The same document already links@.conventions/STYLEGUIDE-CODE.mdcorrectly further down under Code Quality Checks, soCLAUDE.mdcontradicted itself about where the guide lives.@.claude/STYLEGUIDE-CODE.md(missing)@.conventions/STYLEGUIDE-CODE.md@.claude/STYLEGUIDE-UI.md(missing)@.conventions/STYLEGUIDE-UI.md@.claude/FILE-CONVENTIONS.md(missing)The removed line is the one worth a look. Searching the repo for any file serving a file-naming-conventions role turned up nothing — the only occurrence of the string
FILE-CONVENTIONSanywhere is that dangling reference itself. Rather than invent the file, the line is deleted; authoring a new one is out of scope here. This was raised with the repo owner and the removal is a decision already taken, recorded here so it is visible in review rather than silent in a diff. If a file-naming convention should exist, it wants its own PR.Checks
pnpm lintpasses; prettier ran via lint-staged. Markdown only — nothing underpackages/,openspec/, or.changeset/is touched, henceskip-changeset.🤖 Generated with Claude Code
https://claude.ai/code/session_01Jwc9FFroR3mTZ4hLiSkkX3