claude-warden 1.0.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.
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "claude-warden",
3
+ "version": "1.0.0",
4
+ "description": "Smart command safety filter for Claude Code — parses shell pipelines and evaluates per-command safety rules to auto-approve safe commands and block dangerous ones",
5
+ "author": {
6
+ "name": "banyudu"
7
+ }
8
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Yudu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,137 @@
1
+ # Claude Warden
2
+
3
+ Smart command safety filter for [Claude Code](https://claude.ai/code). Parses shell commands, evaluates each against configurable safety rules, and returns allow/deny/ask decisions — eliminating unnecessary permission prompts while blocking dangerous commands.
4
+
5
+ ## What it does
6
+
7
+ Without Warden, Claude Code prompts you for **every** shell command. With Warden:
8
+
9
+ - `ls`, `grep`, `cat`, `git status` → **auto-approved** (100+ safe commands)
10
+ - `sudo`, `shutdown`, `rm -rf /` → **auto-denied**
11
+ - `npm install`, `docker build`, `ssh prod` → **configurable** per-command rules with argument pattern matching
12
+
13
+ It handles pipes, chains (`&&`, `||`, `;`), env prefixes, `sh -c` wrappers, and subshells. If any command in a pipeline is denied, the whole pipeline is denied.
14
+
15
+ ## Install
16
+
17
+ Two commands inside Claude Code:
18
+
19
+ ```
20
+ /plugin marketplace add banyudu/claude-warden
21
+ /plugin install claude-warden@claude-warden
22
+ ```
23
+
24
+ That's it. Restart Claude Code and Warden is active.
25
+
26
+ ### Alternative: install from npm
27
+
28
+ ```bash
29
+ npm install -g claude-warden
30
+ claude --plugin-dir $(npm root -g)/claude-warden
31
+ ```
32
+
33
+ ### Alternative: test locally from source
34
+
35
+ ```bash
36
+ git clone https://github.com/banyudu/claude-warden.git
37
+ cd claude-warden && npm install && npm run build
38
+ claude --plugin-dir ./claude-warden
39
+ ```
40
+
41
+ ## Configure
42
+
43
+ Warden works out of the box with sensible defaults. To customize, create a config file:
44
+
45
+ - **User-level** (applies everywhere): `~/.claude/warden.yaml`
46
+ - **Project-level** (overrides user-level): `.claude/warden.yaml`
47
+
48
+ Copy [config/warden.default.yaml](config/warden.default.yaml) as a starting point.
49
+
50
+ ### Config options
51
+
52
+ ```yaml
53
+ # Default decision for unknown commands: allow | deny | ask
54
+ defaultDecision: ask
55
+
56
+ # Trigger "ask" for commands with $() or backticks
57
+ askOnSubshell: true
58
+
59
+ # Add commands to always allow/deny
60
+ alwaysAllow:
61
+ - terraform
62
+ - flyctl
63
+ alwaysDeny:
64
+ - nc
65
+
66
+ # Block patterns (regex against full command string)
67
+ globalDeny:
68
+ - pattern: 'curl.*evil\.com'
69
+ reason: 'Blocked domain'
70
+
71
+ # Trusted remote targets (auto-allow connection, evaluate remote commands)
72
+ trustedSSHHosts:
73
+ - devserver
74
+ - "*.internal.company.com"
75
+ trustedDockerContainers:
76
+ - my-app
77
+ - dev-*
78
+ trustedKubectlContexts:
79
+ - minikube
80
+ trustedSprites:
81
+ - my-sprite
82
+
83
+ # Per-command rules (override built-in defaults)
84
+ rules:
85
+ - command: npx
86
+ default: allow
87
+ - command: docker
88
+ default: ask
89
+ argPatterns:
90
+ - match:
91
+ anyArgMatches: ['^(ps|images|logs)$']
92
+ decision: allow
93
+ description: Read-only docker commands
94
+ ```
95
+
96
+ ### Config priority
97
+
98
+ Project `.claude/warden.yaml` > User `~/.claude/warden.yaml` > Built-in defaults
99
+
100
+ ## Built-in defaults
101
+
102
+ ### Always allowed (~60 commands)
103
+ File readers (`cat`, `head`, `tail`, `less`), search tools (`grep`, `rg`, `find`, `fd`), directory listing (`ls`, `tree`), text processing (`sed`, `awk`, `jq`), git, package managers (`npm`, `pnpm`, `yarn`), build tools (`make`, `cargo`, `go`, `tsc`), and more.
104
+
105
+ ### Always denied
106
+ `sudo`, `su`, `mkfs`, `fdisk`, `dd`, `shutdown`, `reboot`, `iptables`, `crontab`, `systemctl`, `launchctl`
107
+
108
+ ### Global deny patterns
109
+ - `rm -rf` (recursive force delete)
110
+ - Direct writes to block devices
111
+ - `chmod -R 777`
112
+ - Fork bombs
113
+
114
+ ### Conditional rules
115
+ Commands like `node`, `npx`, `docker`, `ssh`, `git push --force`, `rm` have argument-aware rules. For example, `git` is allowed but `git push --force` triggers a prompt.
116
+
117
+ ## How it works
118
+
119
+ 1. Claude Code calls the `PreToolUse` hook before every Bash command
120
+ 2. Warden parses the command into individual parts (handling pipes, chains, env prefixes)
121
+ 3. Each part is evaluated: global deny → alwaysDeny → alwaysAllow → command rules → default
122
+ 4. For pipelines: any deny → deny whole pipeline, any ask → ask, all allow → allow
123
+ 5. Returns the decision via stdout JSON (allow/ask) or exit code 2 (deny)
124
+
125
+ ## Development
126
+
127
+ ```bash
128
+ pnpm install
129
+ pnpm run build # Build to dist/index.cjs
130
+ pnpm run test # Run tests
131
+ pnpm run typecheck # Type check
132
+ pnpm run dev # Watch mode
133
+ ```
134
+
135
+ ## License
136
+
137
+ MIT
@@ -0,0 +1,67 @@
1
+ # Claude Warden - Default Configuration Reference
2
+ #
3
+ # Copy to ~/.claude/warden.yaml or .claude/warden.yaml (project-level) to customize.
4
+ # Project-level config overrides user-level config, which overrides defaults.
5
+
6
+ # Default decision for commands not covered by any rule: allow | deny | ask
7
+ defaultDecision: ask
8
+
9
+ # If true, commands containing $() or backticks trigger "ask"
10
+ askOnSubshell: true
11
+
12
+ # Additional commands to always allow (appended to built-in list)
13
+ # alwaysAllow:
14
+ # - terraform
15
+ # - flyctl
16
+ # - my-safe-tool
17
+
18
+ # Additional commands to always deny (appended to built-in list)
19
+ # alwaysDeny:
20
+ # - nc
21
+ # - ncat
22
+
23
+ # Additional global deny patterns (regex against full command string)
24
+ # globalDeny:
25
+ # - pattern: 'curl.*evil\\.com'
26
+ # reason: 'Blocked domain'
27
+
28
+ # Trusted SSH hosts — ssh/scp/rsync to these hosts are auto-allowed.
29
+ # Remote commands on trusted hosts are recursively evaluated through warden rules.
30
+ # Supports glob patterns (* wildcards).
31
+ # trustedSSHHosts:
32
+ # - devserver
33
+ # - staging-*
34
+ # - "*.internal.company.com"
35
+ # - 192.168.1.*
36
+
37
+ # Trusted Docker containers — docker exec to these containers are auto-allowed.
38
+ # Remote commands are recursively evaluated through warden rules.
39
+ # trustedDockerContainers:
40
+ # - my-app
41
+ # - dev-*
42
+
43
+ # Trusted kubectl contexts — kubectl exec in these contexts are auto-allowed.
44
+ # Remote commands (after --) are recursively evaluated through warden rules.
45
+ # trustedKubectlContexts:
46
+ # - minikube
47
+ # - dev-cluster-*
48
+
49
+ # Trusted Sprites — sprite exec/console to these sprites are auto-allowed.
50
+ # Remote commands are recursively evaluated through warden rules.
51
+ # trustedSprites:
52
+ # - my-sprite
53
+ # - dev-*
54
+
55
+ # Command-specific rules (override built-in rules by command name)
56
+ # rules:
57
+ # - command: npx
58
+ # default: allow # Trust all npx in this project
59
+ # - command: docker
60
+ # default: allow # Trust docker in this project
61
+ # - command: ssh
62
+ # default: allow
63
+ # argPatterns:
64
+ # - match:
65
+ # anyArgMatches: ['^devserver$', '^staging$']
66
+ # decision: allow
67
+ # description: Known safe SSH targets