Identify misplaced files and organize project structure following open-source best practices, while delegating refactoring to specialized skills
Purpose: Create a clean, welcoming project structure where every file has its proper place, following open-source conventions and the project's established patterns.
Philosophy: A well-organized project should produce a hand-sized, predictable tree that immediately communicates what the project does and how it's structured. The root should be clean and inviting, not overwhelming.
The project root is the first impression. It should contain only:
Files that belong together stay together:
Declutter identifies and recommends but does not refactor alone:
refactor skilltechnical-writer agentdevops skillWhen placement is ambiguous:
Trigger Phrases:
Automatic Contexts:
Phase 1: Assessment (Survey)
ā
Phase 2: Classification (Categorize)
ā
Phase 3: Research (Consult Skills)
ā
Phase 4: Proposal (Plan Moves)
ā
Phase 5: Execution (Delegate Actions)
Goal: Understand current state without judgment.
Capture the current tree:
tree -L 2 -a --dirsfirst -I '.git|node_modules|target|__pycache__|.venv'
Identify technology stack:
package.json, Cargo.toml, pyproject.toml, go.mod, etc.Count root-level items:
ls -la | wc -l
Healthy root: 10-20 items (dirs + essential files) Needs attention: 20-30 items Critical: 30+ items
Identify outliers:
Goal: Assign each item to a category for action.
| Category | Examples | Action |
|---|---|---|
| Essential Root | README, LICENSE, main config | Keep in root |
| Documentation | *.md guides, ADRs, specs | Move to /docs |
| Configuration | dotfiles, *.config.js | Consider /config or keep root |
| Scripts | Shell scripts, automation | Move to /scripts |
| DevOps | CI/CD, Docker, k8s | Move to .github/, /deploy |
| Source Code | Application code | Move to /src, /lib, /app |
| Tests | Test files | Move to /tests or colocate |
| Build Artifacts | Generated files | Add to .gitignore |
| Experiments | POCs, spikes | Move to /sandbox or delete |
| Orphaned | No clear purpose | Ask user or delete |
For Markdown Files:
README.md, CONTRIBUTING.md, CHANGELOG.md ā Root (OSS standard)
CODE_OF_CONDUCT.md, SECURITY.md ā Root (GitHub special files)
*.md (other) ā /docs
For Configuration:
Single dotfile ā Root acceptable
Multiple similar configs ā /config directory
Build tool config ā Usually root (webpack.config.js, etc.)
Editor config ā Root (.editorconfig, .prettierrc)
For Scripts:
1-2 scripts ā /scripts or root acceptable
3+ scripts ā Must move to /scripts
Shell scripts ā /scripts
Build scripts ā /scripts/build or npm scripts
Goal: Get expert guidance before making moves.
| Question Type | Consult |
|---|---|
| "Where should docs go?" | technical-writer agent |
| "How to structure Rust project?" | rust-cli-architect agent |
| "Best practices for this framework?" | Explore agent with framework focus |
| "Is this safe to delete?" | safety-pattern-auditor skill |
| "How to reorganize build pipeline?" | devops skill (if exists) |
| "Cultural/locale files placement?" | multicultural-holidays skill |
Check if skill exists:
Glob: .claude/skills/*/SKILL.md
Check if agent can help:
If skill/agent available:
Task: [appropriate-agent]
Prompt: "I'm decluttering this project and need guidance on
[specific question]. What's the best practice for [specific situation]?"
If skill/agent not available:
Report to user:
"I'd like to consult a [skill-type] skill for [reason], but it's
not installed. Would you like to:
a) Configure/install the skill
b) Proceed with my best judgment
c) Skip this category for now"
When framework-specific guidance isn't available, research:
Use the Explore agent:
Task: Explore
Prompt: "Find the standard directory structure for [technology] projects.
Focus on: root organization, docs placement, scripts location, config handling."
Goal: Present a clear, actionable reorganization plan.
## Declutter Proposal - [Project Name]
### Current State
- Root items: 42 (Critical - needs attention)
- Tech stack: Rust CLI with Astro website
- Primary issues: Documentation scattered, scripts mixed
### Proposed Structure
project-root/ āāā .claude/ # Claude configuration (keep) āāā .github/ # GitHub workflows (keep) āāā docs/ # Documentation (create) ā āāā architecture/ # ADRs and design docs ā āāā guides/ # User guides ā āāā api/ # API documentation āāā scripts/ # Automation (organize) ā āāā build/ # Build scripts ā āāā dev/ # Development helpers ā āāā release/ # Release automation āāā src/ # Source code (keep) āāā tests/ # Test files (keep) āāā website/ # Astro site (keep) āāā Cargo.toml # Main config (keep) āāā README.md # Entry point (keep) āāā LICENSE # Legal (keep) āāā CHANGELOG.md # History (keep)
### Proposed Moves
| File | From | To | Reason |
|------|------|-----|--------|
| ARCHITECTURE.md | / | /docs/architecture/ | Standard docs location |
| setup.sh | / | /scripts/ | OSS convention |
| dev-notes.md | / | /docs/guides/ | Internal documentation |
### Files to Delete
| File | Reason |
|------|--------|
| backup.old | Obsolete backup |
| test_experiment.rs | Superseded by /tests |
### Files Requiring Decision
| File | Options |
|------|---------|
| random_script.py | A) Delete B) Move to /scripts C) Keep |
### Skills to Engage
1. `technical-writer` - Restructure /docs hierarchy
2. `refactor` - Update import paths after moves (NOT AVAILABLE - recommend install)
Goal: Execute the plan with proper delegation.
refactor skill# Always use git mv for tracked files
git mv old/path new/path
# Create directories first
mkdir -p new/directory
# Batch related moves
git mv docs/*.md docs/guides/
Check for broken links:
grep -rn "old/path" --include="*.md" --include="*.rs"
Verify imports still work:
cargo check # For Rust
npm run build # For JS
Update any absolute references
# Single logical commit for declutter
git add -A
git commit -m "$(cat <<'EOF'
refactor: Declutter project structure
Moves:
- ARCHITECTURE.md ā docs/architecture/
- setup.sh ā scripts/
- dev-notes.md ā docs/guides/
Deletes:
- backup.old (obsolete)
- test_experiment.rs (superseded)
Created:
- docs/architecture/ directory
- scripts/build/ directory
Consulted: technical-writer agent, OSS conventions
EOF
)"
For mono-repos, declutter level by level:
/config.github/ or /cimonorepo/
āāā .github/ # Shared CI/CD
āāā docs/ # Shared documentation
āāā packages/ # Sub-projects
ā āāā app-a/
ā ā āāā src/
ā ā āāā tests/
ā ā āāā package.json
ā āāā app-b/
āāā scripts/ # Shared automation
āāā config/ # Shared configuration
āāā package.json # Root workspace
āāā README.md
project/
āāā src/
ā āāā lib.rs # Library entry
ā āāā main.rs # Binary entry
āāā tests/ # Integration tests
āāā benches/ # Benchmarks
āāā examples/ # Example usage
āāā Cargo.toml
āāā README.md
project/
āāā src/ # Source code
āāā dist/ # Build output (gitignored)
āāā tests/ or __tests__/ # Tests
āāā scripts/ # Build/dev scripts
āāā package.json
āāā README.md
project/
āāā src/project_name/ # Package code
āāā tests/ # Tests
āāā docs/ # Documentation
āāā scripts/ # Automation
āāā pyproject.toml
āāā README.md
See references/oss-conventions.md for comprehensive patterns.
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā DECLUTTER CHECKLIST ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¤
ā ā
ā Assessment: ā
ā ā Tree captured (depth 2) ā
ā ā Tech stack identified ā
ā ā Root item count: _____ (target: <20) ā
ā ā Outliers identified ā
ā ā
ā Classification: ā
ā ā Each item categorized ā
ā ā Actions assigned (keep/move/delete/ask) ā
ā ā
ā Research: ā
ā ā Relevant skills consulted ā
ā ā Missing skills reported ā
ā ā OSS conventions checked ā
ā ā
ā Proposal: ā
ā ā Target structure documented ā
ā ā Move plan created ā
ā ā User decisions collected ā
ā ā
ā Execution: ā
ā ā Moves delegated to skills where needed ā
ā ā git mv used for tracked files ā
ā ā Broken references fixed ā
ā ā Commit created with full context ā
ā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
refactor skillrefactor - For updating imports after movestechnical-writer - For documentation restructuringExplore agent - For OSS convention researchdevops - For pipeline reorganizationvalidate-constitution - For checking project rulesUsing the Task tool:
Task: general-purpose
Prompt: "Run the declutter skill on this project.
Follow the workflow in .claude/skills/declutter/SKILL.md:
1. Assess the current structure
2. Classify all files/directories
3. Consult relevant skills for guidance
4. Create a proposal document
5. Present it for user approval before execution
Focus on making the root clean and welcoming.
Respect existing conventions and correlations.
Delegate refactoring to appropriate skills."
Declutter is complete when:
A decluttered project is a welcoming project. Every file in its place, every place with purpose.