Skip to content

fix(claude): keep documented command frontmatter on .claude/commands (#3067) - #3748

Closed
Abhishek Acharya (abhishekacharya200) wants to merge 2 commits into
microsoft:mainfrom
abhishekacharya200:fix/claude-command-frontmatter-keys
Closed

Abhishek Acharya (abhishekacharya200) wants to merge 2 commits into
microsoft:mainfrom
abhishekacharya200:fix/claude-command-frontmatter-keys

Conversation

@abhishekacharya200

Copy link
Copy Markdown
Contributor

Description

Installing a prompt for Claude dropped command frontmatter that Claude Code supports. The command transform kept only description, allowed-tools, model, argument-hint and input, so the repro in #3067 (disable-model-invocation, when_to_use, effort) ended up as a warning and a .claude/commands/p.md with only description.

Claude Code documents that a command file "accepts the same fields except name and paths" (frontmatter reference). On the claude target the command now also keeps when_to_use, disable-model-invocation, user-invocable, disallowed-tools, effort, context, agent, background and shell, plus an authored arguments when there is no input: (input: still wins when both are set).

  • hooks is still withheld, as decided on the issue, now with its own warning saying Claude Code supports it but APM does not yet run frontmatter hooks through executable consent, so the command may not behave as authored. Hook support is tracked in [FEATURE] Harness-specific consent for frontmatter hooks (Claude-first) #3227.
  • name and paths are still dropped with the existing warning.
  • Cursor and Grok use the same transform and their output is unchanged.
  • metadata, license and compatibility are still dropped, since Claude Code accepts them but doesn't act on them. Happy to keep them too if you prefer.

Docs (prompts, hooks-and-commands, apm-guide) and CHANGELOG are updated.

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 hooks remain withheld and are tracked in #3227.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally

  • All existing tests pass

  • Added tests for new functionality (if applicable)

  • New TestClaudeNativeCommandFrontmatter in tests/unit/integration/test_command_integrator.py: documented keys kept on Claude, authored arguments, input precedence, name/paths dropped, hooks withheld warning, Cursor output unchanged. 3 of them fail on main.

  • test_command_integrator.py and tests/integration/test_command_integrator_hermetic.py: 121 passed. Wider install/integration unit runs show no new failures (the existing Windows symlink failures are the same on main).

  • ruff check, ruff format --check, pylint R0801 and lint_architecture_boundaries.py pass.

Spec conformance (OpenAPM v0.1)

  • N/A -- this PR does not change OpenAPM-observable behaviour.

…icrosoft#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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Authored arguments can trigger uncaught TypeErrors that abort integration when diagnostics are enabled, and empty or rejected input incorrectly preserves arguments despite the required input precedence.

2 open issues
What changed in this PR

Repairs Claude command deployment so supported non-hook frontmatter survives APM’s prompt transformation, addressing #3067 while keeping hook consent work separate in #3227.

Changes:

  • Adds Claude-only metadata preservation and authored arguments passthrough.
  • Keeps inline hooks withheld with a dedicated consent warning, without changing other targets.
  • Adds regression tests and updates authoring documentation and the changelog.
File Description
tests/​unit/​integration/​test_command_integrator.py Tests Claude metadata, argument precedence, hook warnings, and unchanged Cursor output.
src/​apm_cli/​integration/​command_integrator.py Adds Claude-specific preservation rules and hook-withholding diagnostics.
packages/​apm-guide/​.apm/​skills/​apm-usage/​package-authoring.md Documents preserved fields and the inline-hook limitation.
docs/​src/​content/​docs/​producer/​author-primitives/​prompts.md Explains Claude command frontmatter handling.
docs/​src/​content/​docs/​producer/​author-primitives/​hooks-and-commands.md Updates command preservation guidance.
CHANGELOG.md Records the metadata repair and remaining hook limitation.

Review effort: Balanced

claude_metadata["arguments"] = input_names
if "argument-hint" not in claude_metadata:
claude_metadata["argument-hint"] = " ".join(f"<{name}>" for name in input_names)
elif is_claude and "arguments" in post.metadata:
claude_metadata["argument-hint"] = " ".join(f"<{name}>" for name in input_names)
elif is_claude and "arguments" in post.metadata:
# No 'input' mapping: keep the author's native Claude 'arguments'.
claude_metadata["arguments"] = post.metadata["arguments"]
@danielmeppiel

Copy link
Copy Markdown
Collaborator

Thank you Abhishek Acharya (@abhishekacharya200) for grounding this in the Claude Code frontmatter reference.

This PR links #3067, which has a current maintainer scope record (#3067 (comment)). Inline hooks stay tracked separately in #3227, as agreed on the issue.

Outstanding before human review:

  • Two automated review findings on src/apm_cli/integration/command_integrator.py have no reply yet. One is input: precedence when it is empty, whitespace-only or rejected. The other is a TypeError in diagnostics for non-string arguments.
  • The PR body nominates two approval comments for [BUG] Claude command transform drops frontmatter keys Claude Code supports on commands #3067. Keep only the current record linked above so the eligibility check can verify it. The older comment is not in the strict record format.
  • Rebase on main. It conflicts in command_integrator.py. Main's docs redesign (94382be) also removed producer/author-primitives/hooks-and-commands.md and prompts.md, so re-apply those doc notes where commands and prompts are now documented.

CI has not run on this fork head yet. A maintainer has to approve the workflow runs after you push.

This is a triage recommendation only, not merge approval.


Generated by autopilot-pr-triage-worker. This comment is AI-generated and may contain errors.

@danielmeppiel Daniel Meppiel (danielmeppiel) added triage/recommended Automated advice completed; not human scope approval. type/bug Something does not work as documented. area/multi-target Multi-target deploy spec, target directory creation, agent surface routing. pillar/consume Pillar: install any agent package into any harness, reproducibly labels Nov 21, 2026
@danielmeppiel

Copy link
Copy Markdown
Collaborator

Thanks again Abhishek Acharya (@abhishekacharya200). We'd like this fix in 0.38.0. On top of the triage notes above (rebase, the two open review findings, and the docs move), there is one new requirement since you opened the PR:

  • CHANGELOG.md no longer takes new [Unreleased] lines. Add the entry as a fragment, changelog.d/3748.fixed.md, holding your one line (see changelog.d/README.md). Keep your -- by @abhishekacharya200 credit, and end the line with (closes #3067, #3748).

Can you push a rebased head by Mon 2026-11-23? If you can't get to it in time, just say so: a maintainer will carry your commits forward in a follow-up PR with your authorship and a Co-authored-by trailer kept, so your work lands in 0.38.0 either way.


This comment is AI-generated on behalf of the 0.38 release team and may contain errors.

Copy link
Copy Markdown
Collaborator

Thanks Abhishek Acharya (@abhishekacharya200)! This branch conflicted with main and the fork could not be updated from our side (the merge touches workflow files), so your commit is carried forward in #4910 with Co-authored-by credit, plus the two Copilot review fixes and the #4182 merge. Superseded by #4910.

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Thanks Abhishek Acharya (@abhishekacharya200)! The branch couldn't be updated in place (the main merge touches workflow files), so this work continues in #4910, which keeps your commits and authorship. Closing in favor of #4910.

Abhishek Kapoor (kapoorsunny) pushed a commit to kapoorsunny/apm that referenced this pull request Nov 23, 2026
…icrosoft#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 (microsoft#3748, by @abhishekacharya200) onto main;
the dropped-key notice follows microsoft#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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/multi-target Multi-target deploy spec, target directory creation, agent surface routing. pillar/consume Pillar: install any agent package into any harness, reproducibly triage/recommended Automated advice completed; not human scope approval. type/bug Something does not work as documented.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Claude command transform drops frontmatter keys Claude Code supports on commands

3 participants