This guide shows how to automatically update the date in your global ~/.claude/CLAUDE.md file every time you start Claude Code, bypassing the broken global hooks system.
Claude Code v1.0.110+ has a bug where global hooks in ~/.claude/settings.json don't execute during session startup. This prevents automatic date updates in your global CLAUDE.md file.
Create a shell function wrapper that intercepts all claude commands and runs the date update script before starting Claude.
Create ~/.claude/update-date.sh:
#!/bin/bash
# Script to update the current date in global CLAUDE.md file
# Only updates if the date is different from today
CLAUDE_MD="$HOME/.claude/CLAUDE.md"
TODAY=$(date +%Y-%m-%d)
# Check if CLAUDE.md exists
if [[ ! -f "$CLAUDE_MD" ]]; then
echo "CLAUDE.md not found at $CLAUDE_MD"
exit 1
fi
# Get current date from file
CURRENT_DATE=$(grep -o '\*\*Current date\*\*: [0-9-]*' "$CLAUDE_MD" | sed 's/\*\*Current date\*\*: //')
# Only update if date is different
if [[ "$CURRENT_DATE" != "$TODAY" ]]; then
# Use sed to update the date line
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS sed syntax
sed -i '' "s/\*\*Current date\*\*: [0-9-]*/\*\*Current date\*\*: $TODAY/" "$CLAUDE_MD"
else
# Linux sed syntax
sed -i "s/\*\*Current date\*\*: [0-9-]*/\*\*Current date\*\*: $TODAY/" "$CLAUDE_MD"
fi
echo "Updated CLAUDE.md date from $CURRENT_DATE to $TODAY"
else
echo "Date already current: $TODAY"
fiMake it executable:
chmod +x ~/.claude/update-date.shAdd this function to your ~/.zshrc (or ~/.bashrc if using bash):
# Claude wrapper function that auto-updates date
claude() {
# Update date in global CLAUDE.md before starting Claude
~/.claude/update-date.sh
# Call the actual claude command with all arguments
command claude "$@"
}source ~/.zshrc- Intercepts all
claudecommands: The function runs before the actual Claude Code CLI - Updates date automatically: Runs the update script every time
- Passes through all arguments: Uses
command claude "$@"to call the real Claude with all original arguments - Works globally: Functions in any directory, unlike project-specific hooks
The wrapper function preserves all arguments, so your yolo mode setup continues to work:
claude --skip-dangerously # Still works exactly the sameYou can also create an alias for convenience:
# Add this to your ~/.zshrc for easy yolo mode access
alias clauded="claude --skip-dangerously"Test the setup:
- Manually change the date in
~/.claude/CLAUDE.mdto an old date - Run any
claudecommand - Check that the date was updated automatically
- ✅ Always works: No dependency on broken global hooks
- ✅ Transparent: Use
claudecommand normally - ✅ Efficient: Only updates when date actually changes
- ✅ Cross-platform: Works on macOS and Linux
- ✅ Argument preservation: All Claude flags and options work unchanged
Script not running?
- Check that
~/.claude/update-date.shis executable:ls -la ~/.claude/update-date.sh - Verify the function is loaded:
type claudeshould show it's a function
Date not updating?
- Manually test the script:
~/.claude/update-date.sh - Check your CLAUDE.md has the expected format:
**Current date**: YYYY-MM-DD
Function not working?
- Reload your shell:
source ~/.zshrc - Check for syntax errors:
zsh -n ~/.zshrc