当前位置: 首页 > Skill >

Forgejo Workflow

Forgejo Workflow

Forgejo Workflow

通过 fj 与 REST API 操作 Forgejo 的仓库、Issue、PR、Wiki、CI 与审查。

0.1.1 2026.11.17 978
获取Skill文件查看使用说明
作 者:顾言 许可证: 更新时间:2026.11.17
本文目录展开

Use the fj CLI and the Forgejo REST API to interact with Forgejo repositories, issues, pull requests, wiki pages, CI, and code review workflows.

Overview

Use this skill when:

  • Creating, listing, viewing, editing, or closing issues
  • Creating, checking out, merging, or reviewing pull requests
  • Managing repositories, forks, releases, labels, and milestones
  • Reading or writing wiki pages
  • Inspecting Forgejo Actions or CI status
  • Performing a structured code review on a Forgejo pull request

Do not use this skill when:

  • Working on local-only git operations such as commit, rebase, stash, push, or branch cleanup
  • Working with GitHub or GitLab instead of Forgejo
  • Performing Forgejo server administration that requires the forgejo server CLI

This skill targets one active Forgejo instance at a time.

Prefer fj for supported operations, use the REST API for feature gaps, and use local git only for review and diff workflows.

Prerequisites

Required binaries:

  • fj
  • curl
  • jq
  • git

Create an application token from:

$FORGEJO_URL/user/settings/applications

Request only the scopes needed for the task. Common patterns for this skill are:

  • read:repository or write:repository for repositories, pull requests, wiki, and releases
  • read:issue or write:issue for issues, labels, and milestones
  • read:notification or write:notification for notifications
  • read:organization or write:organization for org labels and teams
  • read:user or write:user only if user-level endpoints are needed

FORGEJO_URL must be the Forgejo base URL such as https://<your-forgejo-host>, not an /api/v1 endpoint.

FORGEJO_URL is the target Forgejo instance URL, not this skill repository URL.

Required environment

Variable Required Example Purpose
FORGEJO_URL Yes https://<your-forgejo-host> Base URL of the target Forgejo instance for this skill's REST and instance-selection workflow
FORGEJO_TOKEN Yes forgejo_pat_... Application token used by this skill's REST examples and recommended for fj setup

Authenticate fj with the same token when the target host is already inferable from the current repository context:

fj auth add-key <username>

If the current directory is not a Forgejo repository, or if you need to target a different instance explicitly, pass the host:

fj --host <forgejo-host> auth add-key <username>

The examples in this skill use the same token for REST API calls:

curl -sS 
  -H "Authorization: token $FORGEJO_TOKEN" 
  -H "Content-Type: application/json" 
  -H "Accept: application/json" 
  "$FORGEJO_URL/api/v1/..."

If FORGEJO_URL or FORGEJO_TOKEN is missing, stop and ask the user to provide the missing value instead of guessing.

REST-ready requires FORGEJO_URL and FORGEJO_TOKEN. fj-ready also requires fj auth for the target host.

Readiness check

Before doing Forgejo work, verify the required tools, env, and auth state.

Check binaries:

command -v fj curl jq git

Check required env vars:

test -n "$FORGEJO_URL" && test -n "$FORGEJO_TOKEN"

Check fj auth for the target host:

fj auth list

If any readiness check fails, stop and ask for the missing install, env value, or fj auth setup before proceeding.

Repository resolution

Resolve the target repository in this order:

  1. Explicit repository selection when the command supports it, such as --repo owner/repo
  2. The current repository context as resolved from the available git remotes
  3. Ask the user for owner/repo

Do not guess the repository from issue or pull request numbers alone.

For many issue and pull-request commands outside a local clone, explicit target selection is done with embedded forms such as owner/repo#42 rather than a separate --repo flag.

forgejo-cli does not hardcode origin here. In practice it can resolve from a sole remote, the current branch upstream remote, an explicit --remote, or a remote matching --host.

