Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# AGENTS.md

This repository is a **GitHub-native contract pack** for coding agents.
It is not a forge, not a VCS, and not an orchestrator.
This repository defines the **GitHub identity and permissions contract for coding agents**: a user-owned GitHub App bot, a human-owned default-deny capability policy, and machine-checked provenance trailers separate agent contributions from human authors.

Hermes, Claude Code, GitHub Copilot, OpenClaw, Cursor, Codex, and other harnesses **MUST NOT run git commit or git push as the signed-in human when `GITHUB_APP_ID` and `GITHUB_APP_PRIVATE_KEY_PATH` are set**. Load `skills/agent-policy/SKILL.md` and `skills/signed-bot-commit/SKILL.md`; use `node scripts/agent-pr.mjs` for explicitly authorized publication. Missing App configuration means leave changes uncommitted, never use a human credential fallback.

Humans own `agent-policy.yml` and workflow changes. Default merge is human-only; `--merge-when-green` additionally requires human authorization and `merger.merge` in local and reviewed policy. Never self-grant, self-approve, force-push, or deploy.

This is a GitHub-native contract pack, not a forge, VCS, or orchestrator. Start with [onboarding](docs/ONBOARDING.md) and [the threat model](docs/THREAT_MODEL.md).

## What this repo is

Expand Down
22 changes: 22 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cff-version: 1.2.0
message: "If you use this contract pack, please cite it using this metadata."
type: software
title: github-agent-contracts
authors:
- name: R4yHarris
url: "https://github.com/R4yHarris/github-agent-contracts"
repository-code: "https://github.com/R4yHarris/github-agent-contracts"
abstract: >-
github-agent-contracts gives Hermes, Claude Code, GitHub Copilot, OpenClaw, Cursor, and Codex a user-owned GitHub App bot identity and a default-deny permission policy, separate from the human GitHub user.
keywords:
- GitHub App
- agent identity
- agent permissions
- commit trailers
- Hermes
- Claude Code
- GitHub Copilot
- OpenClaw
- Cursor
- Codex
license: MIT
126 changes: 44 additions & 82 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,126 +1,88 @@
# github-agent-contracts

GitHub-native contracts for attributable agent commits and PRs, distinct from human-authored work. **GitHub stays the repository host.** The control is a required PR check, a protected branch, bot authorship, and machine-checked trailers. The App is how agents authenticate to GitHub.
github-agent-contracts gives Hermes, Claude Code, GitHub Copilot, OpenClaw, Cursor, and Codex a user-owned GitHub App bot identity and a default-deny permission policy, separate from the human GitHub user.

This is community OSS for GitHub, not a GitHub replacement.
## Give agents their own identity in 3 steps

## Enable agent identity in 3 steps
1. **Create your own GitHub App** from [docs/app-manifest.json](docs/app-manifest.json). Your user or organization owns the App and its key; install it on selected repositories only. Follow [ONBOARDING](docs/ONBOARDING.md) for registration and the two publisher environment variables.
2. **Define repository permissions** in root `agent-policy.yml`. A human reviews and publishes the [default-deny example](examples/agent-policy.yml). Coder can commit feature branches, open draft PRs, comment, and label; merge and deploy remain denied by default. See [POLICY](docs/POLICY.md).
3. **Publish as the App bot** with `node scripts/agent-pr.mjs`. Copy the required files from the onboarding guide, review and stage the changes, pass tests and policy gates, then run the authorized publication command:

1. **[Register App from manifest](docs/app-manifest.json).** Create an App owned by you or your organization, keep it private to that account, and choose **Only select repositories** during installation.
2. **Configure and copy.** Supply `GITHUB_APP_ID` and `GITHUB_APP_PRIVATE_KEY_PATH` outside git, then copy AGENTS.md, the policy and commit skills, publisher/loader, and check Action/workflow as listed in [ONBOARDING.md](docs/ONBOARDING.md). A human installs the root capability policy. CI stores the key in the `GITHUB_APP_PRIVATE_KEY` secret.
3. **Protect and publish.** Require `check-agent-trailers`, disallow direct pushes to `main` and agent bypass, and leave merging to humans by default. After tests, policy gates, and reviewed staging, authorized agent publication ends with `node scripts/agent-pr.mjs --message "..."`; without App configuration, stop with uncommitted changes, never a human-token fallback.
```bash
node scripts/agent-pr.mjs --message "feat: add input validation"
```

