Chế Độ YOLO

Cấu hình Claude Code để chạy công cụ tự động mà không cần nhắc nhở liên tục.

Tính Năng Cho Power User
Các cài đặt này cho phép Claude thực thi lệnh trên máy của bạn mà không cần sự chấp thuận rõ ràng của bạn cho mỗi bước. Sử dụng cẩn thận. Bạn đang đặt niềm tin lớn vào AI.
1

Cách Nhanh Nhất (Full Bypass)

Thêm dòng này vào cài đặt cục bộ của dự án để cho phép TẤT CẢ công cụ chạy tự động.

File:
<project>/.claude/settings.local.json (project-local)
{
  "permissions": {
    "defaultMode": "bypassPermissions"
  }
}
CẢNH BÁO

Điều này trao cho AI quyền tự chủ hoàn toàn. Trong trường hợp hiếm hoi, nó có thể chạy các lệnh phá hủy như rm -rf ... nếu nó bị ảo giác hoặc hiểu sai tác vụ. Chỉ làm điều này trong các môi trường cô lập hoặc nếu bạn có bản sao lưu tốt (git).

2

Cấu Hình Được Đề Xuất (Cách An Toàn Hơn)

Cho phép tất cả lệnh theo mặc định, nhưng chặn các thao tác nguy hiểm có thể gây thiệt hại không thể khôi phục.

