Skip to content

Commit f369ac4

Browse files
xiaolaiclaude[bot]claudeavifenesh
authored
fix: move prepare lifecycle hook to explicit setup-hooks script (#334)
* fix: move prepare lifecycle hook to explicit setup-hooks script npm's prepare hook runs on every `npm install` in any environment, causing the package to silently install git hooks into any consumer's repository without their explicit consent. This is unexpected behavior for a plugin package consumed by end users. Rename prepare to setup-hooks so contributors can opt in explicitly by running `npm run setup-hooks` after cloning, as now documented in CONTRIBUTING.md. Co-Authored-By: Claude Code <noreply@anthropic.com> * fix(hooks): remove pre-commit placeholder + address bot review - Remove pre-commit hook installation - it was just a no-op placeholder ('lib/ sync now handled by agent-core'), so installing it was pure redundancy. Only the pre-push hook (preflight + /enhance reminder + release tag validation) actually does anything. - CONTRIBUTING.md: replace em-dash with single dash per workspace rule; update text to reflect that only pre-push is installed now. - docs/ARCHITECTURE.md: update setup-hooks.js comment - was 'npm prepare' before xiaolai's PR; now correctly noted as manual. --------- Co-authored-by: claude[bot] <claude[bot]@users.noreply.github.com> Co-authored-by: Claude Code <noreply@anthropic.com> Co-authored-by: Avi Fenesh <aviarchi1994@gmail.com>
1 parent df582c8 commit f369ac4

4 files changed

Lines changed: 13 additions & 16 deletions

File tree

CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ PRs may receive AI-assisted reviews (Copilot, Claude, Gemini, Codex) at the owne
3131

3232
## Before You Start
3333

34+
### First-Time Setup
35+
36+
After cloning the repo, install git hooks manually:
37+
38+
```bash
39+
npm install
40+
npm run setup-hooks
41+
```
42+
43+
The `setup-hooks` script installs the pre-push hook into your local `.git/hooks/` (it runs preflight checks, an `/enhance` reminder, and release-tag validation). It does **not** run automatically on `npm install` - you must opt in.
44+
3445
### Multi-File Changes
3546

3647
For changes touching multiple files, **read the relevant checklist first**:

docs/ARCHITECTURE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ agentsys/
6363
│ └── maintain-cross-platform/ # Cross-platform compatibility skill
6464
│ └── SKILL.md
6565
├── scripts/
66-
│ ├── setup-hooks.js # Git hooks installer (npm prepare)
66+
│ ├── setup-hooks.js # Git hooks installer (manual: npm run setup-hooks)
6767
│ └── graduate-plugin.js # Extract a plugin to a new standalone repo
6868
├── docs/ # User documentation
6969
│ ├── CROSS_PLATFORM.md

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"detect": "node bin/dev-cli.js detect",
3939
"verify": "node bin/dev-cli.js verify",
4040
"version": "node scripts/stamp-version.js && git add -A",
41-
"prepare": "node bin/dev-cli.js setup-hooks"
41+
"setup-hooks": "node bin/dev-cli.js setup-hooks"
4242
},
4343
"repository": {
4444
"type": "git",

scripts/setup-hooks.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
#!/usr/bin/env node
22
/**
33
* Setup git hooks for development
4-
* - pre-commit: Placeholder (lib/ sync handled by agent-core CI)
54
* - pre-push: Runs preflight checks, /enhance reminder, release validation
65
*/
76

87
const fs = require('fs');
98
const path = require('path');
109

1110
const hookDir = path.join(__dirname, '..', '.git', 'hooks');
12-
const preCommitPath = path.join(hookDir, 'pre-commit');
1311
const prePushPath = path.join(hookDir, 'pre-push');
1412

15-
const preCommitHook = `#!/bin/sh
16-
# Pre-commit hook (lib/ sync now handled by agent-core)
17-
`;
18-
1913
const prePushHook = `#!/bin/sh
2014
# Pre-push validations:
2115
# 1. Run preflight checks (validators + gap checks)
@@ -135,14 +129,6 @@ function main() {
135129
return 0;
136130
}
137131

138-
try {
139-
fs.writeFileSync(preCommitPath, preCommitHook, { mode: 0o755 });
140-
console.log('Git pre-commit hook installed');
141-
} catch (err) {
142-
// Non-fatal - might not have write permissions
143-
console.warn('Could not install pre-commit hook:', err.message);
144-
}
145-
146132
try {
147133
fs.writeFileSync(prePushPath, prePushHook, { mode: 0o755 });
148134
console.log('Git pre-push hook installed (release tag validation)');

0 commit comments

Comments
 (0)