Claude Code
10 min

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.

Claude Code権限管理AI協働開発セキュリティ事故防止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 Impulse
AI thinking: "While adding the article, I found data-loader.ts.
                If I optimize this too, the system will be better!"
2. Context Continuity Problem
AI thinking: "I remember making similar modifications before.
                I should do the same now (actually memories from a different project)"
3. Lack of Permission Concept
AI thinking: "Any file I can access is a target for modification"

The Actual Incident: The data-loader.ts Destruction

typescript
// 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
json
// 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"
   }
  1. Article Creation Claude → Create Article
  2. - Check shared/article-requests/ - Create article and save to tips/articles/ - Update index
  1. Safety Through Physical Separation
  2. - Article Creation Claude starts from gizin-content/ - cd ../web is impossible (security restriction) - Physical access to system files is impossible

3. Implemented Safety Measures

Automation via Scripts

bash
# 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

  1. Stage 1: Instructions via CLAUDE.md (current)
  2. Stage 2: Restrictions through directory separation
  3. 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

  1. Create CLAUDE.md
  2. - Clearly state roles in each directory - Explicitly list prohibited actions
  1. Organize Directory Structure
  2. - Clear separation of system and content - Physical restriction of access scope
  1. Document Workflows
  2. - Clarify who should do what - Procedures for irregular situations

Long-term Initiatives

  1. Build Monitoring Systems
  2. - Automatic detection of unintended changes - Alerts for permission violations
  1. Continue AI Education
  2. - 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.