NPM Package: https://www.npmjs.com/package/claude-organize
Claude Code creates files everywhere. Despite CLAUDE.md instructions saying "don't create scripts in the root directory," it keeps creating test files, debug scripts, and documentation right at your project root:
my-project/
βββ test-api-v1.md # First attempt
βββ test-api-v2.md # "Fixed" version
βββ test-api-final.md # "Final" version
βββ test-api-final-FIXED.md # Actually final?
βββ debug-webhook.mjs # Quick test script
βββ analyze-performance.mjs # Debugging session
βββ ... (87 more files at root!)
Solution: Automatic file organization using AI-powered categorization
my-project/
βββ src/ # Source code stays untouched
βββ docs/
β βββ testing/ # Test results organized
β βββ troubleshooting/ # Debug notes in one place
βββ scripts/
βββ checks/ # Validation scripts grouped
βββ debug/ # Debug utilities together
npm install -g claude-organizeYou have two options to configure the file organization hook:
Use Claude Code's built-in /hooks command to configure:
# Step 1: Type the /hooks command
/hooks
# Step 2: Select "PostToolUse" from the menu
# Step 3: Enter the matcher pattern:
Write|Edit|MultiEdit
# Step 4: Select "command" as the hook type
# Step 5: Enter the command:
claude-organize
# Step 6: Press Enter to confirm
# Step 7: Press Esc twice to exit the menu
# That's it! The hook is now configuredAdd to your .claude/settings.json:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit|MultiEdit",
"hooks": [{ "type": "command", "command": "claude-organize" }]
}
]
}
}According to Claude Code Best Practices, the recommended approaches include:
- Hierarchical CLAUDE.md files - Great for static organization in monorepos
- Shorter sessions with /clear - Helps manage context effectively
- Using subagents - Reduces context usage for complex tasks
Claude Organize complements these practices:
File Organization (Hooks) - Works regardless of session length. Even with /clear and perfect CLAUDE.md setup, Claude still creates files in root. Our hooks ensure consistent organization.
Think of it this way:
- Best Practices: Organize your kitchen (hierarchical CLAUDE.md)
- Claude Organize: Clean as you cook (hooks)
Both approaches work together for optimal Claude Code workflows.
β
Automatic cleanup - Files move to proper directories instantly
β
AI categorization - Understands file purpose from content
β
10 script subcategories - Detailed organization for scripts
β
Safe defaults - Protects README, LICENSE, configs
β
Context reduction - Cleaner workspace = better Claude performance
File Organization: User β Claude Code β Hook β claude-organize β AI β Organized Files
View all architecture diagrams β
| Guide | Description |
|---|---|
| π Full Documentation | Complete feature guide and API reference |
| π Quick Start | Get up and running in 5 minutes |
| π Subcategories Guide | Script organization patterns |
| βοΈ Configuration | Customize behavior and settings |
| π§ JavaScript Organization | Experimental JS/MJS features |
| π οΈ Troubleshooting | Common issues and solutions |
Files are automatically organized into these directories:
docs/testing/- Test results, QA reportsdocs/analysis/- Data analysis, performance reportsdocs/architecture/- System design, technical docsdocs/operations/- Deployment guides, runbooksdocs/troubleshooting/- Debug logs, issue investigations
scripts/checks/- Verification and validation utilitiesscripts/testing/- Test scripts and runnersscripts/deployment/- Deployment and release scriptsscripts/utilities/- General utility scripts- + 6 more subcategories
You might encounter this scenario:
Claude: "I'll create test-email.mjs and run it"
*Creates file*
*File gets organized to scripts/testing/*
Claude: "Error: Cannot find module './test-email.mjs'"
This is intentional! The friction teaches Claude (and us) better habits:
- First time: Claude learns files don't stay at root
- Second time: Claude checks where files went (
find . -name "test-email.mjs") - Third time: Claude runs directly from organized location
Just like training a junior developer: "Test files go in the test directory."
The housekeeper doesn't compromise on cleanliness. This "friction" is actually a feature:
- Claude learns project structure through experience
- Better long-term habits > short-term convenience
- Consistent organization > temporary files at root
/claude-organize-bypass- Toggle file organization on/off/claude-organize-add <pattern>- Add patterns to be organized/claude-organize-js- Enable JavaScript organization (experimental)
- β Use version control (Git) before enabling
- β Test in a safe environment first
- β
Review the organization log at
docs/organization-log.json
We welcome contributions! Please see our Contributing Guide for details.
Distributed under the MIT License. See LICENSE for more information.
- cc-enhance - Prompt enhancement with contrarian analysis for Claude Code
- Transform vague requests into comprehensive, context-aware prompts
- Adds contrarian analysis to challenge assumptions early
- Use both tools together for the complete Claude Code experience!
- π Report Issues
- π¬ Discussions

