@smartsoft001/claude-plugins 2.113.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartsoft001/claude-plugins",
3
- "version": "2.113.0",
3
+ "version": "2.114.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -1,88 +1,102 @@
1
1
  # Smart Plugin for Claude Code
2
2
 
3
- Smartsoft integration - safety validation, audit logging, and auto-formatting hooks.
3
+ Smartsoft integration - safety validation, audit logging, auto-formatting hooks, and project convention skills.
4
4
 
5
5
  ## Features
6
6
 
7
- | Feature | Description |
8
- |---------|-------------|
9
- | Safety validation | Blocks destructive bash commands (`rm -rf /`, etc.) |
10
- | Sensitive file protection | Blocks access to `.env`, credentials, secrets |
11
- | Audit logging | Logs all Claude actions to `.claude/audit_logs/` |
12
- | Skill validation | Validates skill file structure (soft warnings) |
13
- | Auto-formatting | Formats files after Write/Edit operations |
7
+ | Feature | Type | Description |
8
+ |---------|------|-------------|
9
+ | Safety validation | Hook | Blocks destructive bash commands (`rm -rf /`, etc.) |
10
+ | Sensitive file protection | Hook | Blocks access to `.env`, credentials, secrets |
11
+ | Audit logging | Hook | Logs all Claude actions to `.claude/audit_logs/` |
12
+ | Skill validation | Hook | Validates skill file structure (soft warnings) |
13
+ | Auto-formatting | Hook | Formats files after Write/Edit operations |
14
+ | Safety check | Skill (background) | Safety rules knowledge for Claude |
15
+ | Project conventions | Skill (background) | Monorepo conventions and patterns |
16
+ | Audit log viewer | Skill (user-invocable) | `/smart:audit-log` to query audit logs |
17
+ | Format code | Skill (user-invocable) | `/smart:format-code` to run formatting |
14
18
 
15
19
  ## Installation
16
20
 
17
- ### 1. Enable plugin in project's `.claude/settings.json`:
21
+ ```bash
22
+ claude plugin update smart@smartsoft --scope project
23
+ ```
24
+
25
+ ## Architecture
18
26
 
19
- ```json
20
- {
21
- "enabledPlugins": {
22
- "smart@smartsoft": true
23
- }
24
- }
27
+ ```
28
+ smart/
29
+ ├── .claude-plugin/
30
+ │ ├── plugin.json # Plugin metadata
31
+ │ └── README.md # This file
32
+ ├── hooks/
33
+ │ ├── hooks.json # Hook configuration
34
+ │ ├── safety_validator.py # Blocks destructive commands
35
+ │ ├── sensitive_file_blocker.py # Blocks access to sensitive files
36
+ │ ├── audit_logger.py # Logs all Claude actions
37
+ │ ├── skill_validator.py # Validates skill file structure
38
+ │ ├── auto_format.sh # Formats code after changes
39
+ │ ├── CONFIG.md # Hook customization guide
40
+ │ └── README.md # Hook documentation
41
+ ├── skills/
42
+ │ ├── safety-check/SKILL.md # Background: safety rules
43
+ │ ├── audit-log/SKILL.md # User-invocable: /smart:audit-log
44
+ │ ├── format-code/SKILL.md # User-invocable: /smart:format-code
45
+ │ └── project-conventions/SKILL.md # Background: project knowledge
46
+ ├── _legacy/
47
+ │ ├── settings.template.json # Deprecated settings template
48
+ │ └── merge-permissions.js # Deprecated merge script
49
+ └── MIGRATION.md # Migration guide from legacy
25
50
  ```
26
51
 
27
- ### 2. Merge settings from template
52
+ ## Skills
28
53
 
29
- **Quick merge script:**
54
+ ### User-Invocable
30
55
 
31
- ```bash
32
- node node_modules/@smartsoft001/claude-plugins/plugins/smart/.claude-plugin/merge-permissions.js
33
- ```
56
+ | Skill | Command | Purpose |
57
+ |-------|---------|---------|
58
+ | audit-log | `/smart:audit-log [today\|yesterday\|YYYYMMDD]` | Query audit logs |
59
+ | format-code | `/smart:format-code` | Run `npm run format` |
60
+
61
+ ### Background (automatic)
34
62
 
35
- This will:
36
- - Add required permissions (source, nvm, npm run format, jq)
37
- - Configure all hooks (PreToolUse, PostToolUse, UserPromptSubmit)
38
- - Enable the plugin
63
+ | Skill | Purpose |
64
+ |-------|---------|
65
+ | safety-check | Blocked patterns and sensitive file rules |
66
+ | project-conventions | Nx monorepo structure, conventions, patterns |
39
67
 
40
68
  ## Hooks
41
69
 
42
- ### PreToolUse Hooks
70
+ Hooks are configured in `hooks/hooks.json` and run automatically:
71
+
72
+ ### PreToolUse
43
73
 
44
74
  | Hook | Matcher | Purpose |
45
75
  |------|---------|---------|
46
76
  | `safety_validator.py` | Bash\|Write\|Edit | Blocks destructive commands |
47
- | Sensitive file blocker | Read\|Edit\|Write | Blocks `.env`, secrets, credentials |
77
+ | `sensitive_file_blocker.py` | Read\|Edit\|Write | Blocks sensitive files |
48
78
  | `audit_logger.py` | * | Logs all events |
49
79
  | `skill_validator.py` | Write\|Edit | Validates skill files |
50
80
 
51
- ### PostToolUse Hooks
81
+ ### PostToolUse
52
82
 
53
83
  | Hook | Matcher | Purpose |
54
84
  |------|---------|---------|
55
- | Auto-format | Write\|Edit | `npm run format` after file changes |
85
+ | `auto_format.sh` | Write\|Edit | Runs formatting pipeline |
56
86
  | `audit_logger.py` | * | Logs all events |
57
87
 
58
- ### UserPromptSubmit Hooks
88
+ ### UserPromptSubmit
59
89
 
60
90
  | Hook | Purpose |
61
91
  |------|---------|
62
92
  | `audit_logger.py` | Logs user prompts |
63
93
 
64
- ## Permissions
65
-
66
- The plugin requires these permissions to function:
67
-
68
- ```json
69
- {
70
- "allow": [
71
- "Bash(source:*)",
72
- "Bash(nvm use:*)",
73
- "Bash(npm run format:*)",
74
- "Bash(jq:*)"
75
- ]
76
- }
77
- ```
78
-
79
94
  ## Audit Logs
80
95
 
81
96
  Logs are stored in `.claude/audit_logs/YYYYMMDD_audit.jsonl`:
82
97
 
83
98
  ```json
