/community/skills/opencognitos skills/safe git
innernet
docsskillscommunitycompanydeveloperssecurityprivacytermscontact

a skill by OpenCognitOS, brought here by kt

safe git

paste this link into your ai. it will know what to do.

/skills/opencognitos-safe-git

Rules for committing, branching and pushing safely as a coding agent. Use before any git commit, push, merge, rebase or history rewrite, and when the user asks to "ship", "commit" or "push" changes.

kindskill
last tended2026-12-05
written byOpenCognitOS
sourcegithub.com/OpenCognitOS/skills
kept currentwith its source · last read 2026-12-05
in the folderopencognitos skills · 6 of 11 · ‹ release notes · sober copy ›
brought here bykt
yours?it stays under your name. to change it or take it down, write to connect@innernet.live
reading2 min

Safe git

Git mistakes made by agents are expensive: lost work, leaked secrets, broken main branches. Follow these rules for every git operation.

Before you commit

  1. 1Run git status and git diff --staged. Read what you are about to commit.
  2. 2Stage files by name (git add path/to/file). Avoid git add -A and git add . unless you checked every untracked file.
  3. 3Never commit: - .env, .env.* (except .env.example), *.pem, *.key, id_rsa*, credentials.json, *.p12, service-account files - local settings such as .claude/settings.local.json, .vscode/ with personal paths - build output, node_modules/, large binaries, database files
  4. 4Scan the staged diff for secrets: API keys (sk-, ghp_, AKIA, xox), private key headers, passwords in URLs, tokens in config. If you find one, unstage the file and tell the user. Do not "fix" it by committing a removal: the secret stays in history.
  5. 5Run the project's tests, linter and type check if they exist and are fast. Do not commit red builds without telling the user.

Commit messages

  • One commit per logical change. Do not mix a refactor with a bug fix.
  • Subject line: imperative, at most ~72 characters, says what changes ("Fix token refresh on expired sessions").
  • Body (optional): why the change was needed and anything a reviewer must know.
  • Follow the repository's existing style and language (git log --oneline -20).

Branches

  • Never commit directly to main/master unless the user asked for it. Create a branch: git switch -c feature/<short-name> or fix/<short-name>.
  • Keep branches small and short-lived.

Pushing and rewriting history

  • Push only when the user asked for it.
  • Never use git push --force on shared branches. If a rewrite is really needed on your own branch, use git push --force-with-lease and say so.
  • Never run git reset --hard, git clean -fd, git checkout -- . or git stash drop without explicit permission: they destroy uncommitted work, possibly the user's.
  • Never rewrite history that is already on the remote (rebase, commit --amend, filter-branch) without asking.
  • Do not skip hooks (--no-verify) to get a commit through. Fix the cause or report it.

When something goes wrong

  • Merge conflict: resolve only the conflicting hunks, keep both sides' intent, run tests, and tell the user which files you resolved.
  • Wrong commit on main (not pushed): create a branch at the current commit, then ask before moving main back.
  • Pushed a secret: stop, tell the user immediately. The key must be revoked; deleting it from history is not enough.

keep it where your ai can reach it.

innernet is memory your ai tools read live — every skill, every project, every decision, in one place, connected once. save this skill to yours, or publish one of your own as a link like this.

save it to your innernetsee every skill