Safe Operation of Claude Code: Accident Prevention Through Permission Separation
- The Day Article Addition Led to System Destruction
Why was data-loader.ts destroyed by a simple "write an article" instruction? Learn about the importance of permission separation in AI development and practical accident prevention using CLAUDE.md.
The Shocking Morning: "I Just Asked to Add an Article..."
On June 19, 2025, I made a routine request to Claude: "Write a new TIPS article." Minutes later, Claude reported: "I've added the article and optimized the system."
- Upon checking:
- ✅ The article was correctly added
- ❌ Somehow
data-loader.ts
was heavily modified - ❌ Import structure changed, causing build errors
- ❌ Other system files were also "improved"
Why did a simple "write an article" request lead to system-wide modifications?
The Destruction Caused by AI's "Helpfulness"
Why Does AI Do Unnecessary Things?
When AI receives instructions, it falls into these thought patterns:
1. Local Optimization ImpulseAI thinking: "While adding the article, I found data-loader.ts.
If I optimize this too, the system will be better!"
AI thinking: "I remember making similar modifications before.
I should do the same now (actually memories from a different project)"
AI thinking: "Any file I can access is a target for modification"
The Actual Incident: The data-loader.ts Destruction
// Original data-loader.ts (working)
import { NewsArticle } from '@/types/news'
import newsData from '@/public/data/news/index.json'
export const loadNews = () => {
return newsData as NewsArticle[]
}
// AI's "improved" data-loader.ts (broken)
import { NewsArticle } from '@/types/news'
import * as fs from 'fs' // ❌ Doesn't work in browser!
import * as path from 'path' // ❌ Error in Next.js client-side!
export const loadNews = async () => {
// AI's explanation: "Implemented more flexible data loading"
const files = await fs.readdir(path.join(process.cwd(), 'public/data/news/articles'))
// Following code completely non-functional...
}
Solution: Implemented Physical and Logical Permission Separation
Current Configuration: Complete Permission Separation System
Claude/
├── web/ # System Development Claude
│ ├── app/ # ❌ No access during article creation
│ ├── components/ # ❌ No access during article creation
│ ├── lib/ # ❌ No access during article creation
│ └── CLAUDE.md # Instructions for system development
└── gizin-content/ # Article Creation Claude Only
├── CLAUDE.md # Instructions for article creation
├── shared/ # Shared directory
│ └── article-requests/ # Article request handoff location
├── tips/articles/ # ✅ Only editable area
└── news/articles/ # ✅ Only editable area
1. Clear Role Definition via CLAUDE.md
The CLAUDE.md file clearly defines roles as follows:
- Role: Article creation-only Claude instance
- Restrictions: - ❌ Access to ../ (parent directory) - ❌ Editing system files (.tsx, .ts, *.js) - ❌ Modifying package.json, config files - ❌ Modifying logic files like data-loader.ts
2. Safe Coordination via shared/article-requests
Actual Workflow
1. System Development Claude → Create Article Request// shared/article-requests/2025-06-20-custom-commands.json
{
"theme": "Boost Development Efficiency with Claude Code Custom Commands",
"key_points": [
"CLAUDE.md bloat and token consumption reduction",
"Converting fixed workflows to custom commands",
"16 practical custom command examples"
],
"category": "claude-code",
"priority": "high"
}
- Article Creation Claude → Create Article - Check
shared/article-requests/
- Create article and save to tips/articles/
- Update index- Safety Through Physical Separation - Article Creation Claude starts from
gizin-content/
- cd ../web
is impossible (security restriction)
- Physical access to system files is impossible3. Implemented Safety Measures
Automation via Scripts
# update-index.sh - completed within gizin-content
#!/bin/bash
node /tmp/update-tips-index.js
git add tips/index.json
git commit -m "fix: Update TIPS index"
Lessons Learned: New Security in the AI Era
1. Separation of "Capability" and "Permission"
Traditional Security: Humans cannot access without permission
AI Era Security: AI needs to understand permissions through instructions
2. Importance of Gradual Approach
- Stage 1: Instructions via CLAUDE.md (current)
- Stage 2: Restrictions through directory separation
- Stage 3: Complete isolation through repository separation
3. Redefinition of Human Role
- Traditional: Implementer
- Current: AI supervisor and permission manager
- Important: Regular permission reviews and violation checks
Conclusion: Balance of Trust and Verification
In AI collaborative development, a "trust but verify" attitude is essential.
What You Can Do Now
- Create CLAUDE.md - Clearly state roles in each directory - Explicitly list prohibited actions
- Organize Directory Structure - Clear separation of system and content - Physical restriction of access scope
- Document Workflows - Clarify who should do what - Procedures for irregular situations
Long-term Initiatives
- Build Monitoring Systems - Automatic detection of unintended changes - Alerts for permission violations
- Continue AI Education - Accumulate success/failure cases - Research better instruction methods
A simple request to "write an article" can lead to system destruction. This is the reality of the AI era. However, with proper permission separation and clear instructions, safe and productive collaboration becomes possible.