# A gate by hand

> GDD without the skills: translated into what you already have (CI, tests, CODEOWNERS), and a first gate ready to copy into your repository.

GDD without the skills, with what your repository already has.

Prepare, stop 2 of 4

A gate by hand is a mandatory check before merging, put together with branch protection, CI, tests and `CODEOWNERS`. It needs no new tools. Whether it truly blocks, and doesn't just warn, depends on your plan: without protected branches or rulesets, which are paid on private GitHub repositories, CI warns but doesn't block.

## Your first gate

1. Create the `checks/<change>` branch from `main` and keep the approved tests on it, which another agent can draft. Only you write to that branch.
2. Create the `<change>` branch from the checks one, for the agent. It can add tests, but it can't change or delete the approved ones, or touch `package.json` or CI.
3. If it needs to touch those files, it stops and asks you. You make that change yourself, on the checks branch.
4. Add the `seal` workflow, which compares the two branches, and the `gates` workflow, which runs the tests.
5. Mark the delicate paths in `CODEOWNERS`, CI itself included.
6. In the settings, require a pull request on `main`, passing `seal` and `gate`, tied to GitHub Actions, and review by the code owners. Dismiss approvals when a new push comes in. And make sure not even whoever administers the repository skips the rule.
7. Create a ruleset on `checks/**/*` so that only you can create and write.
8. Give the agent its own credentials, with no permission to touch workflows.

Before relying on the gate, run an incorrect charge and a valid charge. The first must fail for the expected reason and the second must pass. Check which account can change the criteria, the run or its result.

## The files

| File | What it does |
| --- | --- |
| `.github/workflows/seal.yml` | Compares the agent's branch with the checks one and blocks the changes that aren't allowed. |
| `.github/workflows/gates.yml` | Installs with `npm ci` and runs `npm test`. |
| `CODEOWNERS` | Gives an owner to `/payments/`, `/.github/` and `/CODEOWNERS`. |

## What it guarantees, and what it doesn't

| It guarantees | It can't guarantee |
| --- | --- |
| That tests already approved don't change or disappear. | The whole core of GDD. What's missing is in The engine. |
| That nothing gets merged with failing tests. | Catching a solution tailored to the tests: that takes a reviewer and hidden examples. |
| That the agent doesn't change what you approved, if it uses its own credentials. | Anything, if the agent uses your credentials: with them it can do whatever you can. |
| Review by the code owners on the delicate paths. | That whoever administers the repository doesn't change the settings. |

## Before you cross: The agent works with your credentials. Does the gate still hold?

- Yes

- No

That's not it. With your credentials it can do whatever you can, including writing to the checks branch.

That's it. With your credentials it can do whatever you can, including writing to the checks branch.

[Next: What each color asks for](https://gate-driven.dev/en/docs/the-colors/index.html.md) [Go on without answering](https://gate-driven.dev/en/docs/the-colors/index.html.md) [Index](https://gate-driven.dev/en/docs/index.html.md)
