# Gate Worktree Git Safety > Nota interna del proyecto no-mistakes. Se usa al cambiar la contención recursiva del gate, la colocación del worktree de run, las llamadas a git en el gate bare, el targeting de PR de GitHub o los hooks post-receive. Fuente: https://skillsagentes.com/skills/kunchenguid/no-mistakes/gate-worktree-git-safety Markdown: https://skillsagentes.com/skills/kunchenguid/no-mistakes/gate-worktree-git-safety.md Repositorio: https://github.com/kunchenguid/no-mistakes Autor: kunchenguid Licencia: MIT Actualizado: hace 3 días Coste de contexto: 34 tok instalada, 1.4k tok al activarse, 1.4k tok con todos los archivos del bundle Bundle: 1 archivo, 5 KB Permisos que pide: ninguno declarado ## Instalación Un skill son archivos markdown: los mismos archivos valen para cualquier agente y lo único que cambia es el directorio de destino, es decir la bandera `--agent`. Añade `-g` para instalarlo en todos los proyectos de la máquina. ```bash # Claude Code npx -y skills add kunchenguid/no-mistakes --skill gate-worktree-git-safety --agent claude-code # Cursor npx -y skills add kunchenguid/no-mistakes --skill gate-worktree-git-safety --agent cursor # Codex npx -y skills add kunchenguid/no-mistakes --skill gate-worktree-git-safety --agent codex # Gemini CLI npx -y skills add kunchenguid/no-mistakes --skill gate-worktree-git-safety --agent gemini # Windsurf npx -y skills add kunchenguid/no-mistakes --skill gate-worktree-git-safety --agent windsurf # Cline npx -y skills add kunchenguid/no-mistakes --skill gate-worktree-git-safety --agent cline ``` ## Qué hace - `internal/gatecontext` es el clasificador único de la contención recursiva del gate: combina identidad del directorio del gate con ancestría del peer IPC autenticado por el OS; `NO_MISTAKES_GATE` es solo diagnóstico. - La colocación del worktree de run (`worktree_roots`) la decide la configuración una sola vez al crear el run y se persiste en `runs.worktree_dir`; todo consumidor posterior la lee con `worktrees.RecordedDir`, nunca la re-deriva. - En repos de gate bare, los harnesses inyectan `safe.bareRepository=explicit`; toda llamada a git va por `git.Run`, que antepone `--git-dir=`, nunca por descubrimiento vía `cmd.Dir` o `-C`. - Los comandos `gh` que apuntan a un PR deben nombrarlo explícitamente por número o URL vía `prSelector`, porque el daemon corre `gh` desde el gate bare cuyo HEAD es la rama default. - El valor `--gate` del hook post-receive nunca viene de un `$(pwd)` desnudo; el script resuelve un directorio de gate absoluto y `normalizeNotifyGatePath` es una segunda capa. ## Cuándo usarla - Se cambia la contención recursiva del gate, la colocación del worktree de run, las llamadas a git en el gate bare, el targeting de PR de GitHub o los hooks post-receive. ## Qué la activa - "Voy a tocar la contención de ejecución recursiva del gate" - "Cambia dónde se colocan los worktrees de run" - "Revisa el targeting de PR con gh desde el gate bare" ## Archivos - SKILL.md — 5 KB ## SKILL.md Reproducido tal cual desde kunchenguid/no-mistakes bajo MIT. Esta sección es el documento original y está en inglés. **Recursive Gate-Execution Containment** - `internal/gatecontext` is the single classifier for recursive pipeline control. It combines canonical registered gate common-directory identity with OS-authenticated IPC peer ancestry; `NO_MISTAKES_GATE` is diagnostic only. CLI preflight, daemon mutation ingress, gate init/eject, branch-sync mutation, and the managed pre-receive hook must all keep using that owner so marker removal, cwd changes, and direct pushes cannot bypass refusal. Read-only AXI status/logs, help, and doctor remain available. Regressions: `internal/gatecontext`, `TestGateStepCannotStartRecursivePipeline`. - Every pipeline agent prompt receives the phase boundary from `internal/gateguidance`, and the generated user-level skill reuses the same owner. Step agents return only their assigned phase; the outer executor alone controls other validation, push, PR, and CI phases. Edit `internal/skill/skill.go`, then run `make skill`; never edit the generated skill directly. **Filesystem and Paths** - Use `filepath.Join`; respect `NM_HOME` for app state; directories are `0o755` and files `0o644` by convention. - On macOS, path comparisons may need symlink resolution (`/var` vs `/private/var`); use `worktrees.Canonical`/`worktrees.Contains` wherever run worktree paths are compared, so one spelling matches everywhere. - Run worktree placement (`worktree_roots`) is owned by `internal/worktrees`. Configuration decides it exactly once, at run creation (`Layout.Dir` in `RunManager.startRunWithIntentSource`), and the result is persisted in `runs.worktree_dir`; every later consumer - resume, step diff, startup cleanup, `procreap`, eject, gatecontext attribution - must read it back through `worktrees.RecordedDir` and never re-derive it from config, so a mid-flight edit can neither strand a parked run nor point a removal at a directory the run never used. An empty column means the default `/worktrees//`. - `worktrees.CheckPlacement` is the single policy for an unusable root (inside `NM_HOME`, inside any registered checkout); `config.ValidateWorktreeRoots` owns what the config can judge alone. The daemon refuses to start on an unusable placement, so `init --worktree-root` must refuse exactly the same set or it prints a paste that takes the operator's CLI down, and EVERY `init` refuses to register a checkout that contains a configured root - the same state reached from the other direction. User-facing semantics live in `docs/src/content/docs/reference/global-config.md`. Regressions: `internal/worktrees`, `internal/config/config_worktree_roots_test.go`, `internal/daemon/worktree_roots_test.go`, `internal/gate/eject_sweep_test.go`, `internal/cli/init_test.go`. **Git on Bare Gate Repos (`safe.bareRepository`)** - Agent harnesses and hardened CI inject `safe.bareRepository=explicit`, which forbids cwd-based discovery of bare repositories. Route every gate git call through `git.Run`, which detects a bare git dir and prepends `--git-dir=`; never shell out to git in a bare gate repo relying on `cmd.Dir` or `-C` discovery (issue #362). - Startup gate migration is DB-authoritative with a strict validated `.git` legacy fallback; it must reject non-gates before hook or Git mutation and use `git.RunBare` so a malformed directory cannot discover an ancestor worktree. Completed migrations carry the content-versioned gate-config stamp and normal restarts must stay filesystem-only for current gates. Regressions: `TestMigrateGateConfigsRejectsInvalidDirectoriesAndSkipsCurrentGates`, `TestColdDetachedStartupProductionGateCardinality`. - Regressions: `TestRunOnBareRepoUnderSafeBareRepositoryExplicit`, `TestWorktreeAddRemoveOnBareRepoUnderSafeBareRepositoryExplicit`, `TestInitUnderSafeBareRepositoryExplicit`. **`gh` PR-Targeting From the Bare Gate Repo (`internal/scm/github`)** - The daemon runs `gh` from the detached bare gate repo whose HEAD is the default branch, so every PR-targeting command must name the exact PR explicitly: an empty positional makes `gh pr ` infer the cwd branch (`main`) and return `no pull requests found for branch main` even when the feature PR's checks are green. `GetChecks`, `GetPRState`, `GetMergeableState`, and `UpdatePR` route through the shared `prSelector` (number, else URL, else fail closed) - never append a bare `pr.Number`/`pr.URL` that can be empty. This is the `gh` analogue of the git bare-gate-repo trap above. - Regressions: `TestGetChecksTargetsKnownPRByURLWhenNumberMissing`, `TestPRTargetingReadsFailClosedWithoutIdentity`, `TestPRStateAndMergeableTargetKnownPRByURL`, `TestUpdatePRTargetsKnownPRByURLWhenNumberMissing`, `TestUpdatePRFailsClosedWithoutIdentity`. **Post-Receive Hook Gate Path Resolution (`internal/git/hook.go`)** - The hook's `--gate` value must never come from a bare `$(pwd)`: Git can invoke `post-receive` from a cwd that collapses to `.` (issue #269), which the daemon rejects and the pipeline silently never starts. The hook script resolves an absolute gate dir (git first, hook location fallback), and `normalizeNotifyGatePath` in `internal/cli/daemon_cmd.go` is an independent second layer that absolutizes whatever an already-installed older hook sends. - Regressions: `TestPostReceiveHook_ResolvesAbsoluteGateDir`, `TestPostReceiveHook_FallsBackToHookLocationForGateDir`, `TestNormalizeNotifyGatePathResolvesLegacyDotGate`. ## Dónde encaja - Categoría: [Herramientas para desarrolladores](https://skillsagentes.com/categorias/herramientas-desarrollo.md) — Skills que cambian cómo tu agente escribe, revisa y despliega código. - Creador: [kunchenguid](https://skillsagentes.com/creators/kunchenguid.md) — 16 skills en el directorio - [Todas las skills](https://skillsagentes.com/skills.md) - [Ranking de instalaciones](https://skillsagentes.com/ranking.md) ## Otras skills del mismo repositorio - [No Mistakes](https://skillsagentes.com/skills/kunchenguid/no-mistakes/no-mistakes.md): Valida tus cambios de código por el pipeline de no-mistakes (review de código automatizado, tests, lint, docs, push, PR y CI) antes de que lleguen al destino de push configurado. Se activa con `/no-mistakes`. - [Testing Conventions](https://skillsagentes.com/skills/kunchenguid/no-mistakes/testing-conventions.md): Nota interna del proyecto no-mistakes. Se usa al añadir o cambiar tests, el harness e2e, el aislamiento de procesos de test o el sharding de tests en CI. - [Ci Monitor](https://skillsagentes.com/skills/kunchenguid/no-mistakes/ci-monitor.md): Nota interna del proyecto no-mistakes. Se usa al cambiar la readiness de CI, la recogida de checks del forge, los reruns, los timeouts de CI o la monitorización del ciclo de vida del PR. - [Pr Publication Safety](https://skillsagentes.com/skills/kunchenguid/no-mistakes/pr-publication-safety.md): Nota interna de seguridad del proyecto no-mistakes. Se usa al cambiar el render del cuerpo del PR, la redacción de rutas de home, la publicación de rutas de artefacto o los marcadores de attestation de pipeline. - [Pipeline Review And Agents](https://skillsagentes.com/skills/kunchenguid/no-mistakes/pipeline-review-and-agents.md): Nota interna del proyecto no-mistakes. Se usa al cambiar las sesiones de review, las decisiones sobre findings, los timeouts de agente, el comportamiento del Test local o la conformidad con la intención. ## Skills relacionadas - [Finishing A Development Branch](https://skillsagentes.com/skills/obra/superpowers/finishing-a-development-branch.md): Úsalo cuando la implementación esté completa, todos los tests pasen, y necesites decidir cómo integrar el trabajo. - [Writing Skills](https://skillsagentes.com/skills/obra/superpowers/writing-skills.md): Úsala al crear nuevas skills, editar skills existentes o verificar que funcionan antes de desplegarlas. - [Domain Modeling](https://skillsagentes.com/skills/mattpocock/skills/domain-modeling.md): Construye y afila el modelo de dominio de un proyecto. Úsalo para fijar la terminología o un lenguaje ubicuo, registrar una decisión arquitectónica, o cuando otro skill necesita mantener el modelo. - [Setup Pre Commit](https://skillsagentes.com/skills/mattpocock/skills/setup-pre-commit.md): Configura hooks de pre-commit con Husky y lint-staged (Prettier), typecheck y tests en el repo actual. Úsalo para añadir hooks de pre-commit, configurar Husky o lint-staged. - [Setup Ts Deep Modules](https://skillsagentes.com/skills/mattpocock/skills/setup-ts-deep-modules.md): Conecta dependency-cruiser a un repo TypeScript para que cada paquete sea un módulo profundo: implementación oculta en subcarpetas, alcanzable solo a través de sus entry points. --- Skills Agentes · [Índice de páginas en markdown](https://skillsagentes.com/sitemap.md) · [Inicio](https://skillsagentes.com/index.md)