The manifest is a static template, not a hosted registration button. An owner-controlled manifest callback is a follow-on; placeholder URLs must be replaced before completing GitHub's flow. The [onboarding guide](docs/ONBOARDING.md) describes that boundary and the manual registration fallback.
**Humans merge by default.** Opt-in merging requires a human-published `merger.merge` grant plus explicit authorization for `--merge-when-green`, successful checks on the exact head SHA, and all required reviews. Coder `merge` alone is insufficient.

### Create your own App (recommended)
This is **not a git host, not `copilot[bot]`, not a personal access token (PAT), and not a maintainer-owned App to install on other people's private repositories**. It is community OSS for GitHub, not a GitHub replacement.

Your account or organization owns the App and controls its private key. No project-maintainer installation is needed. Use the [manifest](docs/app-manifest.json), [harness guide](docs/HARNESSES.md), [dedicated machine guide](docs/ORCHESTRATION-MACHINE.md), and [threat model](docs/THREAT_MODEL.md). The App key holder can mint tokens for **every installation of that App**, so installation scope and key custody matter. The manifest includes Checks read-only; humans must accept this permission on existing installations for opt-in merge.
[ONBOARDING](docs/ONBOARDING.md) | [POLICY](docs/POLICY.md) | [THREAT_MODEL](docs/THREAT_MODEL.md) | [HARNESSES](docs/HARNESSES.md) | [ORCHESTRATION-MACHINE](docs/ORCHESTRATION-MACHINE.md) | [AGENTS.md](AGENTS.md)

### Demo App
## Which approach fits?

