claude-dev-env 1.2.1 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agents/project-context-loader.md +1 -1
- package/bin/install.mjs +76 -0
- package/docs/PR_DESCRIPTION_GUIDE.md +95 -0
- package/hooks/blocking/block-main-commit.py +13 -1
- package/hooks/blocking/pr-description-enforcer.py +68 -43
- package/hooks/hooks.json +0 -20
- package/hooks/validation/mypy_validator.py +35 -0
- package/hooks/workflow/auto-formatter.py +40 -1
- package/package.json +8 -2
- package/skills/npm-creator/SKILL.md +7 -3
- package/skills/skill-writer/REFERENCE.md +160 -122
- package/skills/skill-writer/SKILL.md +131 -197
- package/LICENSE +0 -21
- package/README.md +0 -247
- package/hooks/blocking/docker-settings-guard.py +0 -44
- package/hooks/blocking/parallel-task-blocker.py +0 -69
- package/hooks/blocking/pyautogui-scroll-blocker.py +0 -74
- package/hooks/session/bulk-edit-reminder.py +0 -30
- package/hooks/session/code-rules-reminder.py +0 -97
- package/hooks/session/compact-context-reinject.py +0 -39
- package/hooks/session/hook-structure-context.py +0 -140
- package/hooks/validation/code-style-validator.py +0 -145
- package/hooks/validation/e2e-test-validator.py +0 -142
- package/skills/agent-prompt/SKILL.md +0 -102
- package/skills/prompt-generator/REFERENCE.md +0 -150
- package/skills/prompt-generator/SKILL.md +0 -154
package/README.md
DELETED
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
# claude-code-config
|
|
2
|
-
|
|
3
|
-
Consistent development standards for Claude Code across every repo. Install once, get TDD enforcement, code quality hooks, specialized agents, and battle-tested rules everywhere.
|
|
4
|
-
|
|
5
|
-
## Quick Start
|
|
6
|
-
|
|
7
|
-
### Prerequisites
|
|
8
|
-
|
|
9
|
-
- **Node.js 18+** (includes `npx`)
|
|
10
|
-
- **Python 3.8+** (for hook scripts)
|
|
11
|
-
- **Claude Code CLI** installed and working
|
|
12
|
-
|
|
13
|
-
### Install
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npx claude-dev-env
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
That's it. The installer will:
|
|
20
|
-
|
|
21
|
-
1. Detect your Python 3 command (`python3`, `python`, or `py -3`)
|
|
22
|
-
2. Copy 13 rules, 4 docs, 34 agents, 11 commands, and 14 skills to `~/.claude/`
|
|
23
|
-
3. Copy 90+ hook scripts to `~/.claude/hooks/`
|
|
24
|
-
4. Merge 31 hook groups into `~/.claude/settings.json` (preserves your existing hooks)
|
|
25
|
-
5. Write a manifest to `~/.claude/.claude-dev-env-manifest.json` for clean uninstall
|
|
26
|
-
|
|
27
|
-
### Verify
|
|
28
|
-
|
|
29
|
-
Start a new Claude Code session. You should see hook activity on your first prompt (code-rules-reminder, hook-structure-context). Run any slash command like `/commit` or `/readability-review` to confirm commands loaded.
|
|
30
|
-
|
|
31
|
-
### Update
|
|
32
|
-
|
|
33
|
-
Run the same command again. It overwrites existing files and updates hook entries in place:
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
npx claude-dev-env
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### Uninstall
|
|
40
|
-
|
|
41
|
-
Removes only the files this package installed (tracked via manifest) and cleans hook entries from `settings.json`:
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
npx claude-dev-env --uninstall
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## What This Solves
|
|
48
|
-
|
|
49
|
-
Without shared config, every repo needs its own `.claude/rules/`, `.claude/hooks/`, `.claude/agents/`, etc. That means:
|
|
50
|
-
|
|
51
|
-
- Duplicated config across 5+ repos
|
|
52
|
-
- Drift when you update standards in one place but forget others
|
|
53
|
-
- New repos start with zero guardrails
|
|
54
|
-
|
|
55
|
-
This package centralizes all general-purpose Claude Code config. Project-specific rules still live in each repo's `.claude/` directory and merge with these.
|
|
56
|
-
|
|
57
|
-
## What's Included
|
|
58
|
-
|
|
59
|
-
### Rules (13)
|
|
60
|
-
|
|
61
|
-
Behavioral rules loaded into every session. These shape how Claude approaches work before any code is written.
|
|
62
|
-
|
|
63
|
-
| Rule | What it does |
|
|
64
|
-
|------|-------------|
|
|
65
|
-
| `tdd` | Red-green-refactor is non-negotiable |
|
|
66
|
-
| `code-standards` | References CODE_RULES.md for all code generation |
|
|
67
|
-
| `conservative-action` | Research first, act only when explicitly asked |
|
|
68
|
-
| `right-sized-engineering` | Simple > clever, functions > classes, concrete > abstract |
|
|
69
|
-
| `explore-thoroughly` | Read before proposing, map patterns before committing |
|
|
70
|
-
| `research-mode` | Anti-hallucination: cite sources, say "I don't know", use direct quotes |
|
|
71
|
-
| `parallel-tools` | Independent tool calls run simultaneously |
|
|
72
|
-
| `agent-spawn-protocol` | Context sufficiency check before delegating to agents |
|
|
73
|
-
| `git-workflow` | Draft PRs, one commit per review stage, stacked PR patterns |
|
|
74
|
-
| `code-reviews` | Systematic PR review response protocol |
|
|
75
|
-
| `testing` | Complete mocks, reference TEST_QUALITY.md |
|
|
76
|
-
| `context7` | Fetch current docs via Context7 MCP instead of relying on training data |
|
|
77
|
-
| `cleanup-temp-files` | Remove scratch files after tasks complete |
|
|
78
|
-
|
|
79
|
-
### Docs (4)
|
|
80
|
-
|
|
81
|
-
Reference documents that rules and agents point to for detailed standards.
|
|
82
|
-
|
|
83
|
-
| Document | Coverage |
|
|
84
|
-
|----------|----------|
|
|
85
|
-
| `CODE_RULES.md` | Hook-enforced rules, naming conventions, config patterns, type hints, readability rubric |
|
|
86
|
-
| `TEST_QUALITY.md` | Test writing standards, mock completeness, assertion patterns |
|
|
87
|
-
| `REACT_PATTERNS.md` | Component architecture, hooks, state management conventions |
|
|
88
|
-
| `DJANGO_PATTERNS.md` | Model patterns, view architecture, ORM best practices |
|
|
89
|
-
|
|
90
|
-
### Agents (34)
|
|
91
|
-
|
|
92
|
-
Specialized agent prompts for common development tasks. Claude Code automatically discovers these and makes them available for delegation.
|
|
93
|
-
|
|
94
|
-
**Code Quality:** clean-coder, code-quality-agent, code-standards-agent, readability-review-agent, refactoring-specialist, right-sized-engineer
|
|
95
|
-
|
|
96
|
-
**Testing:** tdd-test-writer, test-data-builder, validation-expert
|
|
97
|
-
|
|
98
|
-
**Planning:** plan-executor, parallel-workflow-coordinator, mandatory-agent-workflow-agent, stub-detector-agent
|
|
99
|
-
|
|
100
|
-
**Documentation:** docs-agent, doc-orchestrator, user-docs-writer, project-docs-analyzer
|
|
101
|
-
|
|
102
|
-
**Configuration:** config-extraction-agent, config-centralizer, magic-value-eliminator-agent, project-structure-organizer-agent
|
|
103
|
-
|
|
104
|
-
**Tooling:** agent-writer, skill-writer-agent, skill-to-agent-converter, tooling-builder
|
|
105
|
-
|
|
106
|
-
**Git:** git-commit-crafter, pr-description-writer, session-continuity-manager
|
|
107
|
-
|
|
108
|
-
**File Formats:** docx-agent, pdf-agent, xlsx-agent
|
|
109
|
-
|
|
110
|
-
**Other:** clasp-deployment-orchestrator, workflow-visual-documenter, project-context-loader
|
|
111
|
-
|
|
112
|
-
### Commands (11)
|
|
113
|
-
|
|
114
|
-
Slash commands for common workflows.
|
|
115
|
-
|
|
116
|
-
| Command | Purpose |
|
|
117
|
-
|---------|---------|
|
|
118
|
-
| `/commit` | Structured git commit with conventional format |
|
|
119
|
-
| `/plan` | Create implementation plans with config search |
|
|
120
|
-
| `/implement` | Execute plans with TDD workflow |
|
|
121
|
-
| `/review-plan` | Review and critique implementation plans |
|
|
122
|
-
| `/readability-review` | 8-dimension readability scoring |
|
|
123
|
-
| `/right-size` | Check for over/under-engineering |
|
|
124
|
-
| `/stubcheck` | Find stubs, TODOs, and NotImplementedError |
|
|
125
|
-
| `/pr-comments` | Process PR review comments systematically |
|
|
126
|
-
| `/docupdate` | Update documentation after changes |
|
|
127
|
-
| `/initialize` | Session initialization with protocol review |
|
|
128
|
-
| `/sum` | Summarize current work context |
|
|
129
|
-
|
|
130
|
-
### Skills (14)
|
|
131
|
-
|
|
132
|
-
| Skill | Purpose |
|
|
133
|
-
|-------|---------|
|
|
134
|
-
| `prompt-generator` | Write, refine, and structure prompts for Claude with emotion-informed framing |
|
|
135
|
-
| `agent-prompt` | Craft structured agent prompts and spawn background agents after approval |
|
|
136
|
-
| `tdd-team` | Orchestrate a 4-agent TDD team (planner, tester, implementer, validator) |
|
|
137
|
-
| `pr-review-responder` | Systematic PR review response: fetch comments, checklist, fix, reply, commit |
|
|
138
|
-
| `anthropic-plan` | Readonly codebase exploration before code changes, produces a plan file |
|
|
139
|
-
| `readability-review` | 8-dimension readability scoring (160 pts) with automatic fixes |
|
|
140
|
-
| `ingest` | Digest codebase into LLM-friendly text files via gitingest |
|
|
141
|
-
| `npm-creator` | Scaffold npm installer packages for Claude Code plugin repos |
|
|
142
|
-
| `rule-audit` | Full enforcement audit of rules, hooks, and docs across user and project layers |
|
|
143
|
-
| `rule-creator` | Create and harden Claude Code rules with positive framing and rationale |
|
|
144
|
-
| `skill-writer` | Guide for creating well-structured Agent Skills |
|
|
145
|
-
| `everything-search` | Fast Windows file search via Everything (voidtools) es.exe |
|
|
146
|
-
| `recall` | Retrieve prior session context and decisions from Obsidian vault |
|
|
147
|
-
| `remember` | Save decisions, gotchas, and architectural choices to Obsidian vault |
|
|
148
|
-
|
|
149
|
-
### Hooks (31 registered, 70+ files)
|
|
150
|
-
|
|
151
|
-
Automated enforcement that runs on Claude Code events. The installer detects your Python 3 command and rewrites hook paths to absolute `~/.claude/hooks/` paths in `settings.json`.
|
|
152
|
-
|
|
153
|
-
#### PreToolUse (before tool execution)
|
|
154
|
-
|
|
155
|
-
| Matcher | Hook | What it does |
|
|
156
|
-
|---------|------|-------------|
|
|
157
|
-
| Write\|Edit | `write-existing-file-blocker` | Warns before overwriting files that should be edited |
|
|
158
|
-
| Write\|Edit | `sensitive-file-protector` | Blocks writes to .env, credentials, and sensitive files |
|
|
159
|
-
| Write\|Edit | `pyautogui-scroll-blocker` | Prevents pyautogui scroll direction bugs |
|
|
160
|
-
| Write\|Edit | `hook-format-validator` | Validates hook file format on write |
|
|
161
|
-
| Write\|Edit | `run_all_validators` | Runs the full validation suite (30+ checks) |
|
|
162
|
-
| Write\|Edit | `code-rules-enforcer` | Blocks CODE_RULES.md violations (comments, magic values, imports) |
|
|
163
|
-
| Write\|Edit | `tdd-enforcer` | Prompts TDD confirmation when writing production code |
|
|
164
|
-
| Write\|Edit | `code-style-validator` | Checks indentation and function spacing |
|
|
165
|
-
| Write\|Edit | `docker-settings-guard` | Blocks direct edits to Docker settings files |
|
|
166
|
-
| Edit | `refactor-guard` | Ensures refactoring happens only after green tests |
|
|
167
|
-
| Edit | `migration-safety-advisor` | Warns about risky database migration patterns |
|
|
168
|
-
| Bash | `destructive-command-blocker` | Blocks rm -rf, git reset --hard, and other destructive commands |
|
|
169
|
-
| Bash | `block-main-commit` | Blocks direct commits to main/master branch |
|
|
170
|
-
| Bash | `pr-description-enforcer` | Enforces PR description structure and style |
|
|
171
|
-
| Bash | `test-preflight-check` | Validates server health and database before test runs |
|
|
172
|
-
| Task\|Agent | `parallel-task-blocker` | Suggests team orchestration for parallel agent spawning |
|
|
173
|
-
| AskUserQuestion | `attention-needed-notify` | Desktop notification when Claude needs your input |
|
|
174
|
-
|
|
175
|
-
#### Other Events
|
|
176
|
-
|
|
177
|
-
| Event | Hook | What it does |
|
|
178
|
-
|-------|------|-------------|
|
|
179
|
-
| UserPromptSubmit | `hook-structure-context` | Injects hook directory context into session |
|
|
180
|
-
| UserPromptSubmit | `bulk-edit-reminder` | Suggests script-based approach for bulk updates |
|
|
181
|
-
| UserPromptSubmit | `code-rules-reminder` | Injects CODE_RULES.md reminder on code-related prompts |
|
|
182
|
-
| SessionStart (compact) | `compact-context-reinject` | Re-injects critical rules after context compaction |
|
|
183
|
-
| SessionStart | `plugin-data-dir-cleanup` | Cleans stale plugin data on session start |
|
|
184
|
-
| Stop | `attention-needed-notify` | Desktop notification when Claude stops |
|
|
185
|
-
| Stop | `hedging-language-blocker` | Blocks responses with hedging language (anti-hallucination) |
|
|
186
|
-
| SessionEnd | `session-end-cleanup` | Cleans temporary state on session end |
|
|
187
|
-
| ConfigChange | `config-change-guard` | Guards against accidental settings changes |
|
|
188
|
-
| PostToolUse (Write\|Edit) | `mypy_validator` | Runs mypy type checking after file writes |
|
|
189
|
-
| PostToolUse (Write\|Edit) | `e2e-test-validator` | Validates e2e test conventions after writes |
|
|
190
|
-
| PostToolUse (Write\|Edit) | `auto-formatter` | Auto-formats Python (ruff/black) and JS (prettier) on write |
|
|
191
|
-
| PostToolUse (Agent\|Task) | `investigation-tracker-reset` | Resets investigation tracker after delegation |
|
|
192
|
-
| Notification | `claude-notification-handler` | Routes Claude Code notifications to desktop |
|
|
193
|
-
|
|
194
|
-
#### Validators Module
|
|
195
|
-
|
|
196
|
-
The `hooks/validators/` directory contains 30+ individual check modules with a full test suite:
|
|
197
|
-
|
|
198
|
-
Abbreviations, code quality, comments, file structure, git conventions, magic values, mypy integration, PR references, Python antipatterns, Python style, React patterns, ruff integration, security, TODO tracking, type safety, useless test detection, and more.
|
|
199
|
-
|
|
200
|
-
## Also Available as a Plugin
|
|
201
|
-
|
|
202
|
-
If you prefer the Claude Code plugin system over npm:
|
|
203
|
-
|
|
204
|
-
```bash
|
|
205
|
-
claude plugin install jl-cmd/claude-code-config
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
## Recommended Companion Plugins
|
|
209
|
-
|
|
210
|
-
These plugins provide additional skills and capabilities that complement this config:
|
|
211
|
-
|
|
212
|
-
```bash
|
|
213
|
-
claude plugin install anthropics/claude-code-plugins # Official: frontend-design, code-review, playwright, hookify, skill-creator, claude-md-management, serena, pyright-lsp, typescript-lsp, claude-code-setup
|
|
214
|
-
claude plugin install anthropics/claude-code-workflows # Official: python-dev, ui-design, unit-testing, context-management, agent-teams, and more
|
|
215
|
-
claude plugin install jl-cmd/claude-journal # Session logging to Obsidian vault (provides /session-log)
|
|
216
|
-
claude plugin install jl-cmd/claude-deep-research # Deep multi-source research with citations
|
|
217
|
-
claude plugin install jl-cmd/claude-workflow # Workflow definitions with YAML schemas
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
GSD (project management) is available as an npm package:
|
|
221
|
-
```bash
|
|
222
|
-
npx get-shit-done-cc
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
## Customization
|
|
226
|
-
|
|
227
|
-
Installed rules merge with your project's `.claude/` config. To override a rule for a specific project, create a rule with the same filename in your project's `.claude/rules/` directory.
|
|
228
|
-
|
|
229
|
-
Installed hooks run alongside any hooks already in your `settings.json` or `settings.local.json`. The installer preserves existing hook entries.
|
|
230
|
-
|
|
231
|
-
## Agent Gate
|
|
232
|
-
|
|
233
|
-
For a prompt evaluation gate that reviews prompts before execution, see [agent-gate](https://github.com/jl-cmd/agent-gate):
|
|
234
|
-
|
|
235
|
-
```bash
|
|
236
|
-
npx agent-gate-installer
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
## Requirements
|
|
240
|
-
|
|
241
|
-
- Node.js 18+ (for the installer)
|
|
242
|
-
- Python 3.8+ (for hooks)
|
|
243
|
-
- Claude Code CLI
|
|
244
|
-
|
|
245
|
-
## License
|
|
246
|
-
|
|
247
|
-
MIT
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
PreToolUse hook: blocks direct edits to Docker settings files.
|
|
4
|
-
Hooks must be added to the Windows settings.json instead.
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
import json
|
|
8
|
-
import sys
|
|
9
|
-
|
|
10
|
-
BLOCKED_PATHS = [
|
|
11
|
-
"settings-docker.json",
|
|
12
|
-
"settings-docker",
|
|
13
|
-
"docker/settings-docker.json",
|
|
14
|
-
".claude/docker/settings-docker.json",
|
|
15
|
-
]
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def main() -> None:
|
|
19
|
-
try:
|
|
20
|
-
stdin_data = sys.stdin.read()
|
|
21
|
-
hook_input = json.loads(stdin_data)
|
|
22
|
-
tool_input = hook_input.get("tool_input", {})
|
|
23
|
-
file_path = tool_input.get("file_path", "")
|
|
24
|
-
|
|
25
|
-
for blocked in BLOCKED_PATHS:
|
|
26
|
-
if file_path.endswith(blocked):
|
|
27
|
-
message = "BLOCKED: Docker settings edit denied. Edit your user settings.json instead."
|
|
28
|
-
result = {
|
|
29
|
-
"hookSpecificOutput": {
|
|
30
|
-
"hookEventName": "PreToolUse",
|
|
31
|
-
"permissionDecision": "deny",
|
|
32
|
-
"permissionDecisionReason": message
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
print(json.dumps(result))
|
|
36
|
-
sys.exit(0)
|
|
37
|
-
except SystemExit:
|
|
38
|
-
raise
|
|
39
|
-
except Exception:
|
|
40
|
-
pass
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if __name__ == "__main__":
|
|
44
|
-
main()
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""PreToolUse:Task hook — suggests team orchestration for parallel Task spawning.
|
|
3
|
-
|
|
4
|
-
Detects parallel Task/Agent calls without team_name and injects a suggestion
|
|
5
|
-
into the conversation context. Does NOT block — the tool call proceeds.
|
|
6
|
-
|
|
7
|
-
Uses atomic file creation (O_CREAT | O_EXCL) to detect concurrent calls.
|
|
8
|
-
Lock auto-expires after 3 seconds to avoid false positives on sequential calls.
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
import json
|
|
12
|
-
import os
|
|
13
|
-
import sys
|
|
14
|
-
import tempfile
|
|
15
|
-
import time
|
|
16
|
-
|
|
17
|
-
LOCK_FILE = os.path.join(tempfile.gettempdir(), "claude-parallel-task-guard.lock")
|
|
18
|
-
LOCK_MAX_AGE_SECONDS = 3
|
|
19
|
-
|
|
20
|
-
SUGGESTION_MESSAGE = (
|
|
21
|
-
"SUGGESTION: Multiple parallel agents detected without team orchestration. "
|
|
22
|
-
"Consider using TeamCreate + team_name for better coordination, "
|
|
23
|
-
"progress tracking, and file ownership management. "
|
|
24
|
-
"This is optional — parallel agents will proceed without it."
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def main() -> None:
|
|
29
|
-
try:
|
|
30
|
-
input_data = json.load(sys.stdin)
|
|
31
|
-
except json.JSONDecodeError:
|
|
32
|
-
sys.exit(0)
|
|
33
|
-
|
|
34
|
-
tool_name = input_data.get("tool_name", "")
|
|
35
|
-
tool_input = input_data.get("tool_input", {})
|
|
36
|
-
|
|
37
|
-
if tool_name not in ("Task", "Agent"):
|
|
38
|
-
sys.exit(0)
|
|
39
|
-
|
|
40
|
-
# Team-orchestrated tasks — no suggestion needed
|
|
41
|
-
if tool_input.get("team_name"):
|
|
42
|
-
sys.exit(0)
|
|
43
|
-
|
|
44
|
-
# Clean stale locks (previous turn's lock that wasn't cleaned up)
|
|
45
|
-
try:
|
|
46
|
-
if os.path.exists(LOCK_FILE):
|
|
47
|
-
lock_age = time.time() - os.path.getmtime(LOCK_FILE)
|
|
48
|
-
if lock_age > LOCK_MAX_AGE_SECONDS:
|
|
49
|
-
os.unlink(LOCK_FILE)
|
|
50
|
-
except OSError:
|
|
51
|
-
pass # Race with another process cleaning — fine
|
|
52
|
-
|
|
53
|
-
# Atomic create: only one concurrent caller wins
|
|
54
|
-
try:
|
|
55
|
-
fd = os.open(LOCK_FILE, os.O_CREAT | os.O_EXCL | os.O_WRONLY)
|
|
56
|
-
os.write(fd, str(time.time()).encode())
|
|
57
|
-
os.close(fd)
|
|
58
|
-
# First Task in this turn — no suggestion
|
|
59
|
-
sys.exit(0)
|
|
60
|
-
except FileExistsError:
|
|
61
|
-
pass # Another Task already holds the lock
|
|
62
|
-
|
|
63
|
-
# Second+ parallel Task without team → suggest (not block)
|
|
64
|
-
print(SUGGESTION_MESSAGE, file=sys.stderr)
|
|
65
|
-
sys.exit(0)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if __name__ == "__main__":
|
|
69
|
-
main()
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
Block pyautogui mousewheel scroll usage - guide Claude to use pynput instead.
|
|
4
|
-
|
|
5
|
-
pyautogui's scroll implementation uses incorrect delta values with SendInput API.
|
|
6
|
-
pynput uses the same SendInput API but sends correct delta values.
|
|
7
|
-
"""
|
|
8
|
-
import json
|
|
9
|
-
import re
|
|
10
|
-
import sys
|
|
11
|
-
|
|
12
|
-
PYAUTOGUI_SCROLL_PATTERNS = [
|
|
13
|
-
r'pyautogui\.scroll\s*\(',
|
|
14
|
-
r'pyautogui\.hscroll\s*\(',
|
|
15
|
-
r'pyautogui\.vscroll\s*\(',
|
|
16
|
-
]
|
|
17
|
-
|
|
18
|
-
COMPILED_PATTERNS = [re.compile(pattern) for pattern in PYAUTOGUI_SCROLL_PATTERNS]
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def check_for_pyautogui_scroll(content: str) -> list[str]:
|
|
22
|
-
"""Check for pyautogui scroll function usage."""
|
|
23
|
-
violations = []
|
|
24
|
-
lines = content.split('\n')
|
|
25
|
-
|
|
26
|
-
for line_num, line in enumerate(lines, 1):
|
|
27
|
-
for pattern in COMPILED_PATTERNS:
|
|
28
|
-
if pattern.search(line):
|
|
29
|
-
violations.append(f"Line {line_num}: {line.strip()}")
|
|
30
|
-
break
|
|
31
|
-
|
|
32
|
-
return violations
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def main() -> None:
|
|
36
|
-
try:
|
|
37
|
-
input_data = json.load(sys.stdin)
|
|
38
|
-
except json.JSONDecodeError:
|
|
39
|
-
sys.exit(0)
|
|
40
|
-
|
|
41
|
-
tool_input = input_data.get("tool_input", {})
|
|
42
|
-
file_path = tool_input.get("file_path", "")
|
|
43
|
-
|
|
44
|
-
if not file_path:
|
|
45
|
-
sys.exit(0)
|
|
46
|
-
|
|
47
|
-
# Only check Python files
|
|
48
|
-
if not file_path.endswith('.py'):
|
|
49
|
-
sys.exit(0)
|
|
50
|
-
|
|
51
|
-
content = tool_input.get("content", "") or tool_input.get("new_string", "")
|
|
52
|
-
|
|
53
|
-
if not content:
|
|
54
|
-
sys.exit(0)
|
|
55
|
-
|
|
56
|
-
violations = check_for_pyautogui_scroll(content)
|
|
57
|
-
|
|
58
|
-
if violations:
|
|
59
|
-
violation_list = "\n".join(f" • {v}" for v in violations[:5])
|
|
60
|
-
result = {
|
|
61
|
-
"hookSpecificOutput": {
|
|
62
|
-
"hookEventName": "PreToolUse",
|
|
63
|
-
"permissionDecision": "deny",
|
|
64
|
-
"permissionDecisionReason": f"BLOCKED: pyautogui scroll() is broken on Windows (incorrect delta values). Use pynput instead: from pynput.mouse import Controller; mouse = Controller(); mouse.scroll(0, -3) for scrolling down 3 clicks."
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
print(json.dumps(result))
|
|
68
|
-
sys.stdout.flush()
|
|
69
|
-
|
|
70
|
-
sys.exit(0)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if __name__ == "__main__":
|
|
74
|
-
main()
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
import json
|
|
3
|
-
import sys
|
|
4
|
-
|
|
5
|
-
BULK_UPDATE_KEYWORDS = ["update all", "replace all", "change all", "fix all", "rename all"]
|
|
6
|
-
|
|
7
|
-
BULK_UPDATE_REMINDER = "BULK UPDATE DETECTED: Use a Python script with --preview/--apply instead of line-by-line edits."
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def main() -> None:
|
|
11
|
-
try:
|
|
12
|
-
input_data = json.load(sys.stdin)
|
|
13
|
-
except json.JSONDecodeError:
|
|
14
|
-
sys.exit(0)
|
|
15
|
-
|
|
16
|
-
prompt = input_data.get("prompt", "")
|
|
17
|
-
|
|
18
|
-
if not prompt:
|
|
19
|
-
sys.exit(0)
|
|
20
|
-
|
|
21
|
-
message_lower = prompt.lower()
|
|
22
|
-
|
|
23
|
-
if any(keyword in message_lower for keyword in BULK_UPDATE_KEYWORDS):
|
|
24
|
-
print(BULK_UPDATE_REMINDER)
|
|
25
|
-
|
|
26
|
-
sys.exit(0)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if __name__ == "__main__":
|
|
30
|
-
main()
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
UserPromptSubmit hook that detects code-related requests and injects CODE_RULES.md reminder.
|
|
4
|
-
Triggers on keywords indicating code writing, planning, or implementation.
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
import json
|
|
8
|
-
import re
|
|
9
|
-
import sys
|
|
10
|
-
|
|
11
|
-
CODE_KEYWORDS = [
|
|
12
|
-
# Creation verbs
|
|
13
|
-
r'\b(write|create|implement|add|build|make|generate|develop|setup|scaffold|bootstrap|initialize|init|compose|construct|define|declare|register|wire|connect|integrate|introduce)\b',
|
|
14
|
-
# Code nouns
|
|
15
|
-
r'\b(code|function|class|method|script|module|component|hook|test|spec|api|endpoint|route|handler|service|util|helper|factory|interface|type|enum|constant|variable|parameter|argument|logic|algorithm|feature|library|package|dependency|plugin|extension|widget|element|node|token|parser|serializer|validator|formatter|linter|compiler|transpiler|bundler|loader|resolver|provider|consumer|producer|subscriber|publisher|emitter|dispatcher|reducer|selector|adapter|wrapper|decorator|mixin|trait|protocol|abstract|generic|iterator|generator|coroutine|fiber|thread|process|worker|job|task|queue|stack|buffer|stream|pipe|socket|channel|signal|slot|observer|mediator|strategy|command|visitor|singleton|repository|gateway|mapper|transformer|converter|encoder|decoder|interceptor|guard|filter|middleware|pipeline|chain|proxy|facade|bridge|flyweight|memento|prototype)\b',
|
|
16
|
-
# Modification verbs
|
|
17
|
-
r'\b(fix|update|refactor|modify|change|edit|rewrite|improve|enhance|optimize|debug|patch|correct|adjust|tweak|rework|revise|extend|expand|rename|move|extract|inline|split|merge|combine|consolidate|simplify|clean|cleanup|reorganize|restructure|decouple|encapsulate|abstract|generalize|specialize|upgrade|downgrade|migrate|convert|transform|adapt|port|backport)\b',
|
|
18
|
-
# Deletion/removal verbs
|
|
19
|
-
r'\b(delete|remove|drop|deprecate|disable|deactivate|unregister|detach|disconnect|unbind|unsubscribe|uninstall|prune|trim|strip|purge|clear|reset|destroy|dispose|release|free|deallocate)\b',
|
|
20
|
-
# Planning verbs
|
|
21
|
-
r'\b(plan|design|structure|architect|outline|draft|sketch|propose|suggest|approach|strategy|solution|how would|how should|how do|how can|how to|what if|where should|when should|why does|why is|could we|should we|can we|let.s|need to|want to|going to)\b',
|
|
22
|
-
# Review/analysis verbs
|
|
23
|
-
r'\b(review|check|analyze|audit|inspect|examine|validate|verify|assess|evaluate|trace|profile|benchmark|measure|monitor|diagnose|troubleshoot|investigate|identify|detect|discover|locate|find the bug|root cause)\b',
|
|
24
|
-
# Testing verbs
|
|
25
|
-
r'\b(test|run tests|unit test|integration test|e2e test|end.to.end|assert|expect|mock|stub|spy|fake|fixture|setup|teardown|arrange|act|coverage|regression|smoke test|snapshot|parameterize)\b',
|
|
26
|
-
# File types
|
|
27
|
-
r'\.(py|js|ts|tsx|jsx|css|scss|less|html|json|yaml|yml|toml|ini|cfg|sql|sh|bash|zsh|vue|svelte|go|rs|java|kt|swift|rb|php|c|cpp|h|hpp|cs|fs|ex|exs|erl|hs|ml|clj|scala|groovy|dart|lua|r|jl|nim|zig|wasm|graphql|proto|tf|hcl)\b',
|
|
28
|
-
# Programming concepts
|
|
29
|
-
r'\b(loop|condition|if statement|switch|try|catch|exception|error handling|async|await|promise|callback|event|listener|state|props|render|return|import|export|inherit|extend|override|decorator|middleware|migration|schema|model|view|controller|template|query|mutation|subscription|context|scope|closure|binding|reference|pointer|memory|allocation|garbage collection|concurrency|parallelism|synchronization|deadlock|race condition|mutex|semaphore|lock|atomic|transaction|rollback|commit|index|constraint|foreign key|primary key|join|aggregate|subquery|cursor|trigger|stored procedure|materialized view)\b',
|
|
30
|
-
# DevOps/infrastructure
|
|
31
|
-
r'\b(deploy|release|publish|ship|rollout|rollback|ci|cd|pipeline|docker|container|kubernetes|k8s|terraform|ansible|nginx|apache|server|cluster|replica|shard|partition|load balancer|proxy|cdn|ssl|tls|certificate|dns|domain|cors|csp|firewall|vpc|subnet|security group|iam|role|policy|secret|vault|env var|environment variable|configuration|config file|dotenv)\b',
|
|
32
|
-
# Database/data
|
|
33
|
-
r'\b(database|db|sql|nosql|mongo|postgres|mysql|sqlite|redis|elasticsearch|dynamodb|cassandra|orm|queryset|recordset|dataset|dataframe|csv|parquet|avro|protobuf|graphql|rest|grpc|websocket|sse|webhook|polling|pagination|cursor|offset|limit|batch|bulk|upsert|crud)\b',
|
|
34
|
-
# Sample/example requests
|
|
35
|
-
r'\b(example|sample|snippet|demo|prototype|proof of concept|poc|skeleton|boilerplate|starter|template|scaffold|seed|initial|baseline|reference implementation|minimal|basic|simple|quick|small)\b',
|
|
36
|
-
# Common tool/framework references
|
|
37
|
-
r'\b(django|flask|fastapi|express|next|react|vue|angular|svelte|tailwind|bootstrap|jest|pytest|mocha|cypress|playwright|selenium|webpack|vite|rollup|esbuild|npm|yarn|pnpm|pip|poetry|cargo|gradle|maven|cmake|bazel|make|dockerfile|compose|github|gitlab|bitbucket|jira|confluence)\b',
|
|
38
|
-
]
|
|
39
|
-
|
|
40
|
-
CONDENSED_RULES = """
|
|
41
|
-
<code-rules-reminder>
|
|
42
|
-
## MANDATORY CODE RULES - APPLY TO ALL CODE (samples, plans, implementations)
|
|
43
|
-
|
|
44
|
-
1. **NO COMMENTS** - Self-documenting names only
|
|
45
|
-
- BAD: `d = 0.5 # delay` -> GOOD: `delay_between_retries_seconds = 0.5`
|
|
46
|
-
|
|
47
|
-
2. **NO MAGIC VALUES** - Everything named and in config
|
|
48
|
-
- BAD: `if score > 0.8:` -> GOOD: `if score > MINIMUM_CONFIDENCE_THRESHOLD:`
|
|
49
|
-
|
|
50
|
-
3. **NO ABBREVIATIONS** - Full words always
|
|
51
|
-
- BAD: `ctx`, `cfg`, `msg`, `btn` -> GOOD: `context`, `configuration`, `message`, `button`
|
|
52
|
-
|
|
53
|
-
4. **COMPLETE TYPE HINTS** - All parameters and returns typed, no `Any`
|
|
54
|
-
|
|
55
|
-
5. **CENTRALIZED CONFIG** - Constants in config/, imported everywhere
|
|
56
|
-
|
|
57
|
-
6. **SEARCH BEFORE CREATE** - Use everything-search skill before defining constants
|
|
58
|
-
|
|
59
|
-
7. **ALL IMPORTS SHOWN** - Every code block includes its imports
|
|
60
|
-
|
|
61
|
-
8. **SELF-CONTAINED COMPONENTS** - Components own their modals/toasts/state
|
|
62
|
-
|
|
63
|
-
CHECKLIST before writing ANY code:
|
|
64
|
-
[ ] No comments (names explain everything)
|
|
65
|
-
[ ] No magic values (all named constants)
|
|
66
|
-
[ ] No abbreviations (full words)
|
|
67
|
-
[ ] Complete types (all params + returns)
|
|
68
|
-
[ ] Imports shown
|
|
69
|
-
|
|
70
|
-
SCOPE: These rules apply to code you WRITE or MODIFY. Do NOT fix violations in untouched code unless explicitly instructed.
|
|
71
|
-
</code-rules-reminder>
|
|
72
|
-
"""
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def main() -> None:
|
|
76
|
-
try:
|
|
77
|
-
hook_input = json.load(sys.stdin)
|
|
78
|
-
except json.JSONDecodeError:
|
|
79
|
-
sys.exit(0)
|
|
80
|
-
|
|
81
|
-
prompt = hook_input.get("prompt", "")
|
|
82
|
-
|
|
83
|
-
if not prompt:
|
|
84
|
-
sys.exit(0)
|
|
85
|
-
|
|
86
|
-
message_lower = prompt.lower()
|
|
87
|
-
|
|
88
|
-
for pattern in CODE_KEYWORDS:
|
|
89
|
-
if re.search(pattern, message_lower, re.IGNORECASE):
|
|
90
|
-
print(CONDENSED_RULES)
|
|
91
|
-
sys.exit(0)
|
|
92
|
-
|
|
93
|
-
sys.exit(0)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if __name__ == "__main__":
|
|
97
|
-
main()
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
import json
|
|
3
|
-
import os
|
|
4
|
-
import sys
|
|
5
|
-
|
|
6
|
-
PLUGIN_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
7
|
-
CODE_RULES_PATH = os.path.join(PLUGIN_ROOT, "docs", "CODE_RULES.md")
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def load_code_rules() -> str:
|
|
11
|
-
try:
|
|
12
|
-
with open(CODE_RULES_PATH, encoding="utf-8") as code_rules_file:
|
|
13
|
-
return code_rules_file.read()
|
|
14
|
-
except (FileNotFoundError, OSError):
|
|
15
|
-
return ""
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def main() -> None:
|
|
19
|
-
try:
|
|
20
|
-
json.load(sys.stdin)
|
|
21
|
-
except json.JSONDecodeError:
|
|
22
|
-
sys.exit(0)
|
|
23
|
-
|
|
24
|
-
code_rules_content = load_code_rules()
|
|
25
|
-
if not code_rules_content:
|
|
26
|
-
sys.exit(0)
|
|
27
|
-
|
|
28
|
-
reinject_payload = {
|
|
29
|
-
"hookSpecificOutput": {
|
|
30
|
-
"hookEventName": "SessionStart",
|
|
31
|
-
"additionalContext": code_rules_content,
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
print(json.dumps(reinject_payload))
|
|
35
|
-
sys.exit(0)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if __name__ == "__main__":
|
|
39
|
-
main()
|