Browse Source

feat: Rename /init-perms to /init-tools, add rules template

- Rename command to /init-tools (clearer purpose)
- Add templates/rules/cli-tools.md for project-level rules
- Install both permissions AND rules by default (opt-out)
- Add global rule at ~/.claude/rules/cli-tools.md

Claude now prefers modern tools: fd > find, rg > grep, bat > cat, etc.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
0xDarkMatter 4 months ago
parent
commit
ba0356e47c
3 changed files with 339 additions and 231 deletions
  1. 0 231
      commands/init-perms.md
  2. 227 0
      commands/init-tools.md
  3. 112 0
      templates/rules/cli-tools.md

+ 0 - 231
commands/init-perms.md

@@ -1,231 +0,0 @@
----
-name: init-perms
-description: "Initialize generous Claude Code permissions in current project. Creates .claude/settings.local.json with dev-shell-tools and common dev tool permissions."
----
-
-# /init-perms
-
-Initialize project-local Claude Code permissions for a comfortable development experience.
-
-## What This Does
-
-Creates `.claude/settings.local.json` in the current project with pre-approved permissions for modern CLI tools from [dev-shell-tools](https://github.com/0xDarkMatter/dev-shell-tools):
-
-**Core Tools:**
-- **Git**: Full git access, lazygit, gh (GitHub CLI)
-- **File ops**: ls, mkdir, cat, wc, tree, eza, bat
-- **Search**: rg (ripgrep), fd, fzf, ast-grep/sg
-- **Navigation**: zoxide/z, broot/br
-- **Data processing**: jq, yq, sd
-- **Diff tools**: delta, difft (difftastic)
-- **Analysis**: tokei, procs, hyperfine
-
-**Dev Tools:**
-- **Package managers**: npm, node, python, uv, pip
-- **Task runners**: just
-- **Network**: curl, http (httpie)
-- **Windows**: powershell
-
-## Execution Flow
-
-```
-/init-perms
-    │
-    ├─→ Check if .claude/settings.local.json exists
-    │     ├─ If exists: Ask to overwrite or merge
-    │     └─ If not: Proceed
-    │
-    ├─→ Create .claude directory if needed
-    │
-    └─→ Write settings.local.json with standard permissions
-```
-
-## Instructions
-
-### Step 1: Check for existing settings
-
-```bash
-ls -la .claude/settings.local.json 2>/dev/null
-```
-
-If file exists, show contents and ask user:
-- **Overwrite**: Replace entirely with template
-- **Skip**: Keep existing, do nothing
-- **Merge**: Add missing permissions (advanced)
-
-### Step 2: Create .claude directory
-
-```bash
-mkdir -p .claude
-```
-
-### Step 3: Write permissions file
-
-Write this content to `.claude/settings.local.json`:
-
-```json
-{
-  "permissions": {
-    "allow": [
-      "Bash(git:*)",
-      "Bash(ls:*)",
-      "Bash(mkdir:*)",
-      "Bash(cat:*)",
-      "Bash(wc:*)",
-      "Bash(tree:*)",
-      "Bash(curl:*)",
-      "Bash(rg:*)",
-      "Bash(fd:*)",
-      "Bash(fzf:*)",
-      "Bash(z:*)",
-      "Bash(zoxide:*)",
-      "Bash(br:*)",
-      "Bash(broot:*)",
-      "Bash(ast-grep:*)",
-      "Bash(sg:*)",
-      "Bash(bat:*)",
-      "Bash(eza:*)",
-      "Bash(delta:*)",
-      "Bash(difft:*)",
-      "Bash(jq:*)",
-      "Bash(yq:*)",
-      "Bash(sd:*)",
-      "Bash(lazygit:*)",
-      "Bash(gh:*)",
-      "Bash(tokei:*)",
-      "Bash(uv:*)",
-      "Bash(just:*)",
-      "Bash(http:*)",
-      "Bash(procs:*)",
-      "Bash(hyperfine:*)",
-      "Bash(npm:*)",
-      "Bash(node:*)",
-      "Bash(python:*)",
-      "Bash(pip:*)",
-      "Bash(powershell -Command:*)",
-      "Bash(powershell.exe:*)"
-    ],
-    "deny": [],
-    "ask": []
-  },
-  "hooks": {}
-}
-```
-
-### Step 4: Confirm
-
-Report to user:
-```
-Created .claude/settings.local.json with dev-shell-tools permissions.
-
-Allowed tools (37 total):
-  Core: git, ls, mkdir, cat, wc, tree, curl
-  Search: rg, fd, fzf, ast-grep, sg
-  Navigation: z, zoxide, br, broot
-  View: bat, eza, delta, difft
-  Data: jq, yq, sd
-  Git: lazygit, gh
-  Analysis: tokei, procs, hyperfine
-  Dev: npm, node, python, pip, uv, just, http
-  Windows: powershell
-
-To customize: edit .claude/settings.local.json
-To add to git: git add .claude/settings.local.json
-```
-
-## Options
-
-| Flag | Effect |
-|------|--------|
-| `--force` | Overwrite existing without asking |
-| `--minimal` | Only git, ls, cat, mkdir |
-| `--full` | Add cloud/container tools (docker, kubectl, terraform, aws, etc.) |
-
-### Minimal Template (--minimal)
-
-```json
-{
-  "permissions": {
-    "allow": [
-      "Bash(git:*)",
-      "Bash(ls:*)",
-      "Bash(mkdir:*)",
-      "Bash(cat:*)"
-    ],
-    "deny": [],
-    "ask": []
-  },
-  "hooks": {}
-}
-```
-
-### Full Template (--full)
-
-Includes everything from standard template plus:
-
-```json
-{
-  "permissions": {
-    "allow": [
-      "Bash(git:*)",
-      "Bash(ls:*)",
-      "Bash(mkdir:*)",
-      "Bash(cat:*)",
-      "Bash(wc:*)",
-      "Bash(tree:*)",
-      "Bash(curl:*)",
-      "Bash(wget:*)",
-      "Bash(rg:*)",
-      "Bash(fd:*)",
-      "Bash(fzf:*)",
-      "Bash(z:*)",
-      "Bash(zoxide:*)",
-      "Bash(br:*)",
-      "Bash(broot:*)",
-      "Bash(ast-grep:*)",
-      "Bash(sg:*)",
-      "Bash(bat:*)",
-      "Bash(eza:*)",
-      "Bash(delta:*)",
-      "Bash(difft:*)",
-      "Bash(jq:*)",
-      "Bash(yq:*)",
-      "Bash(sd:*)",
-      "Bash(lazygit:*)",
-      "Bash(gh:*)",
-      "Bash(tokei:*)",
-      "Bash(uv:*)",
-      "Bash(just:*)",
-      "Bash(http:*)",
-      "Bash(procs:*)",
-      "Bash(hyperfine:*)",
-      "Bash(npm:*)",
-      "Bash(node:*)",
-      "Bash(python:*)",
-      "Bash(pip:*)",
-      "Bash(docker:*)",
-      "Bash(docker-compose:*)",
-      "Bash(kubectl:*)",
-      "Bash(helm:*)",
-      "Bash(terraform:*)",
-      "Bash(aws:*)",
-      "Bash(gcloud:*)",
-      "Bash(az:*)",
-      "Bash(wrangler:*)",
-      "Bash(powershell -Command:*)",
-      "Bash(powershell.exe:*)"
-    ],
-    "deny": [],
-    "ask": []
-  },
-  "hooks": {}
-}
-```
-
-## Notes
-
-- Permissions are project-local (don't affect other projects)
-- Global permissions in `~/.claude/settings.json` still apply
-- Project permissions can only ADD to global, not remove
-- Restart Claude Code session for changes to take effect
-- Tools from: https://github.com/0xDarkMatter/dev-shell-tools

+ 227 - 0
commands/init-tools.md

@@ -0,0 +1,227 @@
+---
+name: init-tools
+description: "Initialize Claude Code with dev-shell-tools. Creates permissions, rules, and tool preferences in .claude/ directory."
+---
+
+# /init-tools
+
+Initialize Claude Code with modern dev-shell-tools for a comfortable development experience.
+
+## What This Does
+
+**Installs complete dev environment setup:**
+
+1. **Permissions** (`.claude/settings.local.json`) - Pre-approved CLI tools
+2. **Rules** (`.claude/rules/cli-tools.md`) - Instructions to prefer modern tools
+
+Tools from [dev-shell-tools](https://github.com/0xDarkMatter/dev-shell-tools):
+
+**Core Tools:**
+- **Git**: Full git access, lazygit, gh (GitHub CLI)
+- **File ops**: ls, mkdir, cat, wc, tree, eza, bat
+- **Search**: rg (ripgrep), fd, fzf, ast-grep/sg
+- **Navigation**: zoxide/z, broot/br
+- **Data processing**: jq, yq, sd
+- **Diff tools**: delta, difft (difftastic)
+- **Analysis**: tokei, procs, hyperfine
+
+**Dev Tools:**
+- **Package managers**: npm, node, python, uv, pip
+- **Task runners**: just
+- **Network**: curl, http (httpie)
+- **Windows**: powershell
+
+## Execution Flow
+
+```
+/init-tools
+    |
+    +-- Check for existing .claude/ files
+    |     +-- If exists: Ask to overwrite or skip
+    |     +-- If not: Proceed
+    |
+    +-- Create .claude directory
+    +-- Create .claude/rules directory
+    |
+    +-- Write settings.local.json (permissions)
+    +-- Write rules/cli-tools.md (tool preferences)
+```
+
+## Instructions
+
+### Step 1: Check for existing settings
+
+```bash
+ls -la .claude/settings.local.json 2>/dev/null
+ls -la .claude/rules/cli-tools.md 2>/dev/null
+```
+
+If files exist, ask user:
+- **Overwrite**: Replace entirely
+- **Skip**: Keep existing, do nothing
+
+### Step 2: Create directories
+
+```bash
+mkdir -p .claude/rules
+```
+
+### Step 3: Write permissions file
+
+Write to `.claude/settings.local.json`:
+
+```json
+{
+  "permissions": {
+    "allow": [
+      "Bash(git:*)",
+      "Bash(ls:*)",
+      "Bash(mkdir:*)",
+      "Bash(cat:*)",
+      "Bash(wc:*)",
+      "Bash(tree:*)",
+      "Bash(curl:*)",
+      "Bash(rg:*)",
+      "Bash(fd:*)",
+      "Bash(fzf:*)",
+      "Bash(z:*)",
+      "Bash(zoxide:*)",
+      "Bash(br:*)",
+      "Bash(broot:*)",
+      "Bash(ast-grep:*)",
+      "Bash(sg:*)",
+      "Bash(bat:*)",
+      "Bash(eza:*)",
+      "Bash(delta:*)",
+      "Bash(difft:*)",
+      "Bash(jq:*)",
+      "Bash(yq:*)",
+      "Bash(sd:*)",
+      "Bash(lazygit:*)",
+      "Bash(gh:*)",
+      "Bash(tokei:*)",
+      "Bash(uv:*)",
+      "Bash(just:*)",
+      "Bash(http:*)",
+      "Bash(procs:*)",
+      "Bash(hyperfine:*)",
+      "Bash(npm:*)",
+      "Bash(node:*)",
+      "Bash(python:*)",
+      "Bash(pip:*)",
+      "Bash(powershell -Command:*)",
+      "Bash(powershell.exe:*)"
+    ],
+    "deny": [],
+    "ask": []
+  },
+  "hooks": {}
+}
+```
+
+### Step 4: Write rules file
+
+Write to `.claude/rules/cli-tools.md`:
+
+```markdown
+# CLI Tool Preferences (dev-shell-tools)
+
+ALWAYS prefer modern CLI tools over traditional alternatives.
+
+## File Search & Navigation
+
+| Instead of | Use | Why |
+|------------|-----|-----|
+| `find` | `fd` | 5x faster, respects .gitignore |
+| `grep` | `rg` (ripgrep) | 10x faster, respects .gitignore |
+| `ls` | `eza` | Git status, tree view |
+| `cat` | `bat` | Syntax highlighting |
+| `cd` + manual | `z`/`zoxide` | Frecent directories |
+| `tree` | `eza --tree` | Interactive |
+
+## Data Processing
+
+| Instead of | Use |
+|------------|-----|
+| `sed` | `sd` |
+| Manual JSON | `jq` |
+| Manual YAML | `yq` |
+
+## Git Operations
+
+| Instead of | Use |
+|------------|-----|
+| `git diff` | `delta` or `difft` |
+| Manual git | `lazygit` |
+| GitHub web | `gh` |
+
+## Code Analysis
+
+- Line counts: `tokei`
+- AST search: `ast-grep` / `sg`
+- Benchmarks: `hyperfine`
+
+## Python
+
+| Instead of | Use |
+|------------|-----|
+| `pip` | `uv` |
+| `python -m venv` | `uv venv` |
+
+## Task Running
+
+Prefer `just` over Makefiles.
+
+Reference: https://github.com/0xDarkMatter/dev-shell-tools
+```
+
+### Step 5: Confirm
+
+Report to user:
+```
+Initialized Claude Code with dev-shell-tools:
+
+Created:
+  .claude/settings.local.json  (37 tool permissions)
+  .claude/rules/cli-tools.md   (modern tool preferences)
+
+Claude will now:
+  - Auto-approve dev-shell-tools commands
+  - Prefer fd over find, rg over grep, bat over cat, etc.
+
+To customize: edit files in .claude/
+To add to git: git add .claude/
+```
+
+## Options
+
+| Flag | Effect |
+|------|--------|
+| `--force` | Overwrite existing without asking |
+| `--perms-only` | Only install permissions, skip rules |
+| `--rules-only` | Only install rules, skip permissions |
+| `--minimal` | Minimal permissions (git, ls, cat, mkdir only) |
+| `--full` | Add cloud/container tools (docker, kubectl, terraform, etc.) |
+
+### Full Template (--full)
+
+Adds to permissions:
+```json
+"Bash(docker:*)",
+"Bash(docker-compose:*)",
+"Bash(kubectl:*)",
+"Bash(helm:*)",
+"Bash(terraform:*)",
+"Bash(aws:*)",
+"Bash(gcloud:*)",
+"Bash(az:*)",
+"Bash(wrangler:*)"
+```
+
+## Notes
+
+- Permissions are project-local (don't affect other projects)
+- Rules instruct Claude to prefer modern tools
+- Global settings in `~/.claude/` still apply
+- Restart Claude Code session for changes to take effect
+- Tools from: https://github.com/0xDarkMatter/dev-shell-tools

+ 112 - 0
templates/rules/cli-tools.md

@@ -0,0 +1,112 @@
+# CLI Tool Preferences
+
+Prefer modern, fast CLI tools over traditional alternatives. These tools are pre-approved in permissions.
+
+## File Search & Navigation
+
+| Instead of | Use | Why |
+|------------|-----|-----|
+| `find` | `fd` | 5x faster, simpler syntax, respects .gitignore |
+| `grep` | `rg` (ripgrep) | 10x faster, respects .gitignore, better defaults |
+| `ls` | `eza` | Git status, icons, tree view built-in |
+| `cat` | `bat` | Syntax highlighting, line numbers, git integration |
+| `cd` + manual | `z`/`zoxide` | Jump to frecent directories |
+| `tree` | `broot` or `eza --tree` | Interactive, filterable |
+
+## Examples
+
+```bash
+# Find files (use fd, not find)
+fd "\.ts$"                    # Find TypeScript files
+fd -e py                      # Find by extension
+fd -H config                  # Include hidden files
+
+# Search content (use rg, not grep)
+rg "TODO"                     # Search for TODO
+rg -t ts "function"           # Search in TypeScript files
+rg -l "error"                 # List files with matches
+
+# List files (use eza, not ls)
+eza -la --git                 # List with git status
+eza --tree --level=2          # Tree view
+
+# View files (use bat, not cat)
+bat src/index.ts              # Syntax highlighted
+bat -l json data.txt          # Force language
+
+# Navigate (use z, not cd)
+z project                     # Jump to frecent "project" dir
+```
+
+## Data Processing
+
+| Instead of | Use | Why |
+|------------|-----|-----|
+| `sed` | `sd` | Simpler syntax, no escaping headaches |
+| Manual JSON | `jq` | Structured queries, transformations |
+| Manual YAML | `yq` | Same as jq but for YAML/TOML |
+
+```bash
+# Find and replace (use sd, not sed)
+sd 'oldText' 'newText' file.txt
+sd -f 'pattern' 'replacement' **/*.ts
+
+# JSON processing
+jq '.dependencies | keys' package.json
+jq -r '.scripts | to_entries[] | "\(.key): \(.value)"' package.json
+
+# YAML processing
+yq '.services | keys' docker-compose.yml
+```
+
+## Git Operations
+
+| Instead of | Use | Why |
+|------------|-----|-----|
+| `git diff` | `delta` or `difft` | Syntax highlighting, side-by-side |
+| `git log/status/add` manually | `lazygit` | Full TUI, faster workflow |
+| GitHub web | `gh` | CLI for PRs, issues, actions |
+
+```bash
+# Better diffs
+git diff | delta              # Syntax highlighted diff
+difft file1.ts file2.ts       # Semantic AST diff
+
+# GitHub operations
+gh pr create                  # Create PR from CLI
+gh pr list                    # List PRs
+gh issue list                 # List issues
+```
+
+## Code Analysis
+
+| Task | Tool | Example |
+|------|------|---------|
+| Line counts | `tokei` | `tokei src/` |
+| AST search | `ast-grep` | `sg -p 'console.log($_)' -l ts` |
+| Benchmarks | `hyperfine` | `hyperfine 'npm test' 'yarn test'` |
+| Process view | `procs` | `procs --tree` |
+
+## Python
+
+| Instead of | Use | Why |
+|------------|-----|-----|
+| `pip` | `uv` | 10-100x faster installs |
+| `python -m venv` | `uv venv` | Faster venv creation |
+| `pip install -r` | `uv pip install -r` | Parallel, cached |
+
+```bash
+uv venv .venv                 # Create venv
+uv pip install -r requirements.txt
+uv pip install pandas         # Install package
+```
+
+## Task Running
+
+Prefer `just` over Makefiles for task running:
+
+```bash
+just                          # List available tasks
+just test                     # Run test task
+just build                    # Run build task
+```