# Your .claude Folder Is Your AI Operating System
**作者**: Nainsi Dwivedi
**日期**: 2026-05-06T11:18:33.000Z
**来源**: [https://x.com/NainsiDwiv50980/status/2051984960819777641](https://x.com/NainsiDwiv50980/status/2051984960819777641)
---

## Most developers are using 10% of what Claude Code can actually do.
You don’t scale AI coding workflows by writing better prompts.
You scale them by building a system around the agent.
Most people open Claude Code, type a request, get code, and move on.
- Advanced teams do something completely different:
- They create persistent project rules
- Add security hooks
- Build reusable agents
- Separate team config from personal config
- Auto-enforce formatting, testing, and permissions
- Turn Claude into an actual engineering teammate
That’s where .claude/ becomes insanely powerful.

1. The biggest mistake: putting everything in one prompt
Most developers repeatedly explain the same things:
“Use TypeScript”
“Don’t expose errors”
“Follow our API structure”
“Run tests first”
That’s wasted context.
Instead, elite setups move all of that into persistent project memory.
Your repo becomes self-documenting for the AI.
Example:
```
# Project: Acme API
## Architecture
- Express REST API
- PostgreSQL via Prisma
- Handlers in src/handlers/
## Conventions
- Use zod validation
- Return { data, error }
- Never expose stack traces
```
Now Claude already understands:
- your stack
- architecture
- conventions
- testing flow
- formatting rules
- safety boundaries
before you even type a prompt.
That changes everything.
2. Two .claude folders = team brain + personal brain
This is one of the smartest design decisions in Claude Code.
Project .claude/
Shared with the entire team.
```
your-project/.claude/
```
Used for:
- rules
- hooks
- agents
- shared workflows
- security policies
This goes into Git.
Global ~/.claude/
Your personal AI environment.
~/.claude/
Used for:
- personal agents
- preferences
- local overrides
- session memory
Never committed.
This separation is huge because your team gets consistency without losing personal customization.

3. Modular rules are better than giant prompts
Most teams create one giant CLAUDE.md.
Bad idea.
After 300+ lines, nobody maintains it.
The better setup:
```
.claude/rules/
├── code-style.md
├── testing.md
├── api-conventions.md
└── security.md
```
Then scope rules only where needed.
Example:
```
paths:
- "src/api/**/*.ts"
- "src/handlers/**/*.ts"
---
# API Design Rules
- Return { data, error }
- Use zod validation
- Never leak internal errors
```
This keeps instructions:
- smaller
- modular
- maintainable
- context efficient
Your AI becomes dramatically more reliable.
4. Hooks turn Claude from “smart” into “safe”
This is where things get serious.
Hooks let you intercept tool execution before and after Claude acts.
That means you can:
- block dangerous commands
- auto-format edited files
- enforce tests
- reject insecure operations
Example:
```
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "./.claude/hooks/bash-firewall.sh"
}
]
}
]
}
}
```
Now every shell command passes through your firewall first.
That’s enterprise-grade control.

5. The most underrated feature: specialized agents
Most people use one giant general-purpose AI agent.
Bad scaling strategy.
Claude lets you create focused subagents with limited tools and isolated context.
Example:
```
name: code-reviewer
model: sonnet
tools: Read, Grep, Glob
---
You are a senior code reviewer focused on:
- bugs
- edge cases
- maintainability
```
This is insanely powerful because:
- main context stays clean
- tasks become deterministic
- agents specialize deeply
- permissions stay restricted
You stop context pollution completely.
6. Permissions matter more than prompts
One overlooked feature:
```
{
"permissions": {
"allow": [
"Bash(npm run *)",
"Read",
"Edit"
],
"deny": [
"Bash(rm -rf *)",
"Read(./.env)"
]
}
}
```
This is critical.
Because eventually AI agents won’t fail from intelligence problems.
They’ll fail from permission problems.
The teams that survive AI automation will be the teams that build strong operational boundaries.
Not the teams with the fanciest prompts.

Final Thought
Most developers are still “chatting” with AI.
The next wave of developers will orchestrate AI.
Big difference.
The real unlock is not:
> “How do I prompt better?”
It’s:
> “How do I design an environment where the AI consistently behaves correctly?”
That’s what Claude Code is quietly enabling.
And honestly?
Most people haven’t realized how important that shift is yet.
## 相关链接
- [Nainsi Dwivedi](https://x.com/NainsiDwiv50980)
- [@NainsiDwiv50980](https://x.com/NainsiDwiv50980)
- [1.1K](https://x.com/NainsiDwiv50980/status/2051984960819777641/analytics)
- [Upgrade to Premium](https://x.com/i/premium_sign_up)
- [7:18 PM · May 6, 2026](https://x.com/NainsiDwiv50980/status/2051984960819777641)
- [1,100 Views](https://x.com/NainsiDwiv50980/status/2051984960819777641/analytics)
---
*导出时间: 2026/5/6 20:54:23*
---
## 中文翻译
# 你的 .claude 文件夹就是你的 AI 操作系统
**作者**: Nainsi Dwivedi
**日期**: 2026-05-06T11:18:33.000Z
**来源**: [https://x.com/NainsiDwiv50980/status/2051984960819777641](https://x.com/NainsiDwiv50980/status/2051984960819777641)
---

## 大多数开发者只发挥了 Claude Code 10% 的能力。
扩展 AI 编程工作流的关键,不在于写出更好的提示词。
而在于围绕智能体构建一套系统。
大多数人打开 Claude Code,输入指令,拿到代码,然后就结束了。
- 先进的团队做法截然不同:
- 他们创建持久化的项目规则
- 添加安全钩子
- 构建可复用的智能体
- 将团队配置与个人配置分离
- 自动强制执行格式化、测试和权限
- 将 Claude 变成真正的工程队友
这就是 `.claude/` 变得无比强大的地方。

1. 最大的错误:把所有东西塞进一个提示词里
大多数开发者一次又一次地解释同样的事情:
“使用 TypeScript”
“不要暴露错误”
“遵循我们的 API 结构”
“先运行测试”
这完全是浪费上下文。
相反,顶级的配置会将所有这些转移到持久化的项目记忆中。
你的仓库对 AI 来说变成了“自文档化”的。
示例:
```
# 项目: Acme API
## 架构
- Express REST API
- 通过 Prisma 连接 PostgreSQL
- 处理程序位于 src/handlers/
## 约定
- 使用 zod 验证
- 返回 { data, error }
- 绝不暴露堆栈跟踪
```
现在,在你甚至还没输入提示词之前,Claude 就已经理解了:
- 你的技术栈
- 架构
- 约定
- 测试流程
- 格式化规则
- 安全边界
这改变了一切。
2. 两个 .claude 文件夹 = 团队大脑 + 个人大脑
这是 Claude Code 最聪明的设计决策之一。
项目级 .claude/
与整个团队共享。
```
your-project/.claude/
```
用于:
- 规则
- 钩子
- 智能体
- 共享工作流
- 安全策略
这会被提交到 Git 中。
全局级 ~/.claude/
你的个人 AI 环境。
~/.claude/
用于:
- 个人智能体
- 偏好设置
- 本地覆盖
- 会话记忆
永不提交。
这种分离非常重要,因为你的团队既获得了一致性,又不会失去个性化的定制。

3. 模块化规则优于巨型提示词
大多数团队会创建一个巨大的 CLAUDE.md 文件。
坏主意。
超过 300 行后,没人会维护它。
更好的配置:
```
.claude/rules/
├── code-style.md
├── testing.md
├── api-conventions.md
└── security.md
```
然后仅在需要的地方限定规则范围。
示例:
```
paths:
- "src/api/**/*.ts"
- "src/handlers/**/*.ts"
---
# API 设计规则
- 返回 { data, error }
- 使用 zod 验证
- 绝不泄露内部错误
```
这能保持指令:
- 更轻量
- 模块化
- 易于维护
- 上下文高效
你的 AI 会变得明显更可靠。
4. 钩子让 Claude 从“聪明”变得“安全”
事情到了严肃的阶段。
钩子允许你在 Claude 操作前后拦截工具的执行。
这意味着你可以:
- 阻止危险命令
- 自动格式化编辑过的文件
- 强制执行测试
- 拒绝不安全的操作
示例:
```
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "./.claude/hooks/bash-firewall.sh"
}
]
}
]
}
}
```
现在,每一个 shell 命令都会先通过你的防火墙。
这是企业级的控制能力。

5. 最被低估的功能:专用智能体
大多数人使用一个巨大的通用 AI 智能体。
糟糕的扩展策略。
Claude 允许你创建专注于特定任务、拥有受限工具和隔离上下文的子智能体。
示例:
```
name: code-reviewer
model: sonnet
tools: Read, Grep, Glob
---
你是一位专注于以下内容的高级代码审查员:
- 漏洞
- 边界情况
- 可维护性
```
这非常强大,因为:
- 主上下文保持干净
- 任务变得确定性
- 智能体深度专业化
- 权限受到限制
你彻底杜绝了上下文污染。
6. 权限比提示词更重要
一个被忽视的功能:
```
{
"permissions": {
"allow": [
"Bash(npm run *)",
"Read",
"Edit"
],
"deny": [
"Bash(rm -rf *)",
"Read(./.env)"
]
}
}
```
这至关重要。
因为最终,AI 智能体的失败不会是因为智力问题。
而是会因为权限问题。
能在 AI 自动化浪潮中生存下来的团队,将是那些建立了强大运营边界的团队。
而不是那些拥有最花哨提示词的团队。

最后的思考
大多数开发者还在和 AI “聊天”。
下一代开发者将负责编排 AI。
天壤之别。
真正的解锁关键不是:
> “我如何写出更好的提示词?”
而是:
> “我如何设计一个环境,让 AI 在其中始终表现正确?”
这就是 Claude Code 正在悄然实现的目标。
坦白说?
大多数人还没意识到这一转变有多么重要。