@smartsoft001/claude-plugins 2.112.0 → 2.114.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.
@@ -2,9 +2,9 @@
2
2
 
3
3
  This guide explains how to configure and customize the hooks system.
4
4
 
5
- ## Current Configuration
5
+ ## Hook Configuration
6
6
 
7
- The hooks are configured in `.claude/settings.json`:
7
+ All hooks are defined in `hooks.json` in this directory:
8
8
 
9
9
  ```json
10
10
  {
@@ -16,70 +16,7 @@ The hooks are configured in `.claude/settings.json`:
16
16
  "hooks": [
17
17
  {
18
18
  "type": "command",
19
- "command": "node_modules/@smartsoft001/claude-plugins/plugins/smart/hooks/safety_validator.py"
20
- }
21
- ]
22
- },
23
- {
24
- "_description": "Block sensitive files with detailed error message",
25
- "matcher": "Read|Edit|Write",
26
- "hooks": [
27
- {
28
- "type": "command",
29
- "command": "FILE=$(jq -r '.tool_input.file_path // empty'); echo \"$FILE\" | grep -qE '(\\.env|secrets|credentials)' && { echo \"BLOCKED: Access denied to sensitive file: $FILE\" >&2; exit 2; } || exit 0"
30
- }
31
- ]
32
- },
33
- {
34
- "_description": "Audit trail: logs all PreToolUse events",
35
- "matcher": "",
36
- "hooks": [
37
- {
38
- "type": "command",
39
- "command": "node_modules/@smartsoft001/claude-plugins/plugins/smart/hooks/audit_logger.py"
40
- }
41
- ]
42
- },
43
- {
44
- "_description": "Skill validator: soft enforcement warnings for skill files",
45
- "matcher": "Write|Edit",
46
- "hooks": [
47
- {
48
- "type": "command",
49
- "command": "node_modules/@smartsoft001/claude-plugins/plugins/smart/hooks/skill_validator.py"
50
- }
51
- ]
52
- }
53
- ],
54
- "PostToolUse": [
55
- {
56
- "_description": "Auto-format files after Write/Edit",
57
- "matcher": "Write|Edit",
58
- "hooks": [
59
- {
60
- "type": "command",
61
- "command": "source ~/.nvm/nvm.sh && nvm use 24 && npm run format"
62
- }
63
- ]
64
- },
65
- {
66
- "_description": "Audit trail: logs all PostToolUse events",
67
- "matcher": "",
68
- "hooks": [
69
- {
70
- "type": "command",
71
- "command": "node_modules/@smartsoft001/claude-plugins/plugins/smart/hooks/audit_logger.py"
72
- }
73
- ]
74
- }
75
- ],
76
- "UserPromptSubmit": [
77
- {
78
- "_description": "Audit trail: logs all user prompt submissions",
79
- "hooks": [
80
- {
81
- "type": "command",
82
- "command": "node_modules/@smartsoft001/claude-plugins/plugins/smart/hooks/audit_logger.py"
19
+ "command": "./safety_validator.py"
83
20
  }
84
21
  ]
85
22
  }
@@ -88,6 +25,8 @@ The hooks are configured in `.claude/settings.json`:
88
25
  }
89
26
  ```
90
27
 
28
+ Hook commands use relative paths (e.g., `./safety_validator.py`) resolved from the `hooks/` directory.
29
+
91
30
  ---
92
31
 
93
32
  ## Hook Customization
