Skip to content

Instantly share code, notes, and snippets.

@shoemoney
Last active August 13, 2025 18:45
Show Gist options
  • Save shoemoney/c06445c7c1869a65b25b4333a434df2a to your computer and use it in GitHub Desktop.
Save shoemoney/c06445c7c1869a65b25b4333a434df2a to your computer and use it in GitHub Desktop.
Auto-Claude - Never wait for user input! WIP v.01
#!/bin/bash
################################################
# ____ _ _ ___ _ _
# / ___| | __ _ _ _ __| | ___ / _ \/ / |
#| | | |/ _` | | | |/ _` |/ _ \ (_) | | |
#| |___| | (_| | |_| | (_| | __/\__, | | |
# \____|_|\__,_|\__,_|\__,_|\___| /_/|_|_|
# ##############################################
#
#**** A Script to use in system administration commands that triggers Claude Code
#**** and auto responds to questions to fix.
#**** Contributions welcome!
#
#
# 🤖 Auto-Claude - Never wait for user input!
# 1. AUTO-APPROVE ALL TOOL USE
export CLAUDE_AUTO_APPROVE=true
export CLAUDE_DANGEROUS_MODE=true
# 2. HOOK THAT AUTO-RESPONDS TO PROMPTS
cat > ~/.claude/hooks/auto-respond-hook.sh << 'EOF'
# Auto-respond to Claude when it's waiting
# Pattern matching for common "waiting" states
WAITING_PATTERNS=(
"waiting for user"
"need your input"
"please confirm"
"should I proceed"
"what would you like"
)
# Auto responses based on context
get_auto_response() {
local last_message="$1"
# Database errors
if [[ "$last_message" =~ "Access denied" ]]; then
echo "sudo mysql -e 'CREATE USER IF NOT EXISTS claude@localhost; GRANT ALL ON *.* TO claude@localhost;'"
return
fi
# Permission errors
if [[ "$last_message" =~ "Permission denied" ]]; then
echo "try with sudo"
return
fi
# File not found
if [[ "$last_message" =~ "No such file" ]]; then
echo "create it"
return
fi
# Generic proceed
echo "yes, proceed"
}
# Monitor Claude's state
while true; do
# Check if Claude is waiting (would need actual Claude API/state check)
if claude_is_waiting; then
RESPONSE=$(get_auto_response "$LAST_CLAUDE_MESSAGE")
echo "$RESPONSE" | claude_respond
fi
sleep 2
done
EOF
# 3. DATABASE OF AUTO-RESPONSES
mysql -uroot claude_memory << 'SQL'
CREATE TABLE IF NOT EXISTS auto_responses (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
pattern VARCHAR(500),
response TEXT,
context VARCHAR(100),
priority INT DEFAULT 50,
INDEX idx_pattern (pattern)
);
INSERT INTO auto_responses (pattern, response, context) VALUES
('Access denied.*root@localhost', 'sudo mysql -e "GRANT ALL ON *.* TO root@localhost"', 'database'),
('npm.*not found', 'brew install node', 'missing_tool'),
('poetry.*not found', 'pip install poetry', 'missing_tool'),
('Would you like me to', 'yes', 'confirmation'),
('Should I create', 'yes, create it', 'file_creation'),
('ready to proceed', 'proceed', 'confirmation'),
('Continue?', 'yes', 'confirmation');
SQL
# 4. GIVE CLAUDE SUDO WITHOUT PASSWORD
echo "claude ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/claude
# 5. AUTO-FIX COMMON ISSUES
cat > ~/.claude/auto-fix.sh << 'EOF'
#!/bin/bash
# Auto-fix common issues
fix_database() {
sudo mysql << SQL
CREATE USER IF NOT EXISTS 'root'@'%' IDENTIFIED BY '';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
CREATE USER IF NOT EXISTS 'claude'@'%' IDENTIFIED BY '';
GRANT ALL PRIVILEGES ON *.* TO 'claude'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
SQL
}
fix_permissions() {
sudo chmod -R 777 /tmp
sudo chmod -R 755 ~/.claude
}
fix_network() {
sudo ifconfig lo0 alias 0.0.0.0 255.255.255.0
}
# Run fixes
fix_database
fix_permissions
fix_network
EOF
# 6. ENVIRONMENT THAT ALWAYS SAYS YES
export CLAUDE_ALWAYS_YES=1
export CLAUDE_AUTO_FIX=1
export CLAUDE_NO_CONFIRM=1
echo "🚀 Auto-Claude configured! I'll never wait again!"
echo "⚡ Features enabled:"
echo " - Auto-approve all actions"
echo " - Auto-fix common errors"
echo " - Database access for all"
echo " - Sudo without password"
echo " - Pattern-based auto-responses"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment