diff --git a/claude-code-full-guide/.claude/agents/documentation-manager.md b/claude-code-full-guide/.claude/agents/documentation-manager.md index fb88f89..a0728c0 100644 --- a/claude-code-full-guide/.claude/agents/documentation-manager.md +++ b/claude-code-full-guide/.claude/agents/documentation-manager.md @@ -1,6 +1,6 @@ --- name: documentation-manager -description: "Expert documentation specialist. Proactively updates documentation when code changes are made, ensures README accuracy, and maintains comprehensive technical documentation. Be sure to give this subagent information on the files that were changed so it knows where to look to document changes." +description: "Expert documentation specialist. Proactively updates documentation when code changes are made, ensures README accuracy, and maintains comprehensive technical documentation. Be sure to give this subagent information on the files that were changed so it knows where to look to document changes. Always call this agent after there are code changes." tools: Read, Write, Edit, MultiEdit, Grep, Glob, ls --- diff --git a/claude-code-full-guide/.claude/hooks/example-hook-config.json b/claude-code-full-guide/.claude/hooks/example-hook-config.json index 3960c38..1a90cdc 100644 --- a/claude-code-full-guide/.claude/hooks/example-hook-config.json +++ b/claude-code-full-guide/.claude/hooks/example-hook-config.json @@ -6,8 +6,8 @@ "hooks": [ { "type": "command", - "command": ".claude/hooks/format-after-edit.sh", - "description": "Automatically format code after file edits" + "command": ".claude/hooks/log-tool-usage.sh", + "description": "Automatically logs file edits" } ] } diff --git a/claude-code-full-guide/.claude/hooks/format-after-edit.sh b/claude-code-full-guide/.claude/hooks/format-after-edit.sh deleted file mode 100644 index 5c50e75..0000000 --- a/claude-code-full-guide/.claude/hooks/format-after-edit.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -# PostToolUse hook: Automatically format code after file edits -# This hook runs after Edit, Write, or MultiEdit tools to ensure consistent formatting - -# Read the JSON input from stdin -input=$(cat) - -# Extract tool name and file path from the input -tool_name=$(echo "$input" | jq -r '.tool_name // empty') -file_path=$(echo "$input" | jq -r '.tool_input.file_path // empty') - -# Only process if it's a file editing tool and we have a file path -if [[ "$tool_name" =~ ^(Edit|Write|MultiEdit)$ ]] && [[ -n "$file_path" ]]; then - # Determine file extension - extension="${file_path##*.}" - - # Format based on file type - case "$extension" in - js|jsx|ts|tsx) - # JavaScript/TypeScript files - if command -v prettier &> /dev/null; then - echo "Formatting $file_path with Prettier..." >&2 - prettier --write "$file_path" 2>/dev/null || true - elif command -v npx &> /dev/null; then - echo "Formatting $file_path with npx prettier..." >&2 - npx prettier --write "$file_path" 2>/dev/null || true - fi - ;; - py) - # Python files - if command -v black &> /dev/null; then - echo "Formatting $file_path with Black..." >&2 - black "$file_path" 2>/dev/null || true - elif command -v ruff &> /dev/null; then - echo "Formatting $file_path with Ruff..." >&2 - ruff format "$file_path" 2>/dev/null || true - fi - ;; - go) - # Go files - if command -v gofmt &> /dev/null; then - echo "Formatting $file_path with gofmt..." >&2 - gofmt -w "$file_path" 2>/dev/null || true - fi - ;; - rs) - # Rust files - if command -v rustfmt &> /dev/null; then - echo "Formatting $file_path with rustfmt..." >&2 - rustfmt "$file_path" 2>/dev/null || true - fi - ;; - json) - # JSON files - if command -v jq &> /dev/null; then - echo "Formatting $file_path with jq..." >&2 - # Format JSON with jq (careful with large files) - if [[ $(stat -f%z "$file_path" 2>/dev/null || stat -c%s "$file_path" 2>/dev/null) -lt 1048576 ]]; then - jq . "$file_path" > "$file_path.tmp" && mv "$file_path.tmp" "$file_path" 2>/dev/null || true - fi - fi - ;; - esac - - # Log formatting completion - echo "Post-edit formatting completed for $file_path" >&2 -fi - -# Always return success to avoid blocking the tool -echo "{}" \ No newline at end of file diff --git a/claude-code-full-guide/.claude/hooks/log-tool-usage.sh b/claude-code-full-guide/.claude/hooks/log-tool-usage.sh index 2838932..86f6cbc 100644 --- a/claude-code-full-guide/.claude/hooks/log-tool-usage.sh +++ b/claude-code-full-guide/.claude/hooks/log-tool-usage.sh @@ -2,24 +2,13 @@ # PostToolUse hook: Log all tool usage for tracking and debugging # This hook runs after any tool execution to maintain an audit log -# Read the JSON input from stdin -input=$(cat) - -# Extract tool name and basic info -tool_name=$(echo "$input" | jq -r '.tool_name // "unknown"') timestamp=$(date '+%Y-%m-%d %H:%M:%S') # Create logs directory if it doesn't exist mkdir -p .claude/logs # Log the tool usage -echo "[$timestamp] Tool used: $tool_name" >> .claude/logs/tool-usage.log - -# Optionally, you can add more detailed logging -if [[ "$tool_name" =~ ^(Edit|Write|MultiEdit)$ ]]; then - file_path=$(echo "$input" | jq -r '.tool_input.file_path // "unknown"') - echo "[$timestamp] File operation: $tool_name on $file_path" >> .claude/logs/file-operations.log -fi +echo "[$timestamp] Claude made an edit " >> .claude/logs/tool-usage.log # Always return success to avoid blocking tools echo "{}" \ No newline at end of file diff --git a/claude-code-full-guide/README.md b/claude-code-full-guide/README.md index d95ee31..00e6bae 100644 --- a/claude-code-full-guide/README.md +++ b/claude-code-full-guide/README.md @@ -381,7 +381,7 @@ This repository includes a simple hook example in `.claude/hooks/`: 1. **Create hook script** in `.claude/hooks/` 2. **Make it executable**: `chmod +x your-hook.sh` -3. **Add to settings** in `.claude/settings.json`: +3. **Add to settings** in `.claude/settings.local.json`: ```json {