Skip to main content

require-relative-repository-hook-cwd

Require repository hook cwd values to use repository-relative paths.

Rule catalog ID: R062

Targeted pattern scope​

  • .github/hooks/**/*.json

What this rule reports​

  • absolute or otherwise non-relative cwd values in hook definitions

Why this rule exists​

Repository hooks are meant to run against the checked-out repository. Repository-relative working directories are more portable than absolute paths and avoid machine-specific configuration.

❌ Incorrect​

{
"version": 1,
"hooks": {
"sessionStart": [{ "type": "command", "bash": "echo ready", "cwd": "/tmp" }]
}
}

✅ Correct​

{
"version": 1,
"hooks": {
"sessionStart": [{ "type": "command", "bash": "echo ready", "cwd": "scripts" }]
}
}

Further reading​