with one click
git-best-practices
// Git best practices for ensuring proper .gitignore setup and git workflow management. Use this skill when initializing new projects, working with package managers (npm, pip, etc.), or making git commits.
// Git best practices for ensuring proper .gitignore setup and git workflow management. Use this skill when initializing new projects, working with package managers (npm, pip, etc.), or making git commits.
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | git-best-practices |
| description | Git best practices for ensuring proper .gitignore setup and git workflow management. Use this skill when initializing new projects, working with package managers (npm, pip, etc.), or making git commits. |
This skill provides comprehensive guidelines for proper git workflow management, with a focus on .gitignore setup and preventing accidental commits of unwanted files.
BEFORE initializing npm, pip, poetry, cargo, or any other package manager:
.gitignore exists: Use ls -la .gitignore or check via file system.gitignore doesn't exist: Create it with appropriate patterns for your project type.gitignore exists: Verify it includes the necessary patterns for your package manager.gitignore: Verify it's working with git status to ensure ignored files don't appearnode_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
.pnpm-store/
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
env/
venv/
ENV/
env.bak/
venv.bak/
.venv
pip-log.txt
pip-delete-this-directory.txt
.pytest_cache/
.coverage
htmlcov/
*.egg-info/
dist/
build/
target/
Cargo.lock
*.exe
*.exe~
*.dll
*.so
*.dylib
*.test
*.out
go.work
*.class
*.log
*.jar
*.war
*.ear
target/
build/
.gradle/
.idea/
*.iml
These should be included in every .gitignore:
# Environment files
.env
.env.local
.env.*.local
.env.development
.env.production
.env.test
*.env
# Build outputs
dist/
build/
.next/
out/
*.tsbuildinfo
# OS files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
Desktop.ini
# Logs
*.log
logs/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
# Editor files (optional - include if not using shared IDE config)
.idea/
.vscode/
*.swp
*.swo
*~
.project
.classpath
.settings/
# Temporary files
*.tmp
*.temp
.cache/
Always check git status before committing to see what will be committed:
git status
Review the output carefully:
.env, secrets, API keys)node_modules/ or other build artifacts aren't includedIf unwanted files appear:
.gitignore exists and has the correct patterns.gitignore if neededgit reset HEAD <file>git status againUse the existing project format:
feat: TASK-{id} - {description}
Examples:
feat: TASK-123 - Add user authenticationfeat: TASK-456 - Fix memory leak in data processor.env, .env.local, any file containing secrets, API keys, passwordsnode_modules/, dist/, build/, compiled binaries.DS_Store, Thumbs.dbAfter creating or updating .gitignore:
git status to see what files git is tracking# Remove from git cache (but keep local files)
git rm --cached <file>
# Or for directories:
git rm -r --cached <directory>
git commit -m "chore: Remove tracked files that should be ignored"git status.gitignore before running npm init, pip install, etc.git init (if not already initialized).gitignore is working before proceedinggit status after installing packages.gitignore accordinglyIf a project uses multiple languages/frameworks, include patterns for all of them:
node_modules/ and __pycache__/.next/ or dist/ plus Python patternsBefore committing:
.gitignore exists and is appropriate for the project typegit status and reviewed output.env, secrets) are stagednode_modules/, dist/, etc.) are stagedfeat: TASK-{id} - {description}.gitignore is working correctly (ignored files don't appear in git status)Initializing package managers before creating .gitignore
node_modules/ or similar directories being trackedAssuming .gitignore works retroactively
.gitignoregit rm --cached to untrack themCommitting without checking git status
Including sensitive data in commits
.env files, API keys, passwordsgit reset or git commit --amend (if not pushed)Forgetting project-specific patterns
.gitignore patterns.gitignore to the project's technology stackBefore committing, verify:
npx tsc --noEmit)Consider adding pre-commit hooks for:
Document hook setup in project README if implemented.
Run TypeScript compilation check before commit:
# Before committing, verify compilation
npx tsc --noEmit
# If errors exist, fix them before committing
Verify no console errors:
# Check for console errors in browser
agent-browser console | grep -i "error"
# Or check build output
npm run build 2>&1 | grep -i "error"
Check git status before staging:
# Always check what will be committed
git status
# Review changes
git diff
# Stage only relevant files
git add src/scenes/GameScene.ts
Review changes with git diff:
# Review all changes
git diff
# Review staged changes
git diff --staged
# Review specific file
git diff src/scenes/GameScene.ts
Format: "feat: TASK-ID - Description"
# Examples
git commit -m "feat: US-033 - Add wizard character sprite"
git commit -m "feat: US-034 - Implement timer countdown"
git commit -m "feat: US-035 - Add scene transition animations"
Include task ID for traceability:
# Always include task ID
git commit -m "feat: TASK-{id} - {description}"
# Examples
git commit -m "feat: US-036 - Fix maze generation error handling"
Use conventional commit types:
# Types: feat, fix, chore, docs, refactor, test
git commit -m "feat: US-037 - Add new feature"
git commit -m "fix: US-038 - Fix bug"
git commit -m "chore: US-039 - Update dependencies"
Keep messages descriptive but concise:
# ✅ GOOD: Descriptive but concise
git commit -m "feat: US-040 - Add coin collection sound effect"
# ❌ BAD: Too vague
git commit -m "feat: US-040 - Update code"
# ❌ BAD: Too verbose
git commit -m "feat: US-040 - Add coin collection sound effect that plays when player collects coin and updates score and triggers animation"
Check git status before operations:
# Before any git operation, check status
git status
# See what files changed
git status --short
# See untracked files
git status --untracked-files=all
Stage only relevant files:
# Stage specific files
git add src/scenes/GameScene.ts
git add src/scenes/GameOverScene.ts
# Don't stage everything
# ❌ git add . # Only if you're sure
Commit after verification passes:
# 1. Make changes
# 2. Verify TypeScript compilation
npx tsc --noEmit
# 3. Verify browser testing
agent-browser open http://localhost:3000
# 4. Stage files
git add src/
# 5. Commit
git commit -m "feat: TASK-ID - Description"
Update progress.txt before commit:
# Update progress.txt with task completion
echo "## Task Complete" >> tasks/progress.txt
echo "- [x] All criteria met" >> tasks/progress.txt
# Then commit
git add tasks/progress.txt
git commit -m "feat: TASK-ID - Description"