require-relative-agent-hook-cwd
Require Copilot custom-agent hook cwd values to stay relative to the repository root.
Rule catalog ID: R018
Targeted pattern scopeâ
.github/agents/**/*.agent.md
What this rule reportsâ
- agent-scoped hook entries whose
cwdvalue is empty - agent-scoped hook entries whose
cwdvalue is absolute, home-relative, or otherwise not repository-relative
Why this rule existsâ
VS Code documents hook cwd as a working directory path relative to the repository root. Absolute paths and empty values make hook execution less portable across developers and environments, and they drift away from the documented hook configuration format.
â Incorrectâ
---
description: Format files after editing
hooks:
PostToolUse:
- type: command
command: ./scripts/format.sh
cwd: C:\hooks
---
Format edited files after tool usage.
â Correctâ
---
description: Format files after editing
hooks:
PostToolUse:
- type: command
command: ./scripts/format.sh
cwd: scripts/hooks
---
Format edited files after tool usage.