Agent Git Workflow (Sandbox)
Context
- Workspace lives in Docker volume at
/workspaces/work(no host bind mounts). - Container/volume names may vary per project (see
.devcontainer/docker-compose*.yml). - A local safety pre-push hook blocks pushes to
main/master(anti-footgun, not a server guarantee). It is installed in the image and is locked down (systemcore.hooksPath). - By default the sandbox has sudo + Docker host access (docker.sock). This is convenient but dangerous: Docker operations are potentially destructive.
Quick start
- Go to the target repo directory (usually under
/workspaces/work/<repo>). - Create a task branch off
agent:
agent-task-branch <task-slug>
- Make changes, commit.
- Optional: push current task branch for remote backup (recommended for long tasks / “in progress” safety):
git push -u origin HEAD
- Merge your task branch back into
agentand pushagent:
agent-merge-to-agent
- Open PR
agent→mainonly when the user explicitly asks (see rules below):
agent-open-pr
Rules
Hard rules (do not violate)
- Never push directly to
main/master. Changes land inmainonly via PR. - Never intentionally bypass safety mechanisms (pre-push hook / blocks). Examples of forbidden bypasses:
git push --no-verify ...git -c core.hooksPath=/dev/null push ...- changing
core.hooksPath, deleting hooks, or rewriting the hook script.
- Never embed secrets/tokens in:
- repo files (commits),
- remote URLs,
- logs/outputs.
- If a task requires bypassing protections, stop and ask the user for explicit confirmation and a concrete reason.
- If Docker access is enabled, never run destructive commands (
rm,prune,system prune, volume/network removals) unless the user explicitly requests them.
Conventions
- Branch strategy (default):
agentis the long-lived integration branch for the agent.- task branches
agent/<task>-<yyyymmdd>are created fromagentand merged back intoagentafter testing. - dates are UTC (scripts use
date -u).
- Push strategy:
- pushing
agent/<task>-...is optional and used for remote backup during work (in case the sandbox/volume breaks). agent-merge-to-agentpushesagent(this is the normal “publish progress” step).
- pushing
- PR flow:
agent→mainonly on explicit user instruction (andagent-open-prenforces: PR intomain/masteronly fromagent). - Prefer PRs for all changes, even if branch protection is not enforced server-side.
Pre-flight (common failure points)
- Ensure GitHub auth exists inside the container:
gh auth status- docs:
docs/auth-inside-container.md
- Ensure bot identity is set (inside container):
git config --global user.name ...git config --global user.email ...
Available scripts / commands
agent-task-branch <task-slug>: ensure localagentexists, then create/switch toagent/<task>-<yyyymmdd>fromagent.agent-merge-to-agent: merge current task branch intoagentand pushagent.agent-open-pr [base]: open PR from current branch to base. PRagent→mainis allowed only on explicit user instruction (policy rule).agent-new-branch <task-slug>: legacy helper (does not ensure baseagent); preferagent-task-branch.
Operational workflow
- Clone repos under
/workspaces/work/<repo>. - Create a task branch from
agent:agent-task-branch <task>. - Commit small, coherent chunks.
- Optional remote backup push (during work):
git push -u origin HEAD. - Merge into
agentand pushagent:agent-merge-to-agent. - Only if the user explicitly asked: open PR
agent→main:- ensure you're on
agent - run
agent-open-pr
- ensure you're on
PR bodies should include:
- what changed,
- how to test.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.