Use FORGEJO_URL as the source of truth for REST calls. Use fj --host when the current repository context does not already point at the target instance. fj itself does not read FORGEJO_URL.

Tool priority

  1. fj CLI for all supported Forgejo operations
  2. curl plus jq for Forgejo API gaps
  3. git for diff, log, merge-base, and blame during code review

Always prefer fj over raw API calls when both can do the job.

Unless noted otherwise, the examples below assume the host and repository are already resolved from repo context, --host, --repo, or an embedded target.

Repository operations

fj repo view owner/repo
fj repo create my-repo --private --description "..."
fj repo clone owner/repo
fj repo fork owner/repo
fj repo delete owner/repo
fj repo readme owner/repo
fj repo browse owner/repo
fj repo migrate <URL> name --service forgejo --include wiki,releases,issues --token

When using --include values such as wiki, releases, or issues, specify a non-git migration service such as forgejo. The --token flag is interactive and should not be documented as --token <value>.

There is no generic fj repo list command in forgejo-cli. To list repositories, use user or organization commands such as:

fj user repos
fj user repos username
fj org repo list my-org

When not inside the target repository, prefer explicit repository selection when the command supports it:

fj <command> --repo owner/repo

For issue and pull-request commands that do not support --repo, use an embedded target such as owner/repo#42.

Issues

fj issue search
fj issue create "Bug: ..." --body "..."
fj issue view 42
fj issue edit 42 title "New title"
fj issue comment 42 "My comment"
fj issue close 42

If the repository uses issue templates, issue creation may require --template or --no-template.

Pull requests

fj pr search
fj pr create "feat: ..." --body "..."
fj pr create --agit "..."
fj pr view 55
fj pr checkout 55
fj pr status 55
fj pr merge 55 --method rebase --delete
fj pr close 55
fj pr comment 55 "LGTM"
fj pr edit 55 labels --add bug --rm wip

Some PR commands can infer the PR number from the current branch, but fj pr checkout still requires an explicit PR number.

fj pr create --agit is a specialized local-git workflow that pushes HEAD:refs/for/<base> and may prompt to write git config.

Before checking out a pull request locally, inspect the current worktree:

git status --porcelain

If the worktree is dirty, warn the user before running fj pr checkout.

fj pr checkout will fail if there are uncommitted changes.

Releases

fj release list
fj release create 0.1.0 --tag 0.1.0

Organizations and teams

fj org list
fj org view my-org
fj org label list my-org
fj org label add my-org "bug" "#d73a4a"
fj org team list my-org
fj org team member add my-org devs username

Wiki

Read wiki pages with fj:

fj wiki --repo owner/repo view "Page Name"

List wiki pages with fj:

fj wiki --repo owner/repo contents

Use the REST API for wiki writes, updates, and deletes. See references/api-cheatsheet.md.

Labels and milestones

Use fj for organization labels. Repository labels are available under fj repo labels on current forgejo-cli source builds, but not in packaged v0.4.0 and v0.4.1 releases.

Use the REST API for milestones, and as the fallback whenever the local fj build does not expose the needed label operation. See references/api-cheatsheet.md.

CI and Forgejo Actions

Use fj for the quick status path:

fj --repo owner/repo actions tasks
fj pr status 55

Use the REST API when detailed run information is needed. See references/ci-actions.md.

Code review

When asked to review a pull request, follow references/code-review.md.

Short version:

  1. Inspect worktree state before checkout.
  2. Check out the pull request with fj pr checkout <number>.
  3. Determine the actual base branch from the pull request metadata.
  4. Compute the merge base against that base branch.
  5. Review the diff using the criteria in references/code-review.md.
  6. Post a comment with findings.
  7. Approve only if the user explicitly asks for approval.
  8. Merge only if the user explicitly asks for merge.

Keep approval and merge as separate actions.

Pagination

Many Forgejo API endpoints support ?page=<n>&limit=<n>.