`r4yharris-agent-coder` is an optional maintainer demo identity for **public playground repositories only**. Do not install it on private or production repositories or grant it protected-branch bypass. A globally shared maintainer App is not this standard's production onboarding model.
| Approach | Identity and permissions | Role |
| --- | --- | --- |
| **This pack** | Your GitHub App bot, repository-scoped installation tokens, root capability policy, and commit trailers | A concrete identity and publishing contract shared by different agent harnesses |
| **`copilot[bot]`** | GitHub-managed bot identity for supported Copilot activity | Not a credential or user-owned App you can assign to Hermes or arbitrary agents |
| **Personal access token** | Authenticates as the GitHub user that owns the token, including a separately managed machine user | User-bound access, not an App-owned bot identity; no PAT fallback in this pack |
| **[gh-aw](https://github.com/github/gh-aw)** | GitHub Actions workflows with declared permissions and safe outputs | Agent workflow automation that can consume these contracts; not a replacement for the repository identity policy |

## Shared contracts
## What enforces the contract?

Use it so Copilot, [GitHub Agentic Workflows](https://github.com/github/gh-aw), Hermes, Codex, Cursor, and similar tools share one repo-level convention:
The control is **required PR check + protected branch + bot author + trailers**. The App authenticates GitHub operations. App permissions, branch protection/environments, and the policy must all allow an action; installing an App or adding a prompt does not replace these gates.

| Contract | Where |
| --- | --- |
| Agent instructions | `AGENTS.md` |
| Default-deny capabilities | `examples/agent-policy.yml` + `docs/POLICY.md` |
| Copilot instructions | `.github/copilot-instructions.md` |
| Portable skills | `skills/*/SKILL.md` |
| Bot identity | `docs/github-app-agent-identity.md` |
| Provenance trailers | `docs/commit-trailers.md` + `scripts/check-agent-trailers.mjs` |
| MCP allowlist | `skills/github-mcp-allowlist/SKILL.md` |
| Safe-output Actions | `.github/workflows-src/` |
| PR trailer Action | `.github/actions/check-agent-trailers/action.yml` |
The [publisher](scripts/agent-pr.mjs) discovers the configured App's bot, sets both author and committer, appends `AI-Agent` and `AI-Model`, pushes an authorized feature branch, and creates a draft PR if none exists. It uses `GITHUB_APP_ID` and `GITHUB_APP_PRIVATE_KEY_PATH` from the environment, not a signed-in human's credentials. Missing configuration or denied policy means stop with changes uncommitted.

Humans can review the same rules agents follow, while commit trailers make claimed agent contributions inspectable. The contracts do not schedule agents or prove their identity by themselves.
Humans own policy and workflow changes. Agents cannot grant themselves capabilities or publish `.github/workflows/**` through this helper. Never force-push, push main directly, squash, or self-approve. Deploy and direct protected-push implementations are out of scope.

## Consume the contracts
Trailers and bot fields are claims, not cryptographic proof of who wrote the code. Git commits are currently unsigned; see the [threat model](docs/THREAT_MODEL.md) before adopting this in a repository that requires signing.

- **Copilot / VS Code:** use [AGENTS.md](AGENTS.md) and [.github/copilot-instructions.md](.github/copilot-instructions.md) only as harness configuration. They reference the common commit skill and publisher; no additional agent mode or skill autodiscovery setup is required.
- **Claude Code:** use the short [CLAUDE.md](CLAUDE.md) pointer to AGENTS.md, not a duplicate policy.
- **gh-aw:** include the repository rules and relevant skills in the workflow's instructions. Start with the [issue clarifier source](.github/workflows-src/issue-clarifier.md); the agent is read-only and can request only an `add-comment` safe output.
- **Hermes, Codex, and other agents:** load `AGENTS.md` as repository instructions and import the selected `SKILL.md` files using that runtime's skill mechanism. Discovery paths differ by runtime; this pack does not patch those runtimes.
- **GitHub MCP:** use the [allowlist skill](skills/github-mcp-allowlist/SKILL.md) with a repository-scoped GitHub App installation token. Keep the agent's tools read-only; give approved output handlers only the capabilities they need.
## Attach your agent

Adapt the workspace-specific names in the instruction files when adopting the pack. Human approval, scoped permissions, and tool restrictions enforce boundaries; prompts alone do not.
- **Hermes:** read [AGENTS.md](AGENTS.md), load [agent-policy](skills/agent-policy/SKILL.md) and [signed-bot-commit](skills/signed-bot-commit/SKILL.md), and publish only through the helper. Use the [GitHub MCP allowlist](skills/github-mcp-allowlist/SKILL.md) for scoped reads.
- **Claude Code:** start with the [CLAUDE.md](CLAUDE.md) pointer to the shared rules.
- **GitHub Copilot:** use [AGENTS.md](AGENTS.md) and [.github/copilot-instructions.md](.github/copilot-instructions.md).
- **OpenClaw, Cursor, and Codex:** load the same repository instructions and skills through your runtime's supported mechanism. This pack does not install or patch those runtimes.

See [HARNESSES.md](docs/HARNESSES.md) for the minimal integration in each runtime. Any agent that honors AGENTS.md must honor signed-bot-commit.
See [HARNESSES](docs/HARNESSES.md) for integration details. On a dedicated WSL/Hermes machine, keep only the coder App key, no human GitHub login, and merge disabled until a separate approved merger context is available; follow [ORCHESTRATION-MACHINE](docs/ORCHESTRATION-MACHINE.md). Policy does not select or switch App keys.

## Use in another repo

Follow the [adoption guide](docs/adopt.md) and copy the [consumer workflow](examples/consumer-repo/.github/workflows/check-agent-trailers.yml). Reference the pinned public Action without copying scripts, or vendor the Action and both scripts together. No package registry or GitHub App credentials are needed for the trailer check.

## Capability policy

Hermes, Copilot, Claude Code, and Cursor share one human-owned root `agent-policy.yml`. The [example](examples/agent-policy.yml) allows coder branch commits, draft PRs, comments, and labels; merger and deploy allow-lists are empty. Missing policy denies publication, and agents must not edit policy to grant themselves rights.

Read [POLICY.md](docs/POLICY.md) for the three permission layers, human bootstrap, and optional `--merge-when-green` flow, and [ROLES.md](docs/ROLES.md) for role-key separation. Merging remains disabled unless a human publishes `roles.merger.allow: [merge]` and explicitly authorizes the flag; coder `merge` alone is insufficient. The flag requires a successful exact-head trailer check and all GitHub reviews, creates a merge commit, and cleans up only unchanged remote and local feature refs after confirmation. Policy does not select the App key; a coder-only WSL host must disable merge and a trusted launcher/operator must use a separately approved merger App/context. Protected pushes and deploys remain unsupported. No active policy grant or hosted control plane is installed by this pack.
Follow [ONBOARDING](docs/ONBOARDING.md) for the complete file list and [adopt.md](docs/adopt.md) for distribution options. Copy the [consumer workflow](examples/consumer-repo/.github/workflows/check-agent-trailers.yml) with a pinned public Action, or vendor the [composite Action](.github/actions/check-agent-trailers/action.yml) with both checker scripts. No private-package infrastructure or App credentials are required for the read-only trailer check itself.

## Non-goals
The manifest is a static template, not a hosted registration button. Its placeholder callback URLs need an owner-controlled receiver for GitHub's manifest flow; onboarding also documents the manual registration path. No hosted callback or control plane is provided.

- No self-hosted forge
- No new version-control object store
- No secrets in git
- No unscoped tokens in examples
Create an App owned by the consuming user or organization. The key holder can mint tokens for **every installation of that App**. The maintainer's `r4yharris-agent-coder` demo is for public playgrounds only, never private or production repositories. See the [identity guide](docs/github-app-agent-identity.md) and [role separation](docs/ROLES.md).

## Trailer checker
## Check commit provenance

Requires Node 20+ and Git; no package installation is needed.
Node 20+ and Git are required; the scripts have no runtime dependencies. Publication also needs `gh`.

```bash
node scripts/check-agent-trailers.mjs --help
node scripts/check-agent-trailers.mjs --message-file path/to/message.txt --json
node scripts/check-agent-trailers.mjs --require --message "fix typo"
node --test tests/*.test.mjs
```

Agent-classified commits require these nonempty trailers after a blank line at the end of the message:
An agent commit has a blank-separated footer:

```
AI-Agent: copilot-coding-agent
```text
AI-Agent: your-app-slug
AI-Model: unknown
```

The default checks messages containing `AI-Agent:` and GitHub noreply bot authors. Human privacy addresses alone do not trigger a check. For local author detection, pass `--author-email`; `--require` checks every message. Exit codes are `0` (pass), `1` (missing trailers), and `2` (usage or input error).

See the [trailer spec](docs/commit-trailers.md) for parsing rules and the Action's `require-on-all-commits: "true"` option. The [threat model](docs/THREAT_MODEL.md) explains why trailers and bot fields do not prove authorship, and why unsigned human commits pass the default check.

## PR workflow

The [read-only PR workflow](.github/workflows/check-agent-trailers.yml) checks every PR commit, including bot-authored commits without an `AI-Agent:` marker. It uses the [composite Action](.github/actions/check-agent-trailers/action.yml) and both checker scripts from the base revision. Missing or incomplete history fails closed.

When vendoring this check, copy the workflow, Action directory, and both `scripts/check-*.mjs` files together. Bootstrap the Action and scripts on the base branch before enabling the local workflow. No App token or other custom secret is needed for this workflow.

## Agentic workflow

Keep the issue clarifier under `.github/workflows-src/` until `gh` and the `gh-aw` extension are available. To adopt it, copy the Markdown source into `.github/workflows/issue-clarifier.md`, then run:

```bash
gh aw compile
```

Review the generated workflow and configure the chosen engine's authentication outside git before enabling it. Its source uses `permissions: read-all` and only `safe-outputs.add-comment`; it must not create branches or push. No compiled lockfile is shipped without compiler validation.
The check inspects messages containing `AI-Agent:` and GitHub noreply bot authors by default. Unmarked human commits pass. `--require`, or the Action's `require-on-all-commits: "true"`, requires trailers on every commit. See the [trailer specification](docs/commit-trailers.md) for parsing, exit codes, and limits.

## Publish a new empty GitHub repo
The [PR workflow](.github/workflows/check-agent-trailers.yml) uses the trusted base revision's checker with full history and read-only permissions. Bootstrap the Action and scripts before enabling the local workflow. Humans must configure required checks, reviews, and branch protection; the script does not configure them.

From the local repository root, after creating an empty GitHub repository:
## With gh-aw

These bootstrap commands are for a **human**. Agents must use the App-authenticated publication helper and never assume the human's identity.
The [issue clarifier source](.github/workflows-src/issue-clarifier.md) illustrates `permissions: read-all` and a comment-only safe output. Approved output handlers must enforce the repository policy too. Keep Markdown sources uncompiled unless `gh aw` is already installed; no generated lockfile or agent runtime is required to use the identity contract.

```bash
git init -b main
git add .
git commit -m "feat: day-1 GitHub agent contracts"
git remote add origin git@github.com:YOUR_LOGIN/github-agent-contracts.git
git push -u origin main
```
## Find and cite this pack

If this folder already has commits and an `origin`, only `git push` is needed to publish new commits. No remote changes are needed.
[DISCOVERY.md](docs/DISCOVERY.md) lists the user questions this repository answers, harness attachment steps, suggested topics, and a citation snippet. Skill hubs can index the root [SKILL.md](SKILL.md); citation tools can use [CITATION.cff](CITATION.cff).

## License

MIT. See `LICENSE`.
MIT. See [LICENSE](LICENSE).
Loading
Loading