84
- {"timestamp": "2024-01-15T10:30:00Z", "event": "PreToolUse", "tool": "Bash", "input": {...}}
85
- {"timestamp": "2024-01-15T10:30:01Z", "event": "PostToolUse", "tool": "Bash", "success": true}
99
+ {"timestamp":"2024-01-15T10:30:00Z","event_type":"PreToolUse","session_id":"abc123","event_data":{...}}
86
100
  ```
87
101
 
88
102
  ## Customization
@@ -90,4 +104,8 @@ Logs are stored in `.claude/audit_logs/YYYYMMDD_audit.jsonl`:
90
104
  See `hooks/CONFIG.md` for:
91
105
  - Adding custom blocked patterns
92
106
  - Changing log location
93
- - Creating new hooks
107
+ - Creating new hooks
108
+
109
+ ## Migration from Legacy
110
+
111
+ If upgrading from the old `settings.template.json` approach, see `MIGRATION.md`.
@@ -1,12 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Merge smart plugin settings into project's .claude/settings.json
3
+ * LEGACY: Merge smart plugin settings into project's .claude/settings.json
4
4
  *
5
- * Usage:
6
- * npx @smartsoft001/claude-plugins smart:merge-permissions
5
+ * This script is deprecated. The new plugin architecture uses:
6
+ * - hooks/hooks.json for hook configuration
7
+ * - skills/ directory for skill definitions
8
+ * - `claude plugin update smart@smartsoft --scope project` for installation
7
9
  *
8
- * Or directly:
9
- * node node_modules/@smartsoft001/claude-plugins/plugins/smart/.claude-plugin/merge-permissions.js
10
+ * See MIGRATION.md for upgrade instructions.
11
+ *
12
+ * Usage (legacy):
13
+ * node node_modules/@smartsoft001/claude-plugins/plugins/smart/_legacy/merge-permissions.js
10
14
  */
11
15
 
12
16
  const fs = require('fs');
@@ -38,9 +42,14 @@ function mergeHooks(existing, template) {
38
42
  merged[event] = hooks;
39
43
  } else {
40
44
  // Merge by checking _description to avoid duplicates
41
- const existingDescriptions = merged[event].map(h => h._description).filter(Boolean);
45
+ const existingDescriptions = merged[event]
46
+ .map((h) => h._description)
47
+ .filter(Boolean);
42
48
  for (const hook of hooks) {
43
- if (hook._description && !existingDescriptions.includes(hook._description)) {
49
+ if (
50
+ hook._description &&
51
+ !existingDescriptions.includes(hook._description)
52
+ ) {
44
53
  merged[event].push(hook);
45
54
  } else if (!hook._description) {
46
55
  merged[event].push(hook);
@@ -53,7 +62,10 @@ function mergeHooks(existing, template) {
53
62
  }
54
63
 
55
64
  function main() {
56
- console.log('Smart Plugin - Merge Settings\n');
65
+ console.log('Smart Plugin - Merge Settings (LEGACY)\n');
66
+ console.log(
67
+ 'WARNING: This script is deprecated. Use `claude plugin update smart@smartsoft --scope project` instead.\n',
68
+ );
57
69
 
58
70
  // Load template
59
71
  const template = loadJson(TEMPLATE_PATH);
@@ -71,7 +83,11 @@ function main() {
71
83
  }
72
84
 
73
85
  // Ensure structures exist
74
- settings.permissions = settings.permissions || { allow: [], deny: [], ask: [] };
86
+ settings.permissions = settings.permissions || {
87
+ allow: [],
88
+ deny: [],
89
+ ask: [],
90
+ };
75
91
  settings.permissions.allow = settings.permissions.allow || [];
76
92
  settings.permissions.ask = settings.permissions.ask || [];
77
93
  settings.permissions.deny = settings.permissions.deny || [];
@@ -82,7 +98,10 @@ function main() {
82
98
  const beforeHooks = Object.keys(settings.hooks).length;
83
99
 
84
100
  // Merge permissions
85
- settings.permissions.allow = mergeArrays(settings.permissions.allow, template.permissions.allow);
101
+ settings.permissions.allow = mergeArrays(
102
+ settings.permissions.allow,
103
+ template.permissions.allow,
104
+ );
86
105
 
87
106
  // Merge hooks
88
107
  settings.hooks = mergeHooks(settings.hooks, template.hooks);
@@ -99,10 +118,12 @@ function main() {
99
118
  const afterHooks = Object.keys(settings.hooks).length;
100
119
 
101
120
  console.log('Settings merged successfully!\n');
102
- console.log(` permissions.allow: ${beforeAllow} -> ${settings.permissions.allow.length} (+${addedAllow})`);
121
+ console.log(
122
+ ` permissions.allow: ${beforeAllow} -> ${settings.permissions.allow.length} (+${addedAllow})`,
123
+ );
103
124
  console.log(` hooks events: ${beforeHooks} -> ${afterHooks}`);
104
125
  console.log(`\nPlugin enabled: smart@smartsoft`);
105
126
  console.log(`\nFile updated: ${SETTINGS_PATH}`);
106
127
  }
107
128
 
108
- main();
129
+ main();
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "smart",
3
3
  "description": "Smartsoft integration - safety validation, audit logging, and auto-formatting hooks",
4
- "version": "2.113.0"
4
+ "version": "2.114.0"
5
5
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/anthropics/claude-code/main/schemas/settings.schema.json",
3
- "_description": "Template settings for smart@smartsoft plugin. Merge these into your project's .claude/settings.json",
3
+ "_description": "LEGACY: Template settings for smart@smartsoft plugin. Replaced by hooks/hooks.json and skills/ directory. See MIGRATION.md for upgrade guide.",
4
4
  "permissions": {
5
5
  "allow": [
6
6
  "Bash(source:*)",
@@ -91,4 +91,4 @@
91
91
  "enabledPlugins": {
92
92
  "smart@smartsoft": true
93
93
  }
94
- }
94
+ }
@@ -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
@@ -0,0 +1,90 @@
1
+ ---
2
+ name: project-conventions
3
+ description: Smartsoft001 monorepo conventions and architecture knowledge
4
+ user-invocable: false
5
+ ---
6
+
7
+ # Project Conventions
8
+
9
+ Background skill providing knowledge about the Smartsoft001 monorepo structure, conventions, and patterns.
10
+
11
+ ## Purpose
12
+
13
+ Ensure Claude follows project conventions when generating or modifying code in this Nx monorepo.
14
+
15
+ ## When to Use
16
+
17
+ This skill is applied automatically when working within the Smartsoft001 codebase.
18
+
19
+ ## Monorepo Structure
20
+
21
+ This is an **Nx monorepo** using **pnpm** workspaces. Projects are organized under:
22
+
23
+ - `packages/` — shared libraries and integrations
24
+ - `apps/` — applications (if any)
25
+
26
+ ### Domain Architecture
27
+
28
+ Three main domains, each following the same layered pattern:
29
+
30
+ | Domain | Purpose |
31
+ | ------- | --------------------------------- |
32
+ | `auth` | Authentication and authorization |
33
+ | `crud` | CRUD operations and UI components |
34
+ | `trans` | Translation/internationalization |
35
+
36
+ Each domain's layers:
37
+
38
+ - `domain/` — core business logic and models
39
+ - `shell/app-services/` — application services
40
+ - `shell/dtos/` — data transfer objects
41
+ - `shell/nestjs/` — NestJS implementations
42
+ - `shell/angular/` — Angular UI components (crud only)
43
+
44
+ ### Shared Libraries (`packages/shared/`)
45
+
46
+ `domain-core`, `models`, `angular`, `nestjs`, `users`, `utils`, `mongo`, and payment/third-party integrations (`paypal`, `payu`, `paynow`, `revolut`, `fb`, `google`).
47
+
48
+ ## Code Conventions
49
+
50
+ ### Component Prefixes
51
+
52
+ - `smart` prefix for CRUD shell Angular components
53
+ - `lib` prefix for shared Angular library components
54
+
55
+ ### Project Tags
56
+
57
+ - `scope:crud`, `scope:auth`, `scope:trans` — domain separation
58
+ - `type:shell`, `type:domain` — architectural layers
59
+
60
+ ### ESLint / Import Ordering
61
+
62
+ - Flat ESLint configuration (`eslint.config.mjs`)
63
+ - Alphabetical import sorting
64
+ - Special handling for `@smartsoft001/**` imports
65
+ - Newlines required between import groups
66
+
67
+ ### State Management (NgRx)
68
+
69
+ - Standard NgRx patterns: effects, actions, reducers, selectors
70
+ - Facade pattern for component interaction
71
+ - Error handling via shared error effects and services
72
+
73
+ ### Styling
74
+
75
+ - **Tailwind CSS** for styling
76
+ - **SCSS** for component-level styles
77
+ - PostCSS processing for optimization
78
+
79
+ ### Git Conventions
80
+
81
+ - Conventional commits (enforced by Commitlint + Husky)
82
+ - Main branch: `main`
83
+ - Auto-versioning via GitHub Actions
84
+
85
+ ### Testing
86
+
87
+ - **Jest** as primary test framework
88
+ - `@nx/jest` for Nx integration
89
+ - `jest-preset-angular` for Angular tests
90
+ - Storybook testing with `@storybook/test-runner`
@@ -0,0 +1,76 @@
1
+ ---
2
+ name: safety-check
3
+ description: Safety validation rules for blocking destructive operations
4
+ user-invocable: false
5
+ ---
6
+
7
+ # Safety Check
8
+
9
+ Background skill that provides safety validation knowledge. Claude uses these rules automatically when evaluating tool calls.
10
+
11
+ ## Purpose
12
+
13
+ Prevent destructive operations from executing by defining blocked patterns for bash commands, file operations, and sensitive file access.
14
+
15
+ ## Blocked Bash Patterns
16
+
17
+ The following command patterns are blocked when detected in Bash tool calls:
18
+
19
+ ### Recursive Deletion
20
+
21
+ - `rm -rf /` — recursive delete root filesystem
22
+ - `rm -rf /*` — recursive delete root contents
23
+ - `rm -rf ~` — recursive delete home directory
24
+ - `rm -rf $HOME` — recursive delete home directory
25
+ - `rm -rf *` — recursive delete all files
26
+ - Covers variations: `-rf`, `-r -f`, `--recursive --force`, `-fr`, etc.
27
+
28
+ ### Disk Operations
29
+
30
+ - `dd if=/dev/zero of=/dev/...` — disk wiping
31
+ - `dd of=/dev/...` — writing to raw devices
32
+ - `> /dev/sda` — overwrite disk via redirect
33
+ - `mkfs.*` — formatting filesystems
34
+
35
+ ### System Attacks
36
+
37
+ - `:(){ :|:& };:` — fork bomb
38
+
39
+ ### Sensitive File Access via Bash
40
+
41
+ Commands like `cat`, `head`, `tail`, `cp` targeting:
42
+
43
+ - `.env` files
44
+ - `.secret` files
45
+ - `id_rsa`, `id_ed25519` SSH keys
46
+ - `.pem` certificate files
47
+ - `credentials` files
48
+
49
+ ## Sensitive File Patterns
50
+
51
+ Direct file access (Read/Write/Edit tools) is blocked for paths containing:
52
+
53
+ | Pattern | Description |
54
+ | ------------- | -------------------------- |
55
+ | `.env` | Environment variable files |
56
+ | `.secret` | Secret configuration files |
57
+ | `id_rsa` | RSA SSH private keys |
58
+ | `id_ed25519` | Ed25519 SSH private keys |
59
+ | `id_ecdsa` | ECDSA SSH private keys |
60
+ | `.pem` | Certificate/key files |
61
+ | `credentials` | Credential files |
62
+
63
+ ## Exception: `.example` Files
64
+
65
+ Files ending with `.example` are **always allowed**. These are safe template files without actual secrets:
66
+
67
+ - `.env.example` — safe to read for structure reference
68
+ - `.secret.example` — safe to read for structure reference
69
+
70
+ ## When to Use
71
+
72
+ This skill is applied automatically. Claude should be aware of these safety rules when:
73
+
74
+ - Executing bash commands
75
+ - Reading, writing, or editing files
76
+ - Suggesting commands to users