@@ -112,13 +51,28 @@ SENSITIVE_FILES = [
112
51
 
113
52
  ---
114
53
 
54
+ ### sensitive_file_blocker.py
55
+
56
+ **Add blocked file patterns** by editing:
57
+
58
+ ```python
59
+ SENSITIVE_PATTERNS = [
60
+ r"\.env(?:\.|$)",
61
+ r"secrets",
62
+ r"credentials",
63
+ # Add your patterns here
64
+ ]
65
+ ```
66
+
67
+ ---
68
+
115
69
  ### audit_logger.py
116
70
 
117
71
  **Change log location:**
118
72
 
119
73
  ```python
120
74
  # Default: .claude/audit_logs/YYYYMMDD_audit.jsonl
121
- LOG_DIR = Path(__file__).parent.parent / "audit_logs"
75
+ LOG_DIR = Path(__file__).resolve().parent.parent / "audit_logs"
122
76
 
123
77
  # Custom location:
124
78
  LOG_DIR = Path("/var/log/claude-audit")
@@ -126,10 +80,26 @@ LOG_DIR = Path("/var/log/claude-audit")
126
80
 
127
81
  ---
128
82
 
83
+ ### auto_format.sh
84
+
85
+ **Change format command:**
86
+
87
+ ```bash
88
+ # Default:
89
+ source ~/.nvm/nvm.sh && nvm use 24 && npm run format
90
+
91
+ # Custom (e.g., without nvm):
92
+ npm run format
93
+ ```
94
+
95
+ ---
96
+
129
97
  ## Environment Variables
130
98
 
131
99
  | Variable | Purpose | Default |
132
100
  | -------------------- | ---------------------- | ------------- |
101
+ | `CLAUDE_HOOK_EVENT` | Hook event type | Set by Claude |
102
+ | `CLAUDE_SESSION_ID` | Session identifier | Set by Claude |
133
103
  | `CLAUDE_PROJECT_DIR` | Project root directory | Auto-detected |
134
104
  | `SKIP_AUDIT_LOG` | Disable audit logging | Not set |
135
105
 
@@ -137,24 +107,26 @@ LOG_DIR = Path("/var/log/claude-audit")
137
107
 
138
108
  ## Hook Execution Order
139
109
 
140
- Hooks run in the order specified in `settings.json`:
110
+ Hooks run in the order specified in `hooks.json`:
141
111
 
142
112
  **PreToolUse order:**
143
113
 
144
114
  1. safety_validator.py (can block)
145
- 2. sensitive file blocker (can block)
115
+ 2. sensitive_file_blocker.py (can block)
146
116
  3. audit_logger.py (logs)
147
- 4. skill-validator.py (warns)
117
+ 4. skill_validator.py (warns)
148
118
 
149
119
  **PostToolUse order:**
150
120
 
151
- 1. auto-format.sh (formats)
121
+ 1. auto_format.sh (formats)
152
122
  2. audit_logger.py (logs)
153
123
 
154
124
  ---
155
125
 
156
126
  ## Selective Hook Enabling
157
127
 
128
+ To use only specific hooks, edit `hooks.json` and remove unwanted entries.
129
+
158
130
  ### Safety Only (No Formatting)
159
131
 
160
132
  ```json
@@ -167,7 +139,7 @@ Hooks run in the order specified in `settings.json`:
167
139
  "hooks": [
168
140
  {
169
141
  "type": "command",
170
- "command": ".claude/hooks/safety_validator.py"
142
+ "command": "./safety_validator.py"
171
143
  }
172
144
  ]
173
145
  }
@@ -224,5 +196,3 @@ FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
224
196
  # Exit 0 = allow, Exit 2 = block
225
197
  exit 0
226
198
  ```
227
-
228
- ---
@@ -1,6 +1,6 @@
1
1
  # Hooks
2
2
 
3
- Claude Code hooks for skill activation, safety validation, formatting, and audit logging.
3
+ Claude Code hooks for safety validation, sensitive file protection, formatting, and audit logging.
4
4
 
5
5
  ---
6
6
 
@@ -16,54 +16,56 @@ Hooks are scripts that run at specific points in Claude's workflow:
16
16
 
17
17
  ---
18
18
 
19
+ ## Configuration
20
+
21
+ All hooks are configured in `hooks.json` in this directory. Claude Code reads this file automatically when the plugin is installed.
22
+
23
+ ---
24
+
19
25
  ## Current Hooks
20
26
 
21
27
  | Hook | Event | Purpose |
22
28
  |------|-------|---------|
23
- | `skill-suggester.py` | UserPromptSubmit | Suggests relevant skills based on prompt |
24
29
  | `safety_validator.py` | PreToolUse | Blocks destructive commands |
25
- | `skill-validator.py` | PreToolUse | Validates skill file structure |
26
- | `auto-format.sh` | PostToolUse | Auto-formats Python/JS/TS files |
30
+ | `sensitive_file_blocker.py` | PreToolUse | Blocks access to sensitive files |
31
+ | `skill_validator.py` | PreToolUse | Validates skill file structure |
32
+ | `auto_format.sh` | PostToolUse | Auto-formats after file changes |
27
33
  | `audit_logger.py` | All events | Logs all actions for audit trail |
28
34
 
29
35
  ---
30
36
 
31
37
  ## Hook Details
32
38
 
33
- ### skill-suggester.py (UserPromptSubmit)
39
+ ### safety_validator.py (PreToolUse)
34
40
 
35
- **Purpose:** Automatically suggests relevant skills based on user prompts and file context.
41
+ **Purpose:** Blocks destructive bash commands and sensitive file modifications.
36
42
 
37
- **How it works:**
38
- 1. Reads `.claude/skills/skill-rules.json`
39
- 2. Matches prompt against keywords and intent patterns
40
- 3. Matches file paths against path patterns
41
- 4. Groups matches by priority (critical, high, medium, low)
42
- 5. Outputs all matching skills in a visual block
43
+ **Matcher:** `Bash|Write|Edit`
43
44
 
44
- **Output example:**
45
- ```
46
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
47
- SKILL ACTIVATION CHECK
48
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
49
-
50
- >> RECOMMENDED SKILLS:
51
- -> /python-dev (keyword: python)
45
+ **Blocks:**
46
+ - `rm -rf /`, `rm -rf ~`, `rm -rf *`
47
+ - `dd` disk operations, `mkfs` formatting
48
+ - Fork bombs
49
+ - Bash access to `.env`, `id_rsa`, `credentials` files
52
50
 
