# The settings.json That Made Claude Code 10x Faster (Full File Included)
**作者**: darkzodchi
**日期**: 2026-04-29T09:30:40.000Z
**来源**: [https://x.com/zodchiii/status/2049421095350972922](https://x.com/zodchiii/status/2049421095350972922)
---

Every Claude Code user has the same complaint:
"Can I edit this file?" "Can I run this test?"
You click Allow, Allow, Allow, 30 times a session, and lose your flow every single time.
The fix is settings.json.
One file, a few rules, and Claude stops asking permission for the commands you run every day while staying locked out of the commands that could actually break things!
Most people don't know this file exists. The ones who do have a 3-line version that barely does anything. Here's how to set it up properly👇
Before we dive in, I share daily notes on AI & vibe coding in my Telegram channel: https://t.me/zodchixquant🧠

## Where the file lives
Three levels, just like CLAUDE.md:
```
~/.claude/settings.json → Global (every project)
.claude/settings.json → Project (shared with team, in git)
.claude/settings.local.json → Local (personal, gitignored)
```
Global is for permissions you want everywhere. Project is for your team's shared rules. Local is for your personal overrides that shouldn't go into git.
Rules merge across levels. If your global settings allow Bash(npm *) and your project settings deny Bash(npm publish), both apply.
Deny always wins over allow.
## The permission system in 60 seconds
Three arrays control everything:
```
{
"permissions": {
"allow": [],
"deny": [],
"ask": []
}
}
```
allow - Claude uses these tools without asking. No confirmation dialog.
deny - Claude can never use these. Blocked completely.
ask - Claude asks for permission every time.
Evaluation order: deny first, then ask, then allow. First match wins. A deny rule always beats an allow rule for the same tool.
Rule format: ToolName or ToolName(pattern).
```
"Bash" → all bash commands (dangerous)
"Bash(npm install)" → only npm install
"Bash(npm run *)" → any npm run script
"Bash(git *)" → any git command
"Write(src/**)" → write files only in src/
"Read(.env*)" → read any .env file
```
The space before * matters. Bash(ls *) matches ls -la but not lsof. Wildcards are glob patterns, not regex.
📸 ФОТО 1:

## The 5 permission modes
Instead of setting individual rules, you can also set a default mode:
```
{
"permissions": {
"defaultMode": "default"
}
}
```
```
default → asks for everything dangerous
acceptEdits → auto-approves file edits, still asks for bash
plan → read-only, no changes allowed
dontAsk → denies everything not explicitly allowed
bypassPermissions → approves everything (only use in containers/CI)
```
Quick switch during a session: press Shift+Tab to cycle between default, acceptEdits, and plan mode without touching any config.
## What to allow (the safe list)
These are commands you run dozens of times a day. Letting Claude run them without asking saves 5-10 minutes per session:
```
{
"permissions": {
"allow": [
"Read",
"Glob",
"Grep",
"LS",
"Bash(npm run *)",
"Bash(npm install *)",
"Bash(npm test *)",
"Bash(npx tsc *)",
"Bash(npx vitest *)",
"Bash(git status)",
"Bash(git diff *)",
"Bash(git log *)",
"Bash(git add *)",
"Bash(git commit *)",
"Bash(git checkout *)",
"Bash(git branch *)",
"Write(src/**)",
"Edit",
"MultiEdit"
]
}
}
```
Notice the pattern: read operations are fully open (Read, Glob, Grep, LS). Bash commands are allowed only for specific tools (npm, git, test runners). Write access is scoped to src/ only.
## What to deny (the safety net)
These are commands that can cause real damage. Block them no matter what:
```
{
"permissions": {
"deny": [
"Read(.env*)",
"Read(**/secrets/**)",
"Write(.env*)",
"Write(production.*)",
"Write(.github/workflows/*)",
"Bash(rm -rf *)",
"Bash(sudo *)",
"Bash(git push *)",
"Bash(git merge *)",
"Bash(npm publish *)",
"Bash(docker *)",
"Bash(curl * | sh)",
"Bash(wget *)"
]
}
}
```
Key principle: Claude can read your code, write your code, run your tests, and commit changes. But it can never read secrets, push to remote, delete files recursively, or run anything with sudo.
The dangerous operations stay behind the deny wall.
## Adding hooks to settings.json
Settings and hooks live in the same file. Auto-format code after every edit, auto-lint before commits:
```
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write(*.py)",
"hooks": [
{
"type": "command",
"command": "python -m black $file"
}
]
},
{
"matcher": "Write(*.ts)",
"hooks": [
{
"type": "command",
"command": "npx prettier --write $file"
}
]
}
]
}
}
```
Every .py file auto-formats with Black.
Every .ts file auto-formats with Prettier.
No prompts, no manual steps.
## Shared settings for teams
Put project-level settings in .claude/settings.json and commit to git. Your entire team gets the same permissions:
```
{
"permissions": {
"allow": [
"Read",
"Glob",
"Grep",
"Bash(npm run *)",
"Bash(npm test *)"
],
"deny": [
"Read(.env*)",
"Bash(npm publish *)",
"Bash(rm -rf *)",
"Write(production.*)"
],
"defaultMode": "acceptEdits"
}
}
```
New team member clones the repo, opens Claude Code, and everything is pre-configured. No setup, no "which commands should I allow" questions, no risk of someone accidentally allowing Bash(rm -rf *).
Boris Cherny at Anthropic does exactly this: shared settings.json across the team with pre-approved routine commands and blocked risky ones.
## The full file (copy-paste ready)
Complete settings.json for a typical Node.js/TypeScript project.
Copy it to ~/.claude/settings.json for global use or .claude/settings.json for project-specific:
```
{
"permissions": {
"allow": [
"Read",
"Glob",
"Grep",
"LS",
"Edit",
"MultiEdit",
"Write(src/**)",
"Write(tests/**)",
"Write(docs/**)",
"Bash(npm run *)",
"Bash(npm install *)",
"Bash(npm test *)",
"Bash(npx tsc *)",
"Bash(npx vitest *)",
"Bash(npx prettier *)",
"Bash(npx eslint *)",
"Bash(git status)",
"Bash(git diff *)",
"Bash(git log *)",
"Bash(git add *)",
"Bash(git commit *)",
"Bash(git checkout *)",
"Bash(git branch *)",
"Bash(cat *)",
"Bash(head *)",
"Bash(tail *)",
"Bash(wc *)",
"Bash(find *)",
"Bash(echo *)"
],
"deny": [
"Read(.env*)",
"Read(**/secrets/**)",
"Write(.env*)",
"Write(production.*)",
"Write(.github/workflows/*)",
"Write(package-lock.json)",
"Bash(rm -rf *)",
"Bash(sudo *)",
"Bash(git push *)",
"Bash(git merge *)",
"Bash(git rebase *)",
"Bash(npm publish *)",
"Bash(docker *)",
"Bash(curl * | sh)",
"Bash(wget *)",
"Bash(chmod *)",
"Bash(chown *)"
],
"defaultMode": "acceptEdits"
},
"hooks": {
"PostToolUse": [
{
"matcher": "Write(*.ts)",
"hooks": [
{
"type": "command",
"command": "npx prettier --write $file"
}
]
},
{
"matcher": "Write(*.tsx)",
"hooks": [
{
"type": "command",
"command": "npx prettier --write $file"
}
]
}
]
}
}
```
Copy it. Adjust the Write scopes for your folder structure.
Add or remove Bash rules for your stack (swap npm for pnpm, add python commands, whatever).
The deny list stays mostly the same for every project.
## The before and after
BEFORE settings.json:
- 30-40 permission prompts per session
- Click "Allow" on npm install every time
- Accidentally allow rm -rf once and panic
- New team members configure everything manually
- Flow state interrupted every 2 minutes
AFTER settings.json:
- 0-3 permission prompts per session
- Routine commands run instantly
- Dangerous commands are blocked at the config level
- Team shares one file, everyone is pre-configured
- Flow state stays intact
Two minutes of setup. Every session after that is faster.
I share daily notes on AI, finance, and vibe coding in my Telegram channel: https://t.me/zodchixquant
Thanks for reading 🙏🏼

## 相关链接
- [darkzodchi](https://x.com/zodchiii)
- [@zodchiii](https://x.com/zodchiii)
- [4.8K](https://x.com/zodchiii/status/2049421095350972922/analytics)
- [https://t.me/zodchixquant](https://t.me/zodchixquant)
- [https://t.me/zodchixquant](https://t.me/zodchixquant)
- [Upgrade to Premium](https://x.com/i/premium_sign_up)
- [5:30 PM · Apr 29, 2026](https://x.com/zodchiii/status/2049421095350972922)
- [4,874 Views](https://x.com/zodchiii/status/2049421095350972922/analytics)
- [View quotes](https://x.com/zodchiii/status/2049421095350972922/quotes)
---
*导出时间: 2026/4/29 21:09:21*
---
## 中文翻译
# 让 Claude Code 速度提升 10 倍的 settings.json(附完整文件)
**作者**: darkzodchi
**日期**: 2026-04-29T09:30:40.000Z
**来源**: [https://x.com/zodchiii/status/2049421095350972922](https://x.com/zodchiii/status/2049421095350972922)
---

每个 Claude Code 用户都有同样的抱怨:
“我可以编辑这个文件吗?”“我可以运行这个测试吗?”
你点击允许、允许、允许,每次会话要点击 30 次,每次都会打断你的心流。
解决方法就是 settings.json。
只需一个文件,几条规则,Claude 就会停止为你每天运行的命令请求许可,同时仍然被锁定在那些可能真正造成破坏的命令之外!
大多数人不知道这个文件的存在。知道的人通常只有个 3 行的版本,几乎不起作用。下面是如何正确设置它👇
在深入之前,我在我的 Telegram 频道上分享关于 AI 和 vibe coding 的每日笔记:https://t.me/zodchixquant🧠

## 文件位置
三个级别,就像 CLAUDE.md 一样:
```
~/.claude/settings.json → 全局(每个项目)
.claude/settings.json → 项目(与团队共享,在 git 中)
.claude/settings.local.json → 本地(个人,git 忽略)
```
全局用于你希望在所有地方拥有的权限。项目用于你团队的共享规则。本地用于你不希望进入 git 的个人覆盖设置。
规则在各级之间合并。如果你的全局设置允许 `Bash(npm *)`,而项目设置拒绝 `Bash(npm publish)`,两者都会生效。
拒绝总是覆盖允许。
## 60 秒看懂权限系统
三个数组控制一切:
```
{
"permissions": {
"allow": [],
"deny": [],
"ask": []
}
}
```
allow - Claude 使用这些工具无需询问。没有确认对话框。
deny - Claude 永远不能使用这些。完全被阻止。
ask - Claude 每次都请求许可。
评估顺序:先是 deny,然后是 ask,最后是 allow。匹配即停止。对于同一工具,deny 规则总是胜过 allow 规则。
规则格式:ToolName 或 ToolName(pattern)。
```
"Bash" → 所有 bash 命令(危险)
"Bash(npm install)" → 仅 npm install
"Bash(npm run *)" → 任何 npm run 脚本
"Bash(git *)" → 任何 git 命令
"Write(src/**)" → 仅在 src/ 中写入文件
"Read(.env*)" → 读取任何 .env 文件
```
* 前面的空格很重要。`Bash(ls *)` 匹配 `ls -la` 但不匹配 `lsof`。通配符是 glob 模式,不是正则。
📸 ФОТО 1:

## 5 种权限模式
除了设置单独的规则,你还可以设置默认模式:
```
{
"permissions": {
"defaultMode": "default"
}
}
```
```
default → 对所有危险操作进行询问
acceptEdits → 自动批准文件编辑,bash 仍需询问
plan → 只读,不允许任何更改
dontAsk → 拒绝所有未明确允许的操作
bypassPermissions → 批准所有操作(仅限在容器/CI 中使用)
```
会话期间的快速切换:按 Shift+Tab 在 default、acceptEdits 和 plan 模式之间循环,无需触碰任何配置。
## 允许什么(安全列表)
这些是你每天运行几十次的命令。让 Claude 无询问运行它们,每次会话可节省 5-10 分钟:
```
{
"permissions": {
"allow": [
"Read",
"Glob",
"Grep",
"LS",
"Bash(npm run *)",
"Bash(npm install *)",
"Bash(npm test *)",
"Bash(npx tsc *)",
"Bash(npx vitest *)",
"Bash(git status)",
"Bash(git diff *)",
"Bash(git log *)",
"Bash(git add *)",
"Bash(git commit *)",
"Bash(git checkout *)",
"Bash(git branch *)",
"Write(src/**)",
"Edit",
"MultiEdit"
]
}
}
```
注意这个模式:读取操作完全开放(Read, Glob, Grep, LS)。Bash 命令仅允许特定工具(npm, git, 测试运行器)。写入权限范围仅限于 src/。
## 拒绝什么(安全网)
这些是可能造成实际损害的命令。无论如何都要阻止它们:
```
{
"permissions": {
"deny": [
"Read(.env*)",
"Read(**/secrets/**)",
"Write(.env*)",
"Write(production.*)",
"Write(.github/workflows/*)",
"Bash(rm -rf *)",
"Bash(sudo *)",
"Bash(git push *)",
"Bash(git merge *)",
"Bash(npm publish *)",
"Bash(docker *)",
"Bash(curl * | sh)",
"Bash(wget *)"
]
}
}
```
关键原则:Claude 可以读取你的代码,编写你的代码,运行你的测试,并提交更改。但它永远不能读取机密、推送到远程、递归删除文件或使用 sudo 运行任何东西。
危险操作留在拒绝墙之后。
## 向 settings.json 添加钩子
设置和钩子位于同一个文件中。在每次编辑后自动格式化代码,在提交前自动检查:
```
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write(*.py)",
"hooks": [
{
"type": "command",
"command": "python -m black $file"
}
]
},
{
"matcher": "Write(*.ts)",
"hooks": [
{
"type": "command",
"command": "npx prettier --write $file"
}
]
}
]
}
}
```
每个 .py 文件自动使用 Black 格式化。
每个 .ts 文件自动使用 Prettier 格式化。
没有提示,没有手动步骤。
## 团队共享设置
将项目级设置放在 .claude/settings.json 中并提交到 git。你的整个团队将获得相同的权限:
```
{
"permissions": {
"allow": [
"Read",
"Glob",
"Grep",
"Bash(npm run *)",
"Bash(npm test *)"
],
"deny": [
"Read(.env*)",
"Bash(npm publish *)",
"Bash(rm -rf *)",
"Write(production.*)"
],
"defaultMode": "acceptEdits"
}
}
```
新团队成员克隆仓库,打开 Claude Code,一切都已预先配置。无需设置,没有“我应该允许哪些命令”的问题,也没有人意外允许 `Bash(rm -rf *)` 的风险。
Anthropic 的 Boris Cherny 正是这样做的:在团队间共享 settings.json,预批准常规命令并阻止风险操作。
## 完整文件(可直接复制粘贴)
典型 Node.js/TypeScript 项目的完整 settings.json。
将其复制到 ~/.claude/settings.json 用于全局,或 .claude/settings.json 用于项目特定:
```
{
"permissions": {
"allow": [
"Read",
"Glob",
"Grep",
"LS",
"Edit",
"MultiEdit",
"Write(src/**)",
"Write(tests/**)",
"Write(docs/**)",
"Bash(npm run *)",
"Bash(npm install *)",
"Bash(npm test *)",
"Bash(npx tsc *)",
"Bash(npx vitest *)",
"Bash(npx prettier *)",
"Bash(npx eslint *)",
"Bash(git status)",
"Bash(git diff *)",
"Bash(git log *)",
"Bash(git add *)",
"Bash(git commit *)",
"Bash(git checkout *)",
"Bash(git branch *)",
"Bash(cat *)",
"Bash(head *)",
"Bash(tail *)",
"Bash(wc *)",
"Bash(find *)",
"Bash(echo *)"
],
"deny": [
"Read(.env*)",
"Read(**/secrets/**)",
"Write(.env*)",
"Write(production.*)",
"Write(.github/workflows/*)",
"Write(package-lock.json)",
"Bash(rm -rf *)",
"Bash(sudo *)",
"Bash(git push *)",
"Bash(git merge *)",
"Bash(git rebase *)",
"Bash(npm publish *)",
"Bash(docker *)",
"Bash(curl * | sh)",
"Bash(wget *)",
"Bash(chmod *)",
"Bash(chown *)"
],
"defaultMode": "acceptEdits"
},
"hooks": {
"PostToolUse": [
{
"matcher": "Write(*.ts)",
"hooks": [
{
"type": "command",
"command": "npx prettier --write $file"
}
]
},
{
"matcher": "Write(*.tsx)",
"hooks": [
{
"type": "command",
"command": "npx prettier --write $file"
}
]
}
]
}
}
```
复制它。根据你的文件夹结构调整 Write 范围。
为你的技术栈添加或删除 Bash 规则(将 npm 换成 pnpm,添加 python 命令等)。
拒绝列表对于每个项目基本保持不变。
## 前后对比
设置 settings.json 之前:
- 每次会话 30-40 个权限提示
- 每次都要点击“允许”npm install
- 偶尔意外允许 rm -rf 导致恐慌
- 新团队成员手动配置所有内容
- 心流每 2 分钟被打断一次
设置 settings.json 之后:
- 每次会话 0-3 个权限提示
- 常规命令即时运行
- 危险命令在配置级别被阻止
- 团队共享一个文件,每个人都预先配置好
- 心流状态保持完整
两分钟的设置。之后的每次会话都更快。
我在我的 Telegram 频道上分享关于 AI、金融和 vibe coding 的每日笔记:https://t.me/zodchixquant
感谢阅读 🙏🏼

## 相关链接
- [darkzodchi](https://x.com/zodchiii)
- [@zodchiii](https://x.com/zodchiii)
- [4.8K](https://x.com/zodchiii/status/2049421095350972922/analytics)
- [https://t.me/zodchixquant](https://t.me/zodchixquant)
- [https://t.me/zodchixquant](https://t.me/zodchixquant)
- [Upgrade to Premium](https://x.com/i/premium_sign_up)
- [5:30 PM · Apr 29, 2026](https://x.com/zodchiii/status/2049421095350972922)
- [4,874 Views](https://x.com/zodchiii/status/2049421095350972922/analytics)
- [View quotes](https://x.com/zodchiii/status/2049421095350972922/quotes)
---
*导出时间: 2026/4/29 21:09:21*