mirror of
https://github.com/coleam00/context-engineering-intro.git
synced 2025-12-17 17:55:29 +00:00
Changes for Claude Code resources
This commit is contained in:
parent
5597e61d36
commit
4e1240a0b3
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: documentation-manager
|
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
|
tools: Read, Write, Edit, MultiEdit, Grep, Glob, ls
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@ -6,8 +6,8 @@
|
|||||||
"hooks": [
|
"hooks": [
|
||||||
{
|
{
|
||||||
"type": "command",
|
"type": "command",
|
||||||
"command": ".claude/hooks/format-after-edit.sh",
|
"command": ".claude/hooks/log-tool-usage.sh",
|
||||||
"description": "Automatically format code after file edits"
|
"description": "Automatically logs file edits"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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 "{}"
|
|
||||||
@ -2,24 +2,13 @@
|
|||||||
# PostToolUse hook: Log all tool usage for tracking and debugging
|
# PostToolUse hook: Log all tool usage for tracking and debugging
|
||||||
# This hook runs after any tool execution to maintain an audit log
|
# 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')
|
timestamp=$(date '+%Y-%m-%d %H:%M:%S')
|
||||||
|
|
||||||
# Create logs directory if it doesn't exist
|
# Create logs directory if it doesn't exist
|
||||||
mkdir -p .claude/logs
|
mkdir -p .claude/logs
|
||||||
|
|
||||||
# Log the tool usage
|
# Log the tool usage
|
||||||
echo "[$timestamp] Tool used: $tool_name" >> .claude/logs/tool-usage.log
|
echo "[$timestamp] Claude made an edit " >> .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
|
|
||||||
|
|
||||||
# Always return success to avoid blocking tools
|
# Always return success to avoid blocking tools
|
||||||
echo "{}"
|
echo "{}"
|
||||||
@ -381,7 +381,7 @@ This repository includes a simple hook example in `.claude/hooks/`:
|
|||||||
|
|
||||||
1. **Create hook script** in `.claude/hooks/`
|
1. **Create hook script** in `.claude/hooks/`
|
||||||
2. **Make it executable**: `chmod +x your-hook.sh`
|
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
|
```json
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user