53
- ACTION: Use slash command to activate skill
54
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
55
- ```
51
+ **Exit codes:**
52
+ - `0` - Allow
53
+ - `2` - Block with message
56
54
 
57
55
  ---
58
56
 
59
- ### safety_validator.py (PreToolUse)
57
+ ### sensitive_file_blocker.py (PreToolUse)
60
58
 
61
- **Purpose:** Blocks destructive bash commands and sensitive file modifications.
59
+ **Purpose:** Blocks Read/Edit/Write access to sensitive files.
62
60
 
63
- **Blocks:**
64
- - `rm -rf /`, `rm -rf ~`, `rm -rf *`
65
- - Modifications to `.env`, `id_rsa`, `credentials` files
66
- - Other dangerous patterns
61
+ **Matcher:** `Read|Edit|Write`
62
+
63
+ **Blocked patterns:**
64
+ - `.env` files (`.env`, `.env.local`, `.env.production`)
65
+ - `secrets` in path
66
+ - `credentials` in path
67
+
68
+ **Exception:** Files ending with `.example` are allowed.
67
69
 
68
70
  **Exit codes:**
69
71
  - `0` - Allow
@@ -71,10 +73,12 @@ ACTION: Use slash command to activate skill
71
73
 
72
74
  ---
73
75
 
74
- ### skill-validator.py (PreToolUse)
76
+ ### skill_validator.py (PreToolUse)
75
77
 
76
78
  **Purpose:** Validates skill files follow correct structure.
77
79
 
80
+ **Matcher:** `Write|Edit`
81
+
78
82
  **Checks:**
79
83
  - YAML frontmatter (name, description)
80
84
  - Required sections (Purpose, When to Use)
@@ -85,15 +89,15 @@ ACTION: Use slash command to activate skill
85
89
 
86
90
  ---
87
91
 
88
- ### auto-format.sh (PostToolUse)
92
+ ### auto_format.sh (PostToolUse)
89
93
 
90
94
  **Purpose:** Auto-formats files after Write/Edit operations.
91
95
 
92
- **Formatters:**
93
- - Python: `ruff format`
94
- - JS/TS: `prettier` (if available)
96
+ **Matcher:** `Write|Edit`
95
97
 
96
- **Runs on:** Files matching `*.py`, `*.js`, `*.ts`, `*.tsx`
98
+ **Runs:** `source ~/.nvm/nvm.sh && nvm use 24 && npm run format`
99
+
100
+ **Requires:** Node.js 24 via nvm
97
101
 
98
102
  ---
99
103
 
@@ -111,20 +115,14 @@ ACTION: Use slash command to activate skill
111
115
 
112
116
  ---
113
117
 
114
- ## Configuration
115
-
116
- All hooks are configured in `.claude/settings.json`. See [CONFIG.md](./CONFIG.md) for customization options.
117
-
118
- ---
119
-
120
118
  ## Adding New Hooks
121
119
 
122
- 1. Create script in `.claude/hooks/`
120
+ 1. Create script in this `hooks/` directory
123
121
  2. Make executable: `chmod +x script.py`
124
- 3. Add to `.claude/settings.json` under appropriate event
122
+ 3. Add to `hooks.json` under appropriate event
125
123
  4. Include `_description` for documentation
126
124
 
127
- Example:
125
+ Example entry in `hooks.json`:
128
126
  ```json
129
127
  {
130
128
  "_description": "My custom hook: does something useful",
@@ -132,8 +130,10 @@ Example:
132
130
  "hooks": [
133
131
  {
134
132
  "type": "command",
135
- "command": ".claude/hooks/my-hook.py"
133
+ "command": "./my-hook.py"
136
134
  }
137
135
  ]
138
136
  }
