You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(claude): keep documented command frontmatter on .claude/commands (#3067) - #4910
Supersedes #3748 by Abhishek Acharya (@abhishekacharya200) (credited via Co-authored-by on both commits). The fork branch could not be updated from here (the merge with main touches workflow files), so the contributor's commit is cherry-picked onto main and the review is folded on top.
On the claude target, .claude/commands/*.md now keeps the frontmatter Claude Code documents for command files: when_to_use, disable-model-invocation, user-invocable, disallowed-tools, effort, context, agent, background, shell, and an authored arguments when there is no input:. Inline hooks stay withheld with a warning (tracked in #3227). name and paths are still dropped. Cursor/Grok output is unchanged.
Copilot review fold: an authored input: (empty, whitespace-only or fully rejected) still wins over arguments.
Copilot review fold: the "Mapped input -> command arguments" note uses the explicit mapping result, so an authored arguments: [issue, 7] or arguments: 7 is no longer joined (TypeError) or reported as mapped.
Copilot review fold: the withheld-hooks warning also fires when an existing command is retained (adopted or receipted-unchanged), so a source that only gains hooks: is never kept silently; a retained command with malformed frontmatter reports a per-file warning instead of aborting the run.
Docs moved with main's redesign: producer/write-primitives.md; apm-guide package-authoring.md updated.
Red-first: TestClaudeNativeCommandFrontmatter has 3 tests failing on main (native keys, authored arguments, hooks warning) and 6 failing on the #3748 head (input precedence x3, non-string arguments x2, adopt on reinstall), plus 3 retain-path tests (hooks warning x2, malformed frontmatter) that fail without the last fold; all 15 pass here.
uv run --extra dev pytest -q tests/unit/integration/test_command_integrator.py tests/integration/test_command_integrator_hermetic.py -- 130 passed
uv run --extra dev pytest -q tests/integration/test_architecture_owner_rule_mutations.py -- 1306 passed
uv run --extra dev pytest -q tests/quality -- 665 passed
29 test files touching CommandIntegrator / .claude/commands -- 974 passed, 3 failed (test_local_single_file_matrix.py::test_failed_source_preserves_owned_output[unreadable-*]; environmental: run as root, chmod 0 is not enforced; also fails for agents/instructions this PR does not touch)
changelog_fragments.py check and check-unreleased --base-ref origin/main -- pass
Changelog
One fragment per section, changelog.d/<pr>.<section>.md, holding
one line: user-visible effect first, 25 words or fewer, ending with (#PR); breaking changes only under upgrade notes; no Highlights; no
new lines under ## [Unreleased]. See changelog.d/README.md and .github/instructions/changelog.instructions.md.
…3067)
Claude Code documents that command files accept the skill frontmatter except name and paths, but the command transform kept only description, allowed-tools, model, argument-hint and input. On the claude target it now also keeps when_to_use, disable-model-invocation, user-invocable, disallowed-tools, effort, context, agent, background, shell, and an authored arguments when there is no input. Inline hooks stay withheld with their own warning until they go through executable consent. Cursor and Grok output is unchanged.
Cherry-picked from 9db3413 (#3748, by @abhishekacharya200) onto main;
the dropped-key notice follows #4182 (verbose info), and the deleted
author-primitives doc pages are ported in the next commit.
Co-authored-by: abhishekacharya200 <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
- An authored input (even empty, whitespace or fully rejected) now wins
over arguments, as documented.
- The input -> arguments note uses the explicit mapping result, so an
authored arguments is never joined (no TypeError on non-string items)
or reported as mapped.
- The adopt check renders with the target name, so a Claude command
carrying native keys is adopted on reinstall instead of colliding.
- Port docs to producer/write-primitives.md; add changelog.d fragment.
Co-authored-by: abhishekacharya200 <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The changelog fragment’s incorrect trailing PR number blocks validation and release assembly, while the missing hook-adoption warning and stale mutation-test anchor remain unresolved.
- An adopted Claude command (identical bytes already on disk) now repeats
the withheld-hooks warning instead of keeping it silently.
- Update the render-then-adopt mutation anchor for the target-aware call.
- Shorten the changelog fragment to the 25-word limit.
Co-authored-by: abhishekacharya200 <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
A receipt-backed skip bypasses the withheld-hooks warning when a command gains only hooks, silently retaining the hook-free command and leaving that path without regression coverage.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Warn when matching receipts skip commands with withheld hooks
If an installed command's source gains only hooks:, its rendered bytes stay unchanged, and a matching deployment receipt makes BaseIntegrator._check_adopt_or_skip() return (True, False) (base_integrator.py:855-857). This bypasses the warning helper, silently retaining the hook-free command. Distinguish identical retained output from collision and planning skips through the base integrator, emit the withheld-hooks warning for that outcome too, and add a receipt-backed regression.
A receipted-unchanged skip also bypassed integrate_command(), so a
source that only gained hooks: kept the hook-free command silently.
Warn whenever the existing command is retained (the base integrator
tracks it in target_paths); collision skips and planning stay quiet.
apm-spec-waiver: Claude-target command frontmatter rendering only; no OpenAPM requirement changes.
Co-authored-by: abhishekacharya200 <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Malformed frontmatter can trigger an uncaught YAML error during command adoption, aborting remaining integrations instead of reporting a per-file diagnostic and continuing.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Catch YAML errors during source frontmatter reparsing
If an existing command contains the same malformed frontmatter as its source, _rendered_command() returns None and the adoption check can retain it by comparing raw bytes. This helper then reparses the source outside the per-file YAML error handler, aborting the remaining command integrations. Catch yaml.YAMLError here and report a per-file diagnostic so processing can continue.
#3067)
A command kept by a raw-bytes match with malformed frontmatter reparsed
the source outside the per-file YAML handler; catch it and warn.
apm-spec-waiver: Claude-target command frontmatter rendering only; no OpenAPM requirement changes.
Co-authored-by: abhishekacharya200 <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because an unpublished finding shows that rereading an adopted non-UTF-8 command can raise UnicodeDecodeError and halt processing of the remaining commands.
Copilot's last note (non-string frontmatter keys raise TypeError in the dropped-key sort) is pre-existing on main's write path, not introduced here; tracked in 4922 -> #4922. Head frozen at cc9454b.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because retained-command handling can incorrectly claim preserved hooks were removed and allow malformed metadata to abort the remaining batch.
Final Copilot round at 14b959c has no open threads. Its two notes are edge cases outside the fold criteria and are tracked as follow-ups: the retained-warning wording for kept user files that already have hooks (4930), and non-string frontmatter keys (#4922, already on main). CI is green except the inherited deployment_ledger.py file-length Lint red (fixed by #4878). Integration run 45118148868 passed. Head frozen.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The warning inaccurately implies retained user-edited commands lack hooks; it should say APM omits hooks from rendered output and leaves retained files unchanged.
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
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.
Description
Supersedes #3748 by Abhishek Acharya (@abhishekacharya200) (credited via
Co-authored-byon both commits). The fork branch could not be updated from here (the merge withmaintouches workflow files), so the contributor's commit is cherry-picked ontomainand the review is folded on top.On the
claudetarget,.claude/commands/*.mdnow keeps the frontmatter Claude Code documents for command files:when_to_use,disable-model-invocation,user-invocable,disallowed-tools,effort,context,agent,background,shell, and an authoredargumentswhen there is noinput:. Inlinehooksstay withheld with a warning (tracked in #3227).nameandpathsare still dropped. Cursor/Grok output is unchanged.Changes on top of #3748:
hooksnotice stays a[!]warning because the command behaves differently.input:(empty, whitespace-only or fully rejected) still wins overarguments.arguments: [issue, 7]orarguments: 7is no longer joined (TypeError) or reported as mapped.hookswarning also fires when an existing command is retained (adopted or receipted-unchanged), so a source that only gainshooks:is never kept silently; a retained command with malformed frontmatter reports a per-file warning instead of aborting the run.producer/write-primitives.md; apm-guidepackage-authoring.mdupdated.Issue and approved scope
Issue: Fixes #3067
Human scope-approval comment: #3067 (comment) (hook split: #3067 (comment))
Does this PR complete the issue, or what remains? It completes the non-hook metadata repair. Inline
hooksremain withheld and are tracked in #3227.Supersedes #3748.
Type of change
Testing
Red-first:
TestClaudeNativeCommandFrontmatterhas 3 tests failing onmain(native keys, authoredarguments, hooks warning) and 6 failing on the #3748 head (input precedence x3, non-stringargumentsx2, adopt on reinstall), plus 3 retain-path tests (hooks warning x2, malformed frontmatter) that fail without the last fold; all 15 pass here.uv run --extra dev pytest -q tests/unit/integration/test_command_integrator.py tests/integration/test_command_integrator_hermetic.py-- 130 passeduv run --extra dev pytest -q tests/integration/test_architecture_owner_rule_mutations.py-- 1306 passeduv run --extra dev pytest -q tests/quality-- 665 passedCommandIntegrator/.claude/commands-- 974 passed, 3 failed (test_local_single_file_matrix.py::test_failed_source_preserves_owned_output[unreadable-*]; environmental: run as root,chmod 0is not enforced; also fails for agents/instructions this PR does not touch)ruff check,ruff format --check(ruff 0.15.12), pylint R0801,scripts/lint-auth-signals.sh,check_complexity_ratchet.py --base-ref origin/main,python -m tests.quality.taxonomy --changed,lint_architecture_boundaries.py --root .-- all passchangelog_fragments.py checkandcheck-unreleased --base-ref origin/main-- passChangelog
changelog.d/<pr>.<section>.md, holdingone line: user-visible effect first, 25 words or fewer, ending with
(#PR); breaking changes only under upgrade notes; no Highlights; nonew lines under
## [Unreleased]. Seechangelog.d/README.mdand.github/instructions/changelog.instructions.md.Spec conformance (OpenAPM v0.1)
apm-spec-waiver: Claude-target command frontmatter rendering only; no OpenAPM requirement changes.