agentleFS
d-o-hubd-o-hub/github-template-ai-agents/.agents/skills/codeberg-api/SKILL.md

codeberg-api

Skill2 starsChanged 9 days agoMITView on GitHub

Interact with Forgejo/Codeberg repositories via the REST API — read or write files, manage issues, create pull requests, list branches/tags, search repos, and automate CI/CD workflows. Use this skill when the user wants to interact with a Forgejo or Codeberg repository, even if they just say "read a file from Codeberg" or "create an issue on my Forgejo repo". Not for GitHub (use git-github-workflow) or GitLab (use cicd-pipeline).

  • Reads credentials
  • Installs packages
  • Sends data out

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 4 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read or write files in a Forgejo/Codeberg repository

    line 30
  2. Very specific:

    Create/update/close issues or pull requests

    line 31
  3. Distinctive:

    Search repositories or users

    line 33
  4. Very specific:

    Place workflows in .forgejo/workflows/ directory.

    line 168
  5. Distinctive:

    Use matrix builds for parallel testing

    line 189
  6. Distinctive:

    Use branch protection with required workflows

    line 191

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Forgejo/Codeberg API Skill

Automates Forgejo repository operations using the REST API (v1). Compatible with Codeberg and self-hosted Forgejo instances.

When to Use

Activate when you need to:

  • Read or write files in a Forgejo/Codeberg repository
  • Create/update/close issues or pull requests
  • List branches, tags, commits, or releases
  • Search repositories or users
  • Trigger CI/CD via repository dispatch
  • Automate any git-forge operation

Prerequisites

pip install httpx python-dotenv

Authentication

Set FORGEJO_TOKEN (or CODEBERG_TOKEN) in your environment or .env file. Generate at: Forgejo/Codeberg → Settings → Applications → Generate Token.

Required scopes per operation:

OperationScope needed
Read public repos(none, token optional)
Read private reposread:repository
Write files / create PRswrite:repository
Manage issueswrite:issue
Read user inforead:user
export FORGEJO_TOKEN=your_token_here
# or place in .env at project root

Base URL Configuration

The skill defaults to Codeberg (https://codeberg.org/api/v1). For self-hosted Forgejo instances, set FORGEJO_BASE_URL:

export FORGEJO_BASE_URL=https://forgejo.example.com/api/v1

Base URL & Headers

Base URL : https://codeberg.org/api/v1 (default)
Auth     : Authorization: token <FORGEJO_TOKEN>
Content  : Content-Type: application/json

Commands

CLI Usage (from project root)

# List repos for a user
python .agents/skills/codeberg-api/scripts/forgejo_api.py repos --owner username

# Get file contents
python .agents/skills/codeberg-api/scripts/forgejo_api.py get-file \
  --owner username --repo myrepo \
  --path README.md --branch main

# Create an issue
python .agents/skills/codeberg-api/scripts/forgejo_api.py create-issue \
  --owner username --repo myrepo \
  --title "Bug: xyz" --body "Description"

# List open issues
python .agents/skills/codeberg-api/scripts/forgejo_api.py list-issues \
  --owner username --repo myrepo --state open

# Create or update a file
python .agents/skills/codeberg-api/scripts/forgejo_api.py put-file \
  --owner username --repo myrepo \
  --path docs/test.md --content "# Hello" \
  --message "docs: add test file" --branch main

Standalone Usage (from skill directory)

cd .agents/skills/codeberg-api
python scripts/forgejo_api.py --help

Common API Patterns

Read a file

curl -H "Authorization: token $FORGEJO_TOKEN" \
  "https://codeberg.org/api/v1/repos/{owner}/{repo}/contents/{filepath}?ref=main"

Response contains content (base64-encoded) and sha (needed for updates).

Create/update a file

curl -X PUT -H "Authorization: token $FORGEJO_TOKEN" \
  -H "Content-Type: application/json" \
  "https://codeberg.org/api/v1/repos/{owner}/{repo}/contents/{filepath}" \
  -d '{"message":"commit msg","content":"<base64>","sha":"<existing_sha_or_omit>"}'

Create an issue

curl -X POST -H "Authorization: token $FORGEJO_TOKEN" \
  -H "Content-Type: application/json" \
  "https://codeberg.org/api/v1/repos/{owner}/{repo}/issues" \
  -d '{"title":"Issue title","body":"Body text"}'

List branches

curl "https://codeberg.org/api/v1/repos/{owner}/{repo}/branches"

Error Handling

HTTP StatusMeaningAction
401UnauthorizedCheck FORGEJO_TOKEN
403ForbiddenCheck token scopes
404Not foundVerify owner/repo/path
409ConflictSHA mismatch on file update — fetch current SHA first
422Validation errorCheck request body fields
429Rate limitedWait and retry with backoff

Forgejo Actions (CI/CD)

Forgejo uses Forgejo Actions for CI/CD, fully compatible with GitHub Actions.

Workflow Location

Place workflows in .forgejo/workflows/ directory.

Example: Build Workflow

name: Build
version: "0.2.10"
on: [push, pull_request]
jobs:
  build:
    runs-on: docker
    steps:
      - uses: actions/checkout@v4
      - name: Run tests
        run: npm test
      - name: Build
        run: npm run build

Best Practices (2026)

  • Use matrix builds for parallel testing
  • Enable caching for dependencies
  • Use branch protection with required workflows
  • Leverage secrets for API tokens (FORGEJO_TOKEN)

Bundled Scripts

  • scripts/forgejo_api.py — Main CLI tool for Forgejo API operations

See Also

  • git-github-workflow — GitHub workflow and PR lifecycle
  • cicd-pipeline — CI/CD pipeline design

Rationalizations

RationalizationReality
"I'll hardcode the token in the script for convenience."Hardcoded tokens leak into version control and logs; always use environment variables or .env files.
"The API is the same as GitHub — I'll just use GitHub patterns."Forgejo/Codeberg API has different endpoints, auth scopes, and error codes; copying GitHub patterns silently fails.

Red Flags

  • Committing FORGEJO_TOKEN or any secrets to the repository
  • Skipping SHA fetch before file updates — causes 409 Conflict errors
  • Not checking token scopes when receiving 403 Forbidden responses

References

  • agents-docs/SKILLS.md - Skill authoring guide

Voice & Context

  • Default: professional + blog
  • Reference: voice-profiles skill for definitions and auto-detection.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.