| name | git-directory-management |
| description | Manage git-tracked directories correctly - never create .gitkeep files in directories that will immediately contain tracked files |
Git Directory Management
When to Use This Skill
Use this skill when creating new directories in a git repository, especially when:
- Setting up project structure
- Creating plugin/package directories
- Organizing code into new folders
- Adding configuration directories
Core Principle
Never create .gitkeep files in directories you're about to populate with tracked files.
.gitkeep is ONLY for keeping truly empty directories in version control.
Pattern to Follow
✅ DO - Add actual files directly
mkdir -p plugins/new-plugin/skills
Key points:
- Git automatically tracks directories when they contain files
- Empty directory + file creation can happen in one step
- No
.gitkeep needed - the real files track the directory
❌ DON'T - Create .gitkeep then immediately add files
mkdir -p plugins/new-plugin/skills
touch plugins/new-plugin/skills/.gitkeep
git add plugins/new-plugin/skills/.gitkeep
git commit -m "Add empty directory"
git add plugins/new-plugin/skills/
git commit -m "Add actual skill"
Why this is wrong:
.gitkeep serves no purpose if files are coming
- Creates unnecessary commits
- Clutters directory with placeholder file
- Extra file to maintain/remove later
When to Use .gitkeep
.gitkeep is appropriate ONLY when:
- The directory must exist but remain empty
- The empty directory is required for the application to function
- No files will be added to the directory immediately
Valid use case example:
mkdir -p logs
touch logs/.gitkeep
git add logs/.gitkeep
git commit -m "chore: add logs directory for runtime output"
Why this is valid:
- Directory must exist before application runs
- Directory will be populated at runtime (not in version control)
.gitkeep ensures the empty directory is tracked
Common Scenarios
Scenario: Creating a new plugin structure
✅ DO:
mkdir -p plugins/new-plugin/{skills,commands}
git add plugins/new-plugin/
git commit -m "feat: add new-plugin"
❌ DON'T:
mkdir -p plugins/new-plugin/skills
touch plugins/new-plugin/skills/.gitkeep
Scenario: Creating empty directories for runtime
✅ DO:
mkdir -p tmp/cache
touch tmp/cache/.gitkeep
git add tmp/cache/.gitkeep
git commit -m "chore: add cache directory for runtime"
Why this is correct: Cache directory must exist but contents are not tracked.
Scenario: Setting up tool configuration directories
✅ DO:
mkdir -p .config/tool
git add .config/tool/config.json
git commit -m "feat: add tool configuration"
❌ DON'T:
mkdir -p .config/tool
touch .config/tool/.gitkeep
Decision Tree
Creating a new directory?
│
├─ Will you add tracked files immediately?
│ └─ YES → No .gitkeep needed, just add the files
│
└─ Will the directory stay empty in version control?
│
├─ YES, and it must exist → Use .gitkeep
│
└─ NO, files coming later → Wait until files exist, then commit
Why It Matters
Benefits of not using .gitkeep unnecessarily:
- Cleaner repository (fewer placeholder files)
- Fewer commits (one commit with actual content)
- No cleanup needed later (no .gitkeep to remove)
- Clear intent (tracked files show directory purpose)
Problems with unnecessary .gitkeep:
- Clutters directories with meaningless files
- Creates confusing git history (empty → populated)
- Requires eventual cleanup
- Adds maintenance burden
Quick Reference
Rule of thumb:
- About to add files? → No
.gitkeep
- Directory stays empty? → Use
.gitkeep
- Not sure yet? → Wait until files exist
Remember:
- Git tracks directories through their files
.gitkeep is for truly empty directories
- One commit with actual content beats two commits (empty + populated)
- When in doubt, add the real files first
Examples in This Repository
Correct usage (runtime directories):
- None currently - all directories contain tracked files
What NOT to do:
Correct approach:
git add plugins/tools/skills/new-skill/
git commit -m "feat(tools): add new-skill"