Skip to main content
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.
跳到安装 Skills Marketplace 发现并探索由社区构建的 Agent Skills
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/pmarashian/cursor-agent-skills --skill git-best-practices命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
下载 Zip 下载中... 同仓库更多 Skills capacitor-vite-nextjs-backend Setup and patterns for a Vite + React frontend with Capacitor and Ionic React, plus a separate Next.js backend in a monorepo. Use when creating or modifying a Capacitor mobile app with a Vite frontend and Next.js API, or when adding Capacitor to an existing Vite app with a Next.js backend.
Modify Cursor/VSCode user settings in settings.json. Use when the user wants to change editor settings, preferences, configuration, themes, font size, tab size, format on save, auto save, keybindings, or any settings.json values.
Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.
相关职业
SOC
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.
Git Best Practices Skill
This skill provides comprehensive guidelines for proper git workflow management, with a focus on .gitignore setup and preventing accidental commits of unwanted files.
.gitignore Management
Critical: Always Check Before Initializing Package Managers
BEFORE initializing npm, pip, poetry, cargo, or any other package manager:
Check if .gitignore exists : Use ls -la .gitignore or check via file system
If .gitignore doesn't exist : Create it with appropriate patterns for your project type
If .gitignore exists : Verify it includes the necessary patterns for your package manager
After creating/updating .gitignore : Verify it's working with git status to ensure ignored files don't appear
Required Patterns by Project Type
Node.js / npm / yarn / pnpm
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
.pnpm-store/
Python / pip / poetry
__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/
Rust / cargo
target/
Cargo.lock
Go
*.exe
*.exe~
*.dll
*.so
*.dylib
*.test
*.out
go.work
Java / Maven / Gradle
*.class
*.log
*.jar
*.war
*.ear
target/
build/
.gradle/
.idea/
*.iml
Universal Patterns (All Projects) 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/
Git Workflow Best Practices
Before Committing
Always check git status before committing to see what will be committed:
git status
Review the output carefully :
Ensure no sensitive files are staged (.env, secrets, API keys)
Verify node_modules/ or other build artifacts aren't included
Check that only intended files are staged
If unwanted files appear :
Check if .gitignore exists and has the correct patterns
Update .gitignore if needed
Remove files from staging: git reset HEAD <file>
Verify with git status again
Commit Message Format Use the existing project format:
feat: TASK-{id} - {description}
feat: TASK-123 - Add user authentication
feat: TASK-456 - Fix memory leak in data processor
Never Commit
Sensitive files : .env, .env.local, any file containing secrets, API keys, passwords
Build artifacts : node_modules/, dist/, build/, compiled binaries
OS files : .DS_Store, Thumbs.db
Large binary files : Unless using Git LFS (Large File Storage)
IDE-specific files : Unless the project explicitly includes them in version control
Verifying .gitignore Effectiveness After creating or updating .gitignore:
Run git status to see what files git is tracking
If ignored files still appear, they may have been previously tracked:
git rm --cached <file>
git rm -r --cached <directory>
Commit the removal: git commit -m "chore: Remove tracked files that should be ignored"
Verify again with git status
Project-Specific Considerations
When Initializing a New Project
Create .gitignore before running npm init, pip install, etc.
Include patterns for your package manager
Initialize git: git init (if not already initialized)
Verify .gitignore is working before proceeding
When Adding New Dependencies
Check git status after installing packages
Ensure new build artifacts are ignored
If new file types appear, update .gitignore accordingly
When Working with Multiple Languages If a project uses multiple languages/frameworks, include patterns for all of them:
Node.js + Python: Include both node_modules/ and __pycache__/
React + Python backend: Include .next/ or dist/ plus Python patterns
Quick Reference Checklist
Common Mistakes to Avoid
Initializing package managers before creating .gitignore
This can lead to node_modules/ or similar directories being tracked
Assuming .gitignore works retroactively
Files already tracked by git will continue to be tracked even if added to .gitignore
Use git rm --cached to untrack them
Committing without checking git status
Always verify what you're committing
Including sensitive data in commits
Double-check for .env files, API keys, passwords
If accidentally committed, use git reset or git commit --amend (if not pushed)
Forgetting project-specific patterns
Different projects need different .gitignore patterns
Tailor the .gitignore to the project's technology stack
Pre-Commit Checklist Before committing, verify:
Pre-Commit Hooks Consider adding pre-commit hooks for:
TypeScript compilation check
Linter checks
Test execution
Document hook setup in project README if implemented.
Pre-Commit Validation Run TypeScript compilation check before commit:
Verify no console errors:
agent-browser console | grep -i "error"
npm run build 2>&1 | grep -i "error"
Check git status before staging:
git status
git diff
git add src/scenes/GameScene.ts
Review changes with git diff:
git diff
git diff --staged
git diff src/scenes/GameScene.ts
Commit Message Patterns Format: "feat: TASK-ID - Description"
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:
git commit -m "feat: TASK-{id} - {description}"
git commit -m "feat: US-036 - Fix maze generation error handling"
Use conventional commit types:
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:
git commit -m "feat: US-040 - Add coin collection sound effect"
git commit -m "feat: US-040 - Update code"
git commit -m "feat: US-040 - Add coin collection sound effect that plays when player collects coin and updates score and triggers animation"
Workflow Patterns Check git status before operations:
git status
git status --short
git status --untracked-files=all
Stage only relevant files:
git add src/scenes/GameScene.ts
git add src/scenes/GameOverScene.ts
Commit after verification passes:
npx tsc --noEmit
agent-browser open http://localhost:3000
git add src/
git commit -m "feat: TASK-ID - Description"
Update progress.txt before commit:
echo "## Task Complete" >> tasks/progress.txt
echo "- [x] All criteria met" >> tasks/progress.txt
git add tasks/progress.txt
git commit -m "feat: TASK-ID - Description"