Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/caipe-io/ai-platform-engineering/safe-git-worktreegit clone --depth 1 https://github.com/caipe-io/ai-platform-engineeringWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00877 | $0.00877 |
| Opus 5 | $0.00439 | $0.00439 |
| Sonnet 5 | $0.00175 | $0.00175 |
| Haiku 4.5 | $0.00088 | $0.00088 |
Grade A, and why
safe-git-worktree scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 80 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Safe Git: Protect the User's Working Tree
The user's checked-out branch and working tree are theirs. Before doing any
branch/PR work, make sure you will not lose their edits or churn thousands of
files. The failure that motivated this rule was switching branches across a
stale local main (37 commits behind origin/main), which rewrote ~3,800
docs/ files in the user's tree.
Always (universal — applies to every repo and agent)
- Never assume local
mainis current. Rungit fetch origin <base>and branch from the remote ref (origin/main), not the local one. - Preserve uncommitted work. Run
git statusbefore any git command. If the tree is dirty, do not switch/reset/checkout over those edits — commit, stash with the user's awareness, or isolate in a worktree instead. - Never push to a shared branch. Push only to feature branches; never
push/--forcetoorigin/main(or any protected branch). - Never rewrite shared history (
reset --hard, force-push) on a branch others may have pulled. - Branch naming: use the
prebuild/prefix when the branch should trigger CI Docker image builds (seeAGENTS.md).
Prefer an isolated worktree when the work is risky or parallel
Reach for a throwaway worktree when you need to experiment, run work in parallel with the user's current branch, or when the tree is dirty and you must not disturb it:
git fetch origin main
git worktree add /tmp/caipe-<task> origin/main -b prebuild/<feat-branch>
cd /tmp/caipe-<task> # do edits, commits, pushes here
# when done:
cd - # user's repo, untouched
git worktree remove /tmp/caipe-<task>
Worktree caveats to handle (don't assume the worktree "just works"):
- Untracked-but-essential files don't come along. Gitignored config such as
.envis absent in a fresh worktree — copy or symlink what the task needs. - Virtualenvs are not shared. Per
CLAUDE.md, each worktree (and each subpackage: RAG ingestors/server, MCP agents) needs its ownuv venv --python python3.13 --clear .venv && uv sync. /tmpis cleared on reboot and duplicates large caches — fine for short tasks, not for long-lived state.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2d ago First seen · 80 lines · 877 tokens per session scan A 4d122f22df69
safe-git-worktree is a cursor rule published in the GitHub repository caipe-io/ai-platform-engineering (403 stars, last pushed 3d ago), licensed Apache-2.0. It adds 877 tokens to every session, about $0.0044 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other cursor rules, from other repositories
070-gitlab-ops
When working with GitLab or GitHub — issues, merge requests, pull requests, CI pipelines, labels.
kandev-pr-fixup
Kandev PR fixup workflow prompt for Cursor agents.
conventional-commits
Always use Conventional Commits for git commit messages.
angular-20
This rule provides comprehensive best practices and coding standards for Angular development, focusing on modern TypeScript, standalone components, signals, and performance optimizations.
dev-standard
Apache Superset development standards and guidelines for Cursor IDE.
coolify-ai-docs
Master reference to all Coolify AI documentation in .ai/ directory.