139
137
  ```
138
+
139
+ See [CONFIG.md](./CONFIG.md) for customization options.
@@ -0,0 +1,11 @@
1
+ #!/bin/bash
2
+ # Auto-format hook for Claude Code
3
+ #
4
+ # Runs the project's formatting pipeline (nx format + lint --fix)
5
+ # after Write/Edit operations.
6
+ #
7
+ # Requires Node.js 24 via nvm.
8
+
9
+ set -e
10
+
11
+ source ~/.nvm/nvm.sh && nvm use 24 && npm run format
@@ -0,0 +1,79 @@
1
+ {
2
+ "hooks": {
3
+ "PreToolUse": [
4
+ {
5
+ "_description": "Safety gate: blocks destructive bash commands",
6
+ "matcher": "Bash|Write|Edit",
7
+ "hooks": [
8
+ {
9
+ "type": "command",
10
+ "command": "./safety_validator.py"
11
+ }
12
+ ]
13
+ },
14
+ {
15
+ "_description": "Block sensitive files with detailed error message",
16
+ "matcher": "Read|Edit|Write",
17
+ "hooks": [
18
+ {
19
+ "type": "command",
20
+ "command": "./sensitive_file_blocker.py"
21
+ }
22
+ ]
23
+ },
24
+ {
25
+ "_description": "Audit trail: logs all PreToolUse events",
26
+ "matcher": "",
27
+ "hooks": [
28
+ {
29
+ "type": "command",
30
+ "command": "./audit_logger.py"
31
+ }
32
+ ]
33
+ },
34
+ {
35
+ "_description": "Skill validator: soft enforcement warnings for skill files",
36
+ "matcher": "Write|Edit",
37
+ "hooks": [
38
+ {
39
+ "type": "command",
40
+ "command": "./skill_validator.py"
41
+ }
42
+ ]
43
+ }
44
+ ],
45
+ "PostToolUse": [
46
+ {
47
+ "_description": "Auto-format files after Write/Edit",
48
+ "matcher": "Write|Edit",
49
+ "hooks": [
50
+ {
51
+ "type": "command",
52
+ "command": "./auto_format.sh"
53
+ }
54
+ ]
55
+ },
56
+ {
57
+ "_description": "Audit trail: logs all PostToolUse events",
58
+ "matcher": "",
59
+ "hooks": [
60
+ {
61
+ "type": "command",
62
+ "command": "./audit_logger.py"
63
+ }
64
+ ]
65
+ }
66
+ ],
67
+ "UserPromptSubmit": [
68
+ {
69
+ "_description": "Audit trail: logs all user prompt submissions",
70
+ "hooks": [
71
+ {
72
+ "type": "command",
73
+ "command": "./audit_logger.py"
74
+ }
75
+ ]
76
+ }
77
+ ]
78
+ }
79
+ }
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Sensitive File Blocker Hook for Claude Code
4
+ =============================================
5
+
6
+ Blocks Read/Edit/Write access to sensitive files such as .env, secrets,
7
+ and credentials. Files ending with .example are allowed.
8
+
9
+ Exit Codes:
10
+ 0 - File access permitted
11
+ 2 - File access blocked (sensitive file detected)
12
+
13
+ Integration:
14
+ Configured as PreToolUse hook in hooks/hooks.json
15
+ Receives tool call JSON via stdin from Claude Code
16
+ """
17
+
18
+ import json
19
+ import re
20
+ import sys
21
+
22
+
23
+ SENSITIVE_PATTERNS = [
24
+ r"\.env(?:\.|$)",
25
+ r"secrets",
26
+ r"credentials",
27
+ ]
28
+
29
+
30
+ def main() -> None:
31
+ try:
32
+ data = json.load(sys.stdin)
33
+ except json.JSONDecodeError:
34
+ sys.exit(0)
35
+
36
+ tool_input = data.get("tool_input", {})
37
+ file_path = tool_input.get("file_path", "")
38
+
39
+ if not file_path:
40
+ sys.exit(0)
41
+
42
+ # Allow .example files (safe templates without secrets)
43
+ if file_path.endswith(".example"):
44
+ sys.exit(0)
45
+
46
+ for pattern in SENSITIVE_PATTERNS:
47
+ if re.search(pattern, file_path, re.IGNORECASE):
48
+ print(
49
+ f"BLOCKED: Access denied to sensitive file: {file_path}",
50
+ file=sys.stderr,
51
+ )
52
+ sys.exit(2)
53
+
54
+ sys.exit(0)
55
+
56
+
57
+ if __name__ == "__main__":
58
+ main()
@@ -0,0 +1,82 @@
1
+ ---
2
+ name: audit-log
3
+ description: Query and analyze Claude Code audit logs
4
+ user-invocable: true
5
+ allowed-tools: Bash, Read, Grep, Glob
6
+ ---
7
+
8
+ # Audit Log
9
+
10
+ Query and analyze the Claude Code audit trail stored in `.claude/audit_logs/`.
11
+
12
+ ## Purpose
13
+
14
+ Provide easy access to audit logs that track all Claude Code actions, including tool usage, prompt submissions, and session activity.
15
+
16
+ ## When to Use
17
+
18
+ Use `/smart:audit-log` when you need to:
19
+
20
+ - Review what actions Claude took during a session
21
+ - Debug unexpected behavior by checking the audit trail
22
+ - Verify that safety validators blocked dangerous commands
23
+ - Analyze tool usage patterns
24
+
25
+ ## Arguments
26
+
27
+ ```
28
+ /smart:audit-log [today|yesterday|YYYYMMDD]
29
+ ```
30
+
31
+ - **today** (default) — Show today's audit log
32
+ - **yesterday** — Show yesterday's audit log
33
+ - **YYYYMMDD** — Show log for a specific date (e.g., `20260210`)
34
+
35
+ ## Log Location
36
+
37
+ ```
38
+ .claude/audit_logs/YYYYMMDD_audit.jsonl
39
+ ```
40
+
41
+ Each line is a JSON object with:
42
+
43
+ - `timestamp` — ISO 8601 UTC timestamp
44
+ - `event_type` — Hook event (PreToolUse, PostToolUse, UserPromptSubmit, Stop)
45
+ - `session_id` — Unique session identifier
46
+ - `event_data` — Full event payload
47
+
48
+ ## Instructions
49
+
50
+ 1. Determine the target date from the argument (default: today)
51
+ 2. Construct the log file path: `.claude/audit_logs/YYYYMMDD_audit.jsonl`
52
+ 3. Check if the file exists using Glob
53
+ 4. Read the file and parse JSONL entries
54
+ 5. Present a summary:
55
+ - Total events count
56
+ - Breakdown by event type
57
+ - Any blocked actions (exit code 2)
58
+ - Timeline of key actions
59
+
60
+ ### Filtering Examples
61
+
62
+ To filter by tool name:
63
+
64
+ ```bash
65
+ grep '"tool_name":"Bash"' .claude/audit_logs/YYYYMMDD_audit.jsonl
66
+ ```
67
+
68
+ To filter by event type:
69
+
70
+ ```bash
71
+ grep '"event_type":"PreToolUse"' .claude/audit_logs/YYYYMMDD_audit.jsonl
72
+ ```
73
+
74
+ To show only blocked actions:
75
+
76
+ ```bash
77
+ grep 'BLOCKED' .claude/audit_logs/YYYYMMDD_audit.jsonl
78
+ ```
79
+
80
+ ## Output Format
81
+
82
+ Present results as a readable summary table, not raw JSON. Group events chronologically and highlight any safety blocks or errors.
@@ -0,0 +1,46 @@
1
+ ---
2
+ name: format-code
3
+ description: Format and lint the codebase using Nx
4
+ user-invocable: true
5
+ allowed-tools: Bash
6
+ ---
7
+
8
+ # Format Code
9
+
10
+ Run the project's formatting and linting pipeline.
11
+
12
+ ## Purpose
13
+
14
+ Execute the standard formatting command (`npm run format`) which runs Nx format and lint with auto-fix across the monorepo.
15
+
16
+ ## When to Use
17
+
18
+ Use `/smart:format-code` when you need to:
19
+
20
+ - Format code after making changes across multiple files
21
+ - Fix lint issues before committing
22
+ - Ensure consistent code style across the monorepo
23
+
24
+ ## Prerequisites
25
+
26
+ - **Node.js 24** via nvm (the project requires Node 24 for formatting tools)
27
+ - nvm must be installed and configured at `~/.nvm/nvm.sh`
28
+
29
+ ## Instructions
30
+
31
+ Run the following command:
32
+
33
+ ```bash
34
+ source ~/.nvm/nvm.sh && nvm use 24 && npm run format
35
+ ```
36
+
37
+ This executes:
38
+
39
+ 1. `nx format` — Prettier formatting via Nx
40
+ 2. `nx run-many -t lint --fix` — ESLint auto-fix across all projects
41
+
42
+ ## Notes
43
+
44
+ - The command may take a few minutes on large changesets
45
+ - If nvm is not available, try running `npm run format` directly
46
+ - Formatting follows the project's ESLint flat config (`eslint.config.mjs`) and Prettier settings