When fetching large result sets, keep paging until the response shape or available pagination metadata indicates there are no more results.

Troubleshooting

Symptom Likely cause Action
FORGEJO_URL is not set Required instance URL missing Export FORGEJO_URL before running fj or REST workflows
FORGEJO_TOKEN is not set Required application token missing Create a token in Forgejo and export FORGEJO_TOKEN
fj: command not found forgejo-cli is not installed Install fj with the supported metadata installer or another package source
curl: command not found or jq: command not found REST fallback tools are missing Install the missing system tools before using REST workflows
git: command not found Local review and diff workflows are unavailable Install git before using review flows
fj auth add-key fails fj needs both a username and a resolvable target host Run fj auth add-key <username> in a configured repo or fj --host <host> auth add-key <username>
fj is not authenticated for the target host REST may work, but CLI commands will fail Run fj auth list to inspect configured hosts, then add the key for the target host
repo not found Wrong owner or repo, wrong instance, or missing access Verify owner/repo, the target instance, and token permissions
cannot infer repository No local git remote and no explicit repo selection Ask the user for owner/repo, and include --host or a host-qualified target when needed
HTTP 401 or HTTP 403 Invalid token or insufficient scope Verify token validity, scopes, and repo permissions
HTTP 404 from the API Wrong path or endpoint unsupported on this Forgejo version Recheck the URL and confirm support in $FORGEJO_URL/api/swagger
fj lacks the requested operation CLI gap compared to Forgejo API Fall back to curl and jq using the REST API

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,040
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,033
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,021
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,021
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,019
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,016
Skill 文件
  • SKILL.md
    • Overview
    • Prerequisites
    • Required environment
    • Readiness check
    • Repository resolution
    • Tool priority
    • Repository operations
    • Issues
    • Pull requests
    • Releases
    • Organizations and teams
    • Wiki
    • Labels and milestones
    • CI and Forgejo Actions
    • Code review
    • Pagination
    • Troubleshooting
  • 项目或源文件

相关 Skill

更多
service-qa-coach service-qa-coach Review support quality for chat, email, phone, social DM, or marketplace service teams. Use when a team needs a QA scorecard, failure-mode analysis, coaching plan, calibration checklist, or service-improvement brief without live ticketing, CRM, or contact-center system access.
高中数学作业批改助手 高中数学作业批改助手 >图片识别 直接读取学生手写作答照片,识别公式、符号、步骤 🧮 自动推导 根据题目自动生成参考答案和评分细则,无需教师预设 📊 逐步给分 每个关键步骤独立评分,体现过程分 📝 结构化报告 输出含识别内容、参考答案、逐步评分、改进建议的完整报告 🗂 批量批改 支持一次性批改多道题,最终汇总得分表
Vibration Analysis Vibration Analysis 分析来自CMS趋势、RMS/峰值、频谱及SCADA报警的风机传动链(主轴、齿轮箱、发电机)振动数据。
Traditional Bone Tool Making Basics Traditional Bone Tool Making Basics Use when you need custom, durable, repairable tools like awls, needles, scrapers, harpoons, or fishing hooks made from local animal bones or antlers and comm...
音频混音工具 音频混音工具 名称:Sound Mixing Tool(标识 sound-mixing-tool) 短简介(≤60字):音乐/音效响度精确对齐 + 融合混音工作流:用 ffmpeg 两段式 loudnorm 把多组素材 LUFS 偏差压到 <0.10,再最小干预融合、导出可进引擎的独立分轨。 标签/关键词:音频混音 响度匹配 LUFS ffmpeg 游戏音频 音效设计 Wwise FMOD 分轨导出 后期处理 触发词:混音 · 响度匹配 · LUFS 对齐 · MIX 版本 · 音乐音效分轨 · 融合 · 不打架 · 不能盖住 适用场景 :游戏音频集成、影视短视频配乐、播客后期