Follow these steps when committing or managing git history:
Check the current state first: run
git statusto see staged, unstaged, and untracked files before doing anything else.Review the diff before staging: run
git diff(unstaged) andgit diff --cached(staged) to confirm you know exactly what will be committed.Stage selectively: prefer
git add <file>overgit add .to avoid accidentally including build artifacts, secrets, or unrelated changes.Never commit secrets — check for
.env, API keys, tokens, and passwords. If found, remove them from the diff and add the file to.gitignore.Write a clear commit message:
- First line:
<type>: <short imperative summary>(max 72 chars). Types:feat,fix,refactor,docs,test,chore. - Leave a blank line, then add a body explaining why if needed.
- Example:
feat: add steering queue to agent loop
- First line:
Run tests before committing if a test command exists (
npm test,pnpm test, etc.). Do not commit if tests fail.Check for lint errors before committing: run the project's lint command (
pnpm lint,eslint ., etc.) if available.Use
git commit -m "$(cat <<'EOF' ... EOF)"syntax for multi-line commit messages to avoid shell escaping issues.After committing, run
git log --oneline -5to confirm the commit looks correct.For branch operations: create feature branches with
git checkout -b <type>/<short-description>. Never force-push tomainormaster.
Source: yai-dev/a101 — distributed by TomeVault.