@smartsoft001/claude-plugins 2.113.0 → 2.115.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 +1 -1
- package/plugins/smart/.claude-plugin/README.md +65 -47
- package/plugins/smart/.claude-plugin/merge-permissions.js +33 -12
- package/plugins/smart/.claude-plugin/plugin.json +1 -1
- package/plugins/smart/.claude-plugin/settings.template.json +2 -2
- package/plugins/smart/agents/angular-components/AGENT.md +55 -0
- package/plugins/smart/hooks/CONFIG.md +44 -74
- package/plugins/smart/hooks/README.md +45 -45
- package/plugins/smart/hooks/auto_format.sh +11 -0
- package/plugins/smart/hooks/hooks.json +79 -0
- package/plugins/smart/hooks/sensitive_file_blocker.py +58 -0
- package/plugins/smart/skills/angular-components-button/SKILL.md +109 -0
- package/plugins/smart/skills/audit-log/SKILL.md +82 -0
- package/plugins/smart/skills/format-code/SKILL.md +46 -0
- package/plugins/smart/skills/project-conventions/SKILL.md +90 -0
- package/plugins/smart/skills/safety-check/SKILL.md +76 -0
- package/plugins/smart/audit_logs/20260308_audit.jsonl +0 -190
- package/plugins/smart/audit_logs/20260309_audit.jsonl +0 -476
package/package.json
CHANGED
|
@@ -1,88 +1,102 @@
|
|
|
1
1
|
# Smart Plugin for Claude Code
|
|
2
2
|
|
|
3
|
-
Smartsoft integration - safety validation, audit logging,
|
|
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
|
-
|
|
21
|
+
```bash
|
|
22
|
+
claude plugin update smart@smartsoft --scope project
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Architecture
|
|
18
26
|
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
52
|
+
## Skills
|
|
28
53
|
|
|
29
|
-
|
|
54
|
+
### User-Invocable
|
|
30
55
|
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
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
|
-
|
|
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
|
-
|
|
|
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
|
|
81
|
+
### PostToolUse
|
|
52
82
|
|
|
53
83
|
| Hook | Matcher | Purpose |
|
|
54
84
|
|------|---------|---------|
|
|
55
|
-
|
|
|
85
|
+
| `auto_format.sh` | Write\|Edit | Runs formatting pipeline |
|
|
56
86
|
| `audit_logger.py` | * | Logs all events |
|
|
57
87
|
|
|
58
|
-
### UserPromptSubmit
|
|
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":
|
|
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
|
-
*
|
|
6
|
-
*
|
|
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
|
-
*
|
|
9
|
-
*
|
|
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]
|
|
45
|
+
const existingDescriptions = merged[event]
|
|
46
|
+
.map((h) => h._description)
|
|
47
|
+
.filter(Boolean);
|
|
42
48
|
for (const hook of hooks) {
|
|
43
|
-
if (
|
|
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 || {
|
|
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(
|
|
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(
|
|
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,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.
|
|
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
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: angular-components
|
|
3
|
+
description: Build UI in end-user projects using @smartsoft001/angular components. Knows available components and delegates to per-component skills for API details.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Angular Components Agent
|
|
7
|
+
|
|
8
|
+
Agent for building UI in end-user Angular projects using components from `@smartsoft001/angular`.
|
|
9
|
+
|
|
10
|
+
## When to Use
|
|
11
|
+
|
|
12
|
+
Use this agent when a developer needs to:
|
|
13
|
+
|
|
14
|
+
- Build a page or feature UI using `@smartsoft001/angular` components
|
|
15
|
+
- Choose the right component for a UI requirement
|
|
16
|
+
- Get correct usage, imports, and options for a component
|
|
17
|
+
|
|
18
|
+
## Available Components
|
|
19
|
+
|
|
20
|
+
| Component | Skill | Selector | Description |
|
|
21
|
+
| --------- | --------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------- |
|
|
22
|
+
| Button | `angular-components-button` | `<smart-button>` | Button with shapes (standard/rounded/circular), variants (primary/secondary/soft), sizes, color palette |
|
|
23
|
+
| Icon | — | `<smart-icon>` | SVG icon component (spinner) |
|
|
24
|
+
|
|
25
|
+
## Skills to Use
|
|
26
|
+
|
|
27
|
+
When a user asks about a specific component, **always delegate to the per-component skill** for detailed API, usage examples, and options:
|
|
28
|
+
|
|
29
|
+
- **Button** → use skill `angular-components-button`
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm i @smartsoft001/angular
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Import Pattern
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { ButtonComponent } from '@smartsoft001/angular';
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Shared Types
|
|
44
|
+
|
|
45
|
+
All components use shared types from `@smartsoft001/angular`:
|
|
46
|
+
|
|
47
|
+
- `SmartVariant` — `'primary' | 'secondary' | 'soft'`
|
|
48
|
+
- `SmartSize` — `'xs' | 'sm' | 'md' | 'lg' | 'xl'`
|
|
49
|
+
- `SmartColor` — 22 Tailwind color names (default: `'indigo'`)
|
|
50
|
+
|
|
51
|
+
## Styling
|
|
52
|
+
|
|
53
|
+
- Tailwind CSS v4 with `smart:` prefix
|
|
54
|
+
- Dark mode via `dark:smart:` prefix
|
|
55
|
+
- External classes via `class` input
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
This guide explains how to configure and customize the hooks system.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Hook Configuration
|
|
6
6
|
|
|
7
|
-
|
|
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": "
|
|
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 `
|
|
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.
|
|
115
|
+
2. sensitive_file_blocker.py (can block)
|
|
146
116
|
3. audit_logger.py (logs)
|
|
147
|
-
4.
|
|
117
|
+
4. skill_validator.py (warns)
|
|
148
118
|
|
|
149
119
|
**PostToolUse order:**
|
|
150
120
|
|
|
151
|
-
1.
|
|
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": "
|
|
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
|
-
---
|