2026-05-02 02:33:57 +02:00
# Codex Agent Repository Kit
2026-05-15 03:56:38 +02:00
Reusable setup kit for new or existing repositories that should be easy for Codex agents, humans, and CI workflows to maintain.
2026-05-02 02:33:57 +02:00
2026-05-15 03:56:38 +02:00
This README is for humans. Agent-facing rules live in `AGENTS.md` , `agent-quickstart.md` , `new-repository.md` , and `existing-project.md` .
2026-05-02 02:33:57 +02:00
2026-05-15 03:56:38 +02:00
## What This Kit Adds
2026-05-02 02:33:57 +02:00
2026-05-15 03:56:38 +02:00
- `AGENTS.md` and `.codex/project.md` for agent context.
- Optional Gitea workflows for build, security scan, cleanup, dependency check, release dry run, and template compliance.
- Release, security, handoff, changelog, and contribution templates.
- README blueprint templates for projects that want generated README output.
- Stack notes for Node, Electron, Python, Docker, and static-site projects.
2026-05-02 02:33:57 +02:00
2026-05-15 03:56:38 +02:00
## Recommended New Repository Setup
2026-05-03 02:31:00 +02:00
2026-05-15 03:56:38 +02:00
1. Create the repository in Gitea.
2. Clone it locally with SSH.
3. Copy this kit into the repository with Codex or manually from `files/` .
4. Replace placeholders with real project values.
5. Add repository secrets for CI publishing.
6. Commit and push the baseline.
7. Let the Gitea workflows report any missing setup.
2026-05-03 02:31:00 +02:00
2026-05-15 03:56:38 +02:00
## SSH Setup
2026-05-03 02:31:00 +02:00
2026-05-15 03:56:38 +02:00
Generate a key if you do not already have one:
2026-05-03 02:31:00 +02:00
2026-05-15 03:56:38 +02:00
```powershell
ssh-keygen -t ed25519 -C "you@example .com"
2026-05-03 02:31:00 +02:00
```
2026-05-15 03:56:38 +02:00
Start the SSH agent and add the key:
2026-05-03 02:31:00 +02:00
2026-05-15 03:56:38 +02:00
```powershell
Start-Service ssh-agent
ssh-add $env:USERPROFILE\.ssh\id_ed25519
```
Show the public key:
```powershell
Get-Content $env:USERPROFILE\.ssh\id_ed25519.pub
```
Add that public key in Gitea:
```text
Profile -> Settings -> SSH / GPG Keys -> Add Key
```
Clone with SSH:
```bash
git clone git@git .example.com:OWNER/REPOSITORY.git
cd REPOSITORY
```
Verify the remote:
```bash
git remote -v
git status --short
```
2026-05-03 02:31:00 +02:00
2026-05-15 03:56:38 +02:00
## Applying The Kit With Codex
2026-05-02 02:33:57 +02:00
2026-05-15 03:56:38 +02:00
For a new repository, start Codex in the target repository and use:
2026-05-02 02:33:57 +02:00
```text
2026-05-15 03:56:38 +02:00
Use the Codex Agent Repository Kit.
Read manifest.json, then use new-repository.md.
Create the smallest useful baseline for this repository.
Replace placeholders with real values from this repository.
Keep commands truthful and do not invent scripts that cannot run.
Do not create a release.
2026-05-02 02:33:57 +02:00
```
2026-05-15 03:56:38 +02:00
For an existing repository:
2026-05-02 02:33:57 +02:00
2026-05-15 03:56:38 +02:00
```text
Use the Codex Agent Repository Kit.
Read manifest.json, then use existing-project.md.
Retrofit the baseline without replacing existing project structure or README knowledge.
Preserve current CI behavior and project style.
Do not create a release.
```
## Manual Copy Map
2026-05-03 02:31:00 +02:00
2026-05-15 03:56:38 +02:00
Use `manifest.json` as the source of truth. Common targets:
2026-05-02 02:33:57 +02:00
2026-05-15 03:56:38 +02:00
| Template | Target |
2026-05-02 02:33:57 +02:00
| --- | --- |
| `files/AGENTS.md` | `AGENTS.md` |
| `files/project.md` | `.codex/project.md` |
| `files/build-gitea.yml` | `.gitea/workflows/build.yml` |
2026-05-03 22:01:41 +02:00
| `files/security-scan-gitea.yml` | `.gitea/workflows/security-scan.yml` |
2026-05-03 22:08:43 +02:00
| `files/repo-cleanup-gitea.yml` | `.gitea/workflows/repo-cleanup.yml` |
2026-05-03 22:17:27 +02:00
| `files/dependency-check-gitea.yml` | `.gitea/workflows/dependency-check.yml` |
| `files/release-dry-run-gitea.yml` | `.gitea/workflows/release-dry-run.yml` |
| `files/template-compliance-gitea.yml` | `.gitea/workflows/template-compliance.yml` |
2026-05-02 02:33:57 +02:00
| `files/SECURITY.md` | `SECURITY.md` |
| `files/CHANGELOG.md` | `CHANGELOG.md` |
2026-05-03 21:46:59 +02:00
| `files/CONTRIBUTING.md` | `CONTRIBUTING.md` |
2026-05-15 03:56:38 +02:00
| `files/release-checklist.md` | `docs/release-checklist.md` |
| `files/security-review.md` | `docs/security-review.md` |
2026-05-03 21:46:59 +02:00
| `files/agent-handoff.md` | `docs/agent-handoff.md` |
2026-05-03 11:57:22 +02:00
2026-05-15 03:56:38 +02:00
## Required Placeholder Values
2026-05-03 21:46:59 +02:00
2026-05-15 03:56:38 +02:00
Replace or remove all placeholders before considering a repository ready:
2026-05-02 02:33:57 +02:00
```text
PROJECT_NAME
PROJECT_DESCRIPTION
REPOSITORY_OWNER
REPOSITORY_NAME
PACKAGE_NAME
ARTIFACT_NAME
ARTIFACT_OUTPUT_DIRECTORY
AUTHOR_NAME
PROJECT_STACK
DOWNLOAD_URL
2026-05-15 02:55:41 +02:00
CI_URL
RELEASES_URL
GITEA_SERVER_URL
2026-05-02 02:33:57 +02:00
BUILD_COMMAND
TEST_COMMAND
LINT_COMMAND
AUDIT_COMMAND
2026-05-15 02:55:41 +02:00
README_COMMAND
INSTALL_COMMAND
DEV_COMMAND
PACKAGE_MANAGER
PROJECT_VERSION
COMMIT_OR_VERSION
2026-05-02 02:33:57 +02:00
```
2026-05-15 03:56:38 +02:00
If a value does not apply, remove that section instead of leaving fake data. If a value is genuinely unknown, mark it as `PENDING` .
2026-05-15 00:43:49 +02:00
2026-05-15 03:56:38 +02:00
## Token Overview
2026-05-03 11:57:22 +02:00
2026-05-15 03:56:38 +02:00
Use separate tokens for separate jobs.
2026-05-03 11:57:22 +02:00
2026-05-15 03:56:38 +02:00
| Token | Location | Purpose |
| --- | --- | --- |
| `REGISTRY_TOKEN` | Repository secret | CI package publishing from Gitea Actions |
| `GITEA_TOKEN` | Local environment or repository secret | Gitea API access for issues, releases, workflow polling, and repository metadata |
2026-05-03 11:57:22 +02:00
2026-05-15 03:56:38 +02:00
Repository secrets are available to workflows. They are not visible to local Codex sessions. Local Codex API actions need a local environment variable.
2026-05-03 11:57:22 +02:00
2026-05-15 03:56:38 +02:00
## Gitea Token Permissions
2026-05-03 02:31:00 +02:00
2026-05-15 03:56:38 +02:00
For the token permission screen shown in Gitea, choose:
2026-05-03 22:01:41 +02:00
2026-05-15 03:56:38 +02:00
```text
Repository and Organization Access: All (public, private, and limited)
issue: Read and Write
package: Read and Write
repository: Read and Write
user: Read
activitypub: No Access
admin: No Access
misc: No Access
notification: No Access
organization: No Access
```
2026-05-03 22:01:41 +02:00
2026-05-15 03:56:38 +02:00
These permissions cover:
2026-05-03 22:01:41 +02:00
2026-05-15 03:56:38 +02:00
- creating and reading issues,
- creating and reading releases,
- uploading package registry files,
- reading repository metadata,
- polling workflow runs where the Gitea API allows it.
2026-05-03 22:01:41 +02:00
2026-05-15 03:56:38 +02:00
Use a dedicated bot or automation user when possible.
2026-05-03 22:01:41 +02:00
2026-05-15 03:56:38 +02:00
## Setting Local Tokens
2026-05-03 22:08:43 +02:00
2026-05-15 03:56:38 +02:00
Set a local token for Codex or shell-based API work.
2026-05-03 22:08:43 +02:00
2026-05-15 03:56:38 +02:00
Current PowerShell session:
2026-05-03 22:08:43 +02:00
2026-05-15 03:56:38 +02:00
```powershell
$env:GITEA_TOKEN = "paste-token-here"
```
2026-05-03 22:08:43 +02:00
2026-05-15 03:56:38 +02:00
Persist for the current Windows user:
2026-05-03 22:08:43 +02:00
2026-05-15 03:56:38 +02:00
```powershell
setx GITEA_TOKEN "paste-token-here"
```
2026-05-03 22:08:43 +02:00
2026-05-15 03:56:38 +02:00
Open a new terminal after `setx` .
2026-05-03 22:17:27 +02:00
2026-05-15 03:56:38 +02:00
Test repository API access:
2026-05-03 22:17:27 +02:00
2026-05-15 03:56:38 +02:00
```powershell
$headers = @{ Authorization = "token $env:GITEA_TOKEN" }
Invoke-RestMethod `
-Uri "GITEA_SERVER_URL/api/v1/repos/REPOSITORY_OWNER/REPOSITORY_NAME" `
-Headers $headers
```
2026-05-03 22:17:27 +02:00
2026-05-15 03:56:38 +02:00
Test issue access:
2026-05-03 22:17:27 +02:00
2026-05-15 03:56:38 +02:00
```powershell
Invoke-RestMethod `
-Uri "GITEA_SERVER_URL/api/v1/repos/REPOSITORY_OWNER/REPOSITORY_NAME/issues?state=open&limit=1" `
-Headers $headers
```
2026-05-03 22:17:27 +02:00
2026-05-15 03:56:38 +02:00
## Setting Repository Secrets
2026-05-03 22:17:27 +02:00
2026-05-15 03:56:38 +02:00
In Gitea:
2026-05-03 22:17:27 +02:00
2026-05-15 03:56:38 +02:00
```text
Repository -> Settings -> Actions -> Secrets -> Add Secret
```
2026-05-03 22:17:27 +02:00
2026-05-15 03:56:38 +02:00
Add:
2026-05-03 22:17:27 +02:00
2026-05-15 03:56:38 +02:00
```text
REGISTRY_TOKEN
```
2026-05-03 22:17:27 +02:00
2026-05-15 03:56:38 +02:00
Use a token with package write access. If you want workflows to create releases or issues too, add a separate secret:
2026-05-03 22:17:27 +02:00
2026-05-15 03:56:38 +02:00
```text
GITEA_TOKEN
```
2026-05-03 22:17:27 +02:00
2026-05-15 03:56:38 +02:00
Keep package publishing and release or issue automation separate when possible. It makes permission reviews easier.
2026-05-03 22:17:27 +02:00
2026-05-15 03:56:38 +02:00
## Package Publishing
2026-05-03 22:17:27 +02:00
2026-05-15 03:56:38 +02:00
`files/build-gitea.yml` can publish generic packages when `REGISTRY_TOKEN` is available.
2026-05-03 02:08:36 +02:00
2026-05-15 03:56:38 +02:00
The workflow:
2026-05-03 02:08:36 +02:00
2026-05-15 03:56:38 +02:00
- builds project artifacts,
- copies them to URL-safe filenames,
- uploads immutable versioned packages,
- updates a stable `latest` package path.
2026-05-03 02:08:36 +02:00
2026-05-15 03:56:38 +02:00
The workflow uses:
2026-05-03 02:08:36 +02:00
```text
2026-05-15 03:56:38 +02:00
GITHUB_SERVER_URL
GITHUB_REPOSITORY_OWNER
GITHUB_REPOSITORY
REGISTRY_TOKEN
2026-05-03 02:08:36 +02:00
```
2026-05-15 03:56:38 +02:00
When those values are unavailable, replace `GITEA_SERVER_URL` , `REPOSITORY_OWNER` , and related placeholders before use.
2026-05-03 02:10:10 +02:00
2026-05-15 03:56:38 +02:00
## Agent Follow-up Issues
2026-05-03 02:10:10 +02:00
2026-05-15 03:56:38 +02:00
Agents should create focused tracker issues for real follow-up work that is outside the current scope or can be handled independently by humans or other agents.
2026-05-15 03:30:40 +02:00
2026-05-15 03:56:38 +02:00
An issue should include:
2026-05-15 03:30:40 +02:00
- observed problem,
2026-05-15 03:56:38 +02:00
- impact,
- affected files or commands,
2026-05-15 03:30:40 +02:00
- suggested next steps,
- verification already performed.
2026-05-15 03:56:38 +02:00
Agents must not create issues for vague reminders, duplicate work, or tasks they can safely finish immediately. Sensitive details belong in private channels or `docs/agent-handoff.md` , not public issues.
2026-05-15 03:30:40 +02:00
2026-05-15 03:56:38 +02:00
## Release Checklist For A New Repo
2026-05-04 10:59:09 +02:00
2026-05-15 03:56:38 +02:00
Before the first release of a target project:
2026-05-04 10:59:09 +02:00
2026-05-15 03:56:38 +02:00
1. Ensure `AGENTS.md` and `.codex/project.md` match the real project.
2. Replace all placeholders or mark genuinely unknown values as `PENDING` .
3. Configure `REGISTRY_TOKEN` if packages are published.
4. Configure `GITEA_TOKEN` only if workflows need issue or release API access.
5. Verify SSH push access.
6. Run lint, test, build, and audit commands that exist.
7. Run `git diff --check` .
8. Confirm release artifacts do not include Codex kit metadata unless explicitly wanted.
9. Push and poll workflows to success or document the blocker.
2026-05-04 10:59:09 +02:00
2026-05-15 03:56:38 +02:00
## Updating The Kit In A Project
2026-05-03 02:31:00 +02:00
2026-05-15 03:56:38 +02:00
When this kit changes, update target repositories conservatively:
2026-05-02 02:33:57 +02:00
2026-05-15 03:56:38 +02:00
```bash
git status --short
git pull --ff-only
2026-05-02 02:33:57 +02:00
```
2026-05-15 03:56:38 +02:00
Then ask Codex:
2026-05-02 02:33:57 +02:00
```text
2026-05-15 03:56:38 +02:00
Update this repository's Codex Agent Repository Kit files from the latest kit.
Preserve project-specific README content, commands, release rules, and workflow customizations.
Do not overwrite unrelated changes.
2026-05-02 02:33:57 +02:00
```