File:
<project>/.claude/settings.local.json (project-local)
{
  "permissions": {
    "allow": [
      "Bash(*)",
      "Read(*)",
      "Write(*)"
    ],
    "deny": [
      "Bash(:(){:|:&};:)",
      "Bash(:(){ :|:& };:)",
      "Bash(bomb(){ bomb|bomb& };bomb)",

      "Bash(dd if=/dev/zero of=/dev/sd*:*)",
      "Bash(dd if=/dev/zero of=/dev/disk*:*)",
      "Bash(dd if=/dev/random of=/dev/sd*:*)",
      "Bash(dd if=/dev/urandom of=/dev/sd*:*)",
      "Bash(cat /dev/zero > /dev/sd*:*)",
      "Bash(cat /dev/urandom > /dev/sd*:*)",
      "Bash(shred /dev/sd*:*)",
      "Bash(shred -vfz -n *:*)",
      "Bash(> /dev/sda:*)",
      "Bash(mkfs.:*::*)",
      "Bash(fdisk:*)",
      "Bash(parted:*)",
      "Bash(diskutil eraseDisk:*)",

      "Bash(rm ~/)",
      "Bash(rm /)",
      "Bash(rm -rf /:*)",
      "Bash(rm -rf ~:*)",
      "Bash(rm -rf /*:*)",
      "Bash(rm -rf .*:*)",
      "Bash(sudo rm -rf :*::*)",
      "Bash(shred:*)",
      "Bash(mv * /dev/null:*)",
      "Bash(mv ~/* /dev/null:*)",
      "Bash(mv /* /dev/null:*)",
      "Bash(find / -delete:*)",
      "Bash(find / -exec rm -rf {} \;:*)",

      "Bash(chown -R /:*)",
      "Bash(chown -R root:root /:*)",
      "Bash(chmod -R 0 /:*)",
      "Bash(chmod -R 777 /:*)",
      "Bash(chmod 777 -R /:*)",
      "Bash(chmod -R 000 /:*)",
      "Bash(chmod 000 -R /:*)",

      "Bash(curl*|*sh:*)",
      "Bash(wget*|*sh:*)",
      "Bash(curl * | bash:*)",
      "Bash(curl * | sh:*)",
      "Bash(wget * | bash:*)",
      "Bash(wget * | sh:*)",
      "Bash(curl -s * | bash:*)",
      "Bash(wget -q * | bash:*)",
      "Bash(curl -fsSL * | bash:*)",
      "Bash(wget -qO- * | bash:*)",
      "Bash(eval $*:*)",

      "Bash(mysql * DROP DATABASE:*)",
      "Bash(mysql * DROP TABLE:*)",
      "Bash(mysql * TRUNCATE:*)",
      "Bash(mysqladmin drop:*)",

      "Bash(psql * DROP DATABASE:*)",
      "Bash(psql * DROP TABLE:*)",
      "Bash(psql * TRUNCATE:*)",
      "Bash(dropdb:*)",

      "Bash(mongo * --eval *dropDatabase*:*)",
      "Bash(mongosh * --eval *dropDatabase*:*)",
      "Bash(mongo * dropDatabase:*)",

      "Bash(redis-cli FLUSHALL:*)",
      "Bash(redis-cli FLUSHDB:*)",

      "Bash(prisma db push)",
      "Bash(npx prisma db push)",
      "Bash(prisma migrate reset:*)",
      "Bash(npm run db:push)",
      "Bash(bun run db:push)",
      "Bash(pnpm run db:push)",
      "Bash(yarn db:push:*)",
      "Bash(yarn prisma db push:*)",
      "Bash(yarn prisma migrate reset:*)",
      "Bash(pnpm prisma migrate reset:*)",
      "Bash(drizzle-kit drop:*)",
      "Bash(npm run db:drop:*)",
      "Bash(typeorm schema:drop:*)",
      "Bash(sequelize db:drop:*)",

      "Bash(rails db:drop:*)",
      "Bash(rails db:reset:*)",
      "Bash(rails db:migrate:reset:*)",
      "Bash(rails db:schema:load:*)",
      "Bash(rails db:seed:replant:*)",
      "Bash(bundle exec rake db:drop:*)",
      "Bash(bundle exec rake db:reset:*)",
      "Bash(rake db:drop:*)",
      "Bash(rake db:reset:*)",
      "Bash(rails credentials:edit:*)",
      "Bash(rails secret:*)",
      "Bash(rails runner*eval*:*)",
      "Bash(ruby -e*system*:*)",
      "Bash(ruby -e*exec*:*)",
      "Bash(irb -e*:*)",
      "Bash(gem uninstall -aIx:*)",
      "Bash(bundle exec rails destroy:*)",

      "Bash(kubectl delete namespace --all:*)",
      "Bash(kubectl delete ns --all:*)",
      "Bash(kubectl delete all --all:*)",
      "Bash(kubectl delete all --all-namespaces:*)",
      "Bash(kubectl delete pods --all:*)",
      "Bash(kubectl delete deployments --all:*)",
      "Bash(kubectl delete pvc --all:*)",
      "Bash(kubectl delete pv --all:*)",
      "Bash(kubectl delete secrets --all:*)",
      "Bash(kubectl delete configmaps --all:*)",
      "Bash(helm uninstall --all:*)",
      "Bash(helm delete --purge:*)",

      "Bash(docker system prune -af:*)",
      "Bash(docker volume rm -f :*::*)",
      "Bash(docker rm -f $(docker ps -aq):*)",
      "Bash(docker rmi -f $(docker images -aq):*)",
      "Bash(docker stop $(docker ps -aq):*)",
      "Bash(docker kill $(docker ps -aq):*)",
      "Bash(docker stop $(docker ps -q):*)",
      "Bash(docker kill $(docker ps -q):*)",
      "Bash(docker network prune -f:*)",
      "Bash(docker volume prune -f:*)",
      "Bash(docker image prune -af:*)",
      "Bash(docker container prune -f:*)",
      "Bash(docker-compose down -v:*)",
      "Bash(docker compose down -v:*)",
      "Bash(docker-compose down -v --rmi all:*)",
      "Bash(docker run --privileged:*)",
      "Bash(docker run -v /:/host:*)",

      "Bash(git reset --hard:*)",
      "Bash(git clean -fdx:*)",
      "Bash(git push --force:*)",
      "Bash(git push origin --delete:*)",
      "Bash(git push --force-with-lease:*)",
      "Bash(git branch -D:*)",
      "Bash(git reflog expire --expire=now --all:*)",
      "Bash(git gc --prune=now:*)",
      "Bash(git filter-branch:*)",
      "Bash(git rebase -i --root:*)",

      "Bash(shutdown:*)",
      "Bash(reboot:*)",
      "Bash(systemctl poweroff:*)",
      "Bash(init 0:*)",
      "Bash(init 6:*)",
      "Bash(telinit 0:*)",
      "Bash(halt:*)",
      "Bash(poweroff:*)",
      "Bash(echo b > /proc/sysrq-trigger:*)",
      "Bash(echo c > /proc/sysrq-trigger:*)",
      "Bash(echo o > /proc/sysrq-trigger:*)",
      "Bash(crontab -r:*)",
      "Bash(rm /var/spool/cron/*:*)",

      "Bash(iptables -F:*)",
      "Bash(iptables --flush:*)",
      "Bash(iptables -X:*)",
      "Bash(ip6tables -F:*)",
      "Bash(ip6tables --flush:*)",
      "Bash(ufw disable:*)",
      "Bash(firewall-cmd --panic-on:*)",
      "Bash(nft flush ruleset:*)",

      "Bash(cat /etc/shadow:*)",
      "Bash(cat ~/.ssh/id_rsa:*)",
      "Bash(cat ~/.aws/credentials:*)",
      "Bash(cat ~/.git-credentials:*)",

      "Bash(rm -rf /var/log/*:*)",
      "Bash(> /var/log/*:*)",
      "Bash(truncate -s 0 /var/log/*:*)",
      "Bash(shred /var/log/*:*)",
      "Bash(history -c:*)",
      "Bash(cat /dev/null > ~/.bash_history:*)",

      "Bash(apt-get remove --purge *:*)",
      "Bash(apt remove --purge *:*)",
      "Bash(yum remove *:*)",
      "Bash(dnf remove *:*)",
      "Bash(pacman -Rns *:*)",

      "Bash(kill -9:*)",
      "Bash(killall:*)",
      "Bash(kill -9 -1:*)",
      "Bash(killall -9 *:*)",
      "Bash(pkill -9 *:*)",
      "Bash(kill -SIGKILL -1:*)",

      "Bash(aws s3 rm --recursive s3://*:*)",
      "Bash(aws ec2 terminate-instances:*)",
      "Bash(aws rds delete-db-instance:*)",
      "Bash(aws cloudformation delete-stack:*)",

      "Bash(gcloud compute instances delete:*)",
      "Bash(gsutil rm -r gs://*:*)",
      "Bash(gcloud sql instances delete:*)",

      "Bash(az group delete:*)",
      "Bash(az vm delete:*)",
      "Bash(az storage blob delete-batch:*)",

      "Bash(terraform destroy -auto-approve:*)",
      "Bash(terraform apply -destroy:*)",

      "Bash(npm publish:*)",
      "Bash(pnpm publish:*)",

      "Bash(export HISTSIZE=0:*)",
      "Bash(unset HISTFILE:*)",
      "Bash(set +o history:*)",
      "Bash(ln -sf /dev/null /etc/*:*)",
      "Bash(swapoff -a:*)",
      "Bash(mkswap /dev/sd*:*)"
    ]
  }
}

Cấu hình này sử dụng wildcard để cho phép tất cả thao tác Bash, Read và Write, trong khi danh sách deny chặn các lệnh phá hủy như xóa database, force push và thay đổi hệ thống.

Tham khảo: Danh Sách Lệnh Bổ Sung

Để xem tài liệu đầy đủ về phạm vi quyền và cú pháp, hãy truy cập Tài liệu Chính thức của Claude Code