2026-04-26 08:16:52 -06:00
# fj - Forgejo/Gitea CLI Tool
2025-12-08 09:49:07 +01:00
2025-12-13 23:04:15 +01:00
[](https://golang.org)
[](LICENSE)
2026-04-26 08:16:52 -06:00
`fj` is a command-line tool for working with Forgejo and Gitea instances. It brings pull requests, issues, and other forge concepts to the terminal, similar to what `gh` does for GitHub. This fork adds agentic dev features — raw API access, PR review workflows, structured error output, and machine-readable I/O for AI coding agents.
feat: v0.3.0a — add api command, pr diff/comment/review, structured errors
New commands:
- fgj api: raw REST API passthrough with field inference and path interpolation
- fgj pr diff: view PR diffs with color, --name-only, --stat
- fgj pr comment: add comments to pull requests
- fgj pr review: approve, request changes, or comment on PRs
Agentic enhancements:
- --json-errors flag for structured JSON error output on stderr
- APIError type wrapping HTTP status codes for machine consumption
- Error codes: auth_required, not_found, api_error, invalid_input, etc.
Docs updated for forgejo.zerova.net/sid/fgj-sid fork.
2026-03-21 21:50:24 -06:00
2026-04-26 08:16:52 -06:00
> Forked from [codeberg.org/romaintb/fj](https://codeberg.org/romaintb/fj) and hosted at [forgejo.zerova.net/public/fj](https://forgejo.zerova.net/public/fj).
2025-12-08 09:49:07 +01:00
## Features
feat: v0.3.0a — add api command, pr diff/comment/review, structured errors
New commands:
- fgj api: raw REST API passthrough with field inference and path interpolation
- fgj pr diff: view PR diffs with color, --name-only, --stat
- fgj pr comment: add comments to pull requests
- fgj pr review: approve, request changes, or comment on PRs
Agentic enhancements:
- --json-errors flag for structured JSON error output on stderr
- APIError type wrapping HTTP status codes for machine consumption
- Error codes: auth_required, not_found, api_error, invalid_input, etc.
Docs updated for forgejo.zerova.net/sid/fgj-sid fork.
2026-03-21 21:50:24 -06:00
- Multi-instance support (works with any Forgejo or Gitea instance)
2026-03-21 21:50:24 -06:00
- Pull request management (create, list, view, merge, diff, comment, review)
2026-03-13 18:20:21 +01:00
- Issue tracking (create, list, view, comment, close, labels)
2026-03-21 21:50:24 -06:00
- Repository operations (view, list, create, edit, clone, fork)
2026-03-21 21:50:24 -06:00
- Label management (list, create, edit, delete)
- Milestone management (list, view, create, edit, delete)
- Wiki page management (list, view, create, edit, delete)
- Issue dependencies (`--add-dependency` , `--remove-dependency` )
2026-03-13 18:20:21 +01:00
- Forgejo Actions (workflow runs, watch/rerun/cancel, enable/disable, secrets, variables)
- Releases (create, upload, delete)
2026-04-26 08:16:52 -06:00
- Raw API access (`fj api` ) for arbitrary REST calls
2026-03-13 18:20:21 +01:00
- Shell completions (bash, zsh, fish, PowerShell) and man pages
- JSON output (`--json` ) for all list/view commands
2026-03-21 21:50:24 -06:00
- Structured JSON error output (`--json-errors` ) for machine consumption
2026-03-13 18:20:21 +01:00
- Automatic repository and hostname detection from git context
2025-12-08 09:49:07 +01:00
- Secure authentication with personal access tokens
2026-03-13 18:20:21 +01:00
- XDG Base Directory compliant config location
2025-12-08 09:49:07 +01:00
- AI coding agent friendly
## Installation
2025-12-17 11:36:21 +01:00
### macOS (Homebrew)
```bash
2026-04-26 08:34:10 -06:00
brew tap public/sid git@forgejo .zerova.net:public/homebrew-sid.git
2026-04-26 08:16:52 -06:00
brew install fj
2025-12-08 09:49:07 +01:00
```
### Using Go Install
```bash
2026-04-26 08:16:52 -06:00
go install forgejo.zerova.net/public/fj@latest
2025-12-08 09:49:07 +01:00
```
feat: v0.3.0a — add api command, pr diff/comment/review, structured errors
New commands:
- fgj api: raw REST API passthrough with field inference and path interpolation
- fgj pr diff: view PR diffs with color, --name-only, --stat
- fgj pr comment: add comments to pull requests
- fgj pr review: approve, request changes, or comment on PRs
Agentic enhancements:
- --json-errors flag for structured JSON error output on stderr
- APIError type wrapping HTTP status codes for machine consumption
- Error codes: auth_required, not_found, api_error, invalid_input, etc.
Docs updated for forgejo.zerova.net/sid/fgj-sid fork.
2026-03-21 21:50:24 -06:00
### From Source
2025-12-17 11:36:21 +01:00
feat: v0.3.0a — add api command, pr diff/comment/review, structured errors
New commands:
- fgj api: raw REST API passthrough with field inference and path interpolation
- fgj pr diff: view PR diffs with color, --name-only, --stat
- fgj pr comment: add comments to pull requests
- fgj pr review: approve, request changes, or comment on PRs
Agentic enhancements:
- --json-errors flag for structured JSON error output on stderr
- APIError type wrapping HTTP status codes for machine consumption
- Error codes: auth_required, not_found, api_error, invalid_input, etc.
Docs updated for forgejo.zerova.net/sid/fgj-sid fork.
2026-03-21 21:50:24 -06:00
```bash
2026-04-26 08:16:52 -06:00
git clone https://forgejo.zerova.net/public/fj.git
cd fj
go build -o fj .
feat: v0.3.0a — add api command, pr diff/comment/review, structured errors
New commands:
- fgj api: raw REST API passthrough with field inference and path interpolation
- fgj pr diff: view PR diffs with color, --name-only, --stat
- fgj pr comment: add comments to pull requests
- fgj pr review: approve, request changes, or comment on PRs
Agentic enhancements:
- --json-errors flag for structured JSON error output on stderr
- APIError type wrapping HTTP status codes for machine consumption
- Error codes: auth_required, not_found, api_error, invalid_input, etc.
Docs updated for forgejo.zerova.net/sid/fgj-sid fork.
2026-03-21 21:50:24 -06:00
```
2025-12-17 11:36:21 +01:00
2025-12-08 09:49:07 +01:00
## Quick Start
### 1. Authenticate
feat: v0.3.0a — add api command, pr diff/comment/review, structured errors
New commands:
- fgj api: raw REST API passthrough with field inference and path interpolation
- fgj pr diff: view PR diffs with color, --name-only, --stat
- fgj pr comment: add comments to pull requests
- fgj pr review: approve, request changes, or comment on PRs
Agentic enhancements:
- --json-errors flag for structured JSON error output on stderr
- APIError type wrapping HTTP status codes for machine consumption
- Error codes: auth_required, not_found, api_error, invalid_input, etc.
Docs updated for forgejo.zerova.net/sid/fgj-sid fork.
2026-03-21 21:50:24 -06:00
First, authenticate with your Forgejo or Gitea instance:
2025-12-08 09:49:07 +01:00
```bash
2026-04-26 08:16:52 -06:00
fj auth login
2025-12-08 09:49:07 +01:00
```
You'll be prompted for:
feat: v0.3.0a — add api command, pr diff/comment/review, structured errors
New commands:
- fgj api: raw REST API passthrough with field inference and path interpolation
- fgj pr diff: view PR diffs with color, --name-only, --stat
- fgj pr comment: add comments to pull requests
- fgj pr review: approve, request changes, or comment on PRs
Agentic enhancements:
- --json-errors flag for structured JSON error output on stderr
- APIError type wrapping HTTP status codes for machine consumption
- Error codes: auth_required, not_found, api_error, invalid_input, etc.
Docs updated for forgejo.zerova.net/sid/fgj-sid fork.
2026-03-21 21:50:24 -06:00
- Instance hostname (default: codeberg.org)
2025-12-08 09:49:07 +01:00
- Personal access token
To create a personal access token:
feat: v0.3.0a — add api command, pr diff/comment/review, structured errors
New commands:
- fgj api: raw REST API passthrough with field inference and path interpolation
- fgj pr diff: view PR diffs with color, --name-only, --stat
- fgj pr comment: add comments to pull requests
- fgj pr review: approve, request changes, or comment on PRs
Agentic enhancements:
- --json-errors flag for structured JSON error output on stderr
- APIError type wrapping HTTP status codes for machine consumption
- Error codes: auth_required, not_found, api_error, invalid_input, etc.
Docs updated for forgejo.zerova.net/sid/fgj-sid fork.
2026-03-21 21:50:24 -06:00
1. Go to your instance (e.g., https://forgejo.zerova.net)
2025-12-08 09:49:07 +01:00
2. Navigate to Settings > Applications > Generate New Token
3. Give it appropriate permissions (repo, issue, etc.)
4. Copy the token and paste it when prompted
### 2. Check Authentication Status
```bash
2026-04-26 08:16:52 -06:00
fj auth status
2025-12-08 09:49:07 +01:00
```
2026-03-13 18:20:21 +01:00
### Auth Helpers
```bash
# Print the stored token for the current host
2026-04-26 08:16:52 -06:00
fj auth token
2026-03-13 18:20:21 +01:00
# Remove authentication for a host
2026-04-26 08:16:52 -06:00
fj auth logout
2026-03-13 18:20:21 +01:00
```
2025-12-08 09:49:07 +01:00
## Usage
2025-12-08 10:24:49 +01:00
### Repository Detection
2026-04-26 08:16:52 -06:00
`fj` automatically detects the repository from your git context, similar to `gh` :
2025-12-08 10:24:49 +01:00
```bash
# When inside a git repository, no -R flag needed!
cd /path/to/your/repo
2026-04-26 08:16:52 -06:00
fj pr list # Automatically uses current repo
fj issue list # Automatically uses current repo
fj pr view 123 # Automatically uses current repo
2025-12-08 10:24:49 +01:00
# Or explicitly specify a repository with -R
2026-04-26 08:16:52 -06:00
fj pr list -R owner/repo
2025-12-08 10:24:49 +01:00
```
feat: v0.3.0a — add api command, pr diff/comment/review, structured errors
New commands:
- fgj api: raw REST API passthrough with field inference and path interpolation
- fgj pr diff: view PR diffs with color, --name-only, --stat
- fgj pr comment: add comments to pull requests
- fgj pr review: approve, request changes, or comment on PRs
Agentic enhancements:
- --json-errors flag for structured JSON error output on stderr
- APIError type wrapping HTTP status codes for machine consumption
- Error codes: auth_required, not_found, api_error, invalid_input, etc.
Docs updated for forgejo.zerova.net/sid/fgj-sid fork.
2026-03-21 21:50:24 -06:00
The tool reads `.git/config` to find the origin remote and extract both the owner/repo information and the instance hostname. If you're not in a git repository, you'll need to use the `-R` flag.
2025-12-08 10:24:49 +01:00
2025-12-08 09:49:07 +01:00
### Pull Requests
```bash
2026-01-05 12:47:28 +01:00
# List pull requests (auto-detects repo and hostname from git)
2026-04-26 08:16:52 -06:00
fj pr list
2025-12-08 10:24:49 +01:00
# Or specify explicitly
2026-04-26 08:16:52 -06:00
fj pr list -R owner/repo
2025-12-08 09:49:07 +01:00
2025-12-08 10:24:49 +01:00
# Filter by state
2026-04-26 08:16:52 -06:00
fj pr list --state closed
2025-12-08 10:24:49 +01:00
2025-12-08 09:49:07 +01:00
# View a specific pull request
2026-04-26 08:16:52 -06:00
fj pr view 123
2025-12-08 09:49:07 +01:00
# Create a pull request
2026-04-26 08:16:52 -06:00
fj pr create -t "PR Title" -b "PR Description" -H feature-branch -B main
2025-12-08 09:49:07 +01:00
# Merge a pull request
2026-04-26 08:16:52 -06:00
fj pr merge 123 --merge-method squash
2026-03-21 21:50:24 -06:00
# View PR diff
2026-04-26 08:16:52 -06:00
fj pr diff 123
2026-03-21 21:50:24 -06:00
# View diff with color
2026-04-26 08:16:52 -06:00
fj pr diff 123 --color always
2026-03-21 21:50:24 -06:00
# Show only changed file names
2026-04-26 08:16:52 -06:00
fj pr diff 123 --name-only
2026-03-21 21:50:24 -06:00
# Show diffstat summary
2026-04-26 08:16:52 -06:00
fj pr diff 123 --stat
2026-03-21 21:50:24 -06:00
# Comment on a pull request
2026-04-26 08:16:52 -06:00
fj pr comment 123 -b "Looks good, minor nit on line 42"
2026-03-21 21:50:24 -06:00
# Comment from a file
2026-04-26 08:16:52 -06:00
fj pr comment 123 --body-file review-notes.md
2026-03-21 21:50:24 -06:00
# Approve a pull request
2026-04-26 08:16:52 -06:00
fj pr review 123 --approve -b "LGTM"
2026-03-21 21:50:24 -06:00
# Request changes
2026-04-26 08:16:52 -06:00
fj pr review 123 --request-changes -b "Please fix the error handling"
2026-03-21 21:50:24 -06:00
# Submit a review comment (neither approve nor request changes)
2026-04-26 08:16:52 -06:00
fj pr review 123 --comment -b "Some observations"
2025-12-08 09:49:07 +01:00
```
### Issues
```bash
2026-01-05 12:47:28 +01:00
# List issues (auto-detects repo and hostname from git)
2026-04-26 08:16:52 -06:00
fj issue list
2025-12-08 10:24:49 +01:00
# Or specify explicitly
2026-04-26 08:16:52 -06:00
fj issue list -R owner/repo
2025-12-08 09:49:07 +01:00
2025-12-08 10:24:49 +01:00
# Filter by state
2026-04-26 08:16:52 -06:00
fj issue list --state all
2025-12-08 10:24:49 +01:00
2025-12-08 09:49:07 +01:00
# View an issue
2026-04-26 08:16:52 -06:00
fj issue view 456
2025-12-08 09:49:07 +01:00
# Create an issue
2026-04-26 08:16:52 -06:00
fj issue create -t "Issue Title" -b "Issue Description"
2025-12-08 09:49:07 +01:00
2026-03-13 18:20:21 +01:00
# Create an issue with labels
2026-04-26 08:16:52 -06:00
fj issue create -t "Issue Title" -b "Issue Description" -l bug -l enhancement
2026-03-13 18:20:21 +01:00
2025-12-08 09:49:07 +01:00
# Comment on an issue
2026-04-26 08:16:52 -06:00
fj issue comment 456 -b "My comment"
2025-12-08 09:49:07 +01:00
# Close an issue
2026-04-26 08:16:52 -06:00
fj issue close 456
2026-01-16 10:03:49 +01:00
# Close an issue with a comment
2026-04-26 08:16:52 -06:00
fj issue close 456 -c "Fixed in v2.0"
2026-03-13 18:20:21 +01:00
# Edit an issue (title, body, state, labels)
2026-04-26 08:16:52 -06:00
fj issue edit 456 -t "New Title"
fj issue edit 456 --add-label priority --remove-label bug
2026-03-21 21:50:24 -06:00
# Manage issue dependencies
2026-04-26 08:16:52 -06:00
fj issue edit 456 --add-dependency 123
fj issue edit 456 --remove-dependency 123
2026-03-21 21:50:24 -06:00
```
### Labels
```bash
# List labels
2026-04-26 08:16:52 -06:00
fj label list
2026-03-21 21:50:24 -06:00
# Create a label
2026-04-26 08:16:52 -06:00
fj label create bug --color ff0000 -d "Something isn't working"
2026-03-21 21:50:24 -06:00
# Edit a label
2026-04-26 08:16:52 -06:00
fj label edit bug --name bugfix --color ee0000
2026-03-21 21:50:24 -06:00
# Delete a label
2026-04-26 08:16:52 -06:00
fj label delete bug
2026-03-21 21:50:24 -06:00
```
### Milestones
```bash
# List milestones
2026-04-26 08:16:52 -06:00
fj milestone list
fj milestone list --state all
2026-03-21 21:50:24 -06:00
# View a milestone
2026-04-26 08:16:52 -06:00
fj milestone view "v1.0"
2026-03-21 21:50:24 -06:00
# Create a milestone with due date
2026-04-26 08:16:52 -06:00
fj milestone create "v2.0" -d "Next major release" --due 2026-06-01
2026-03-21 21:50:24 -06:00
# Edit a milestone
2026-04-26 08:16:52 -06:00
fj milestone edit "v2.0" --title "v2.0-rc1" --state closed
2026-03-21 21:50:24 -06:00
# Delete a milestone
2026-04-26 08:16:52 -06:00
fj milestone delete "v2.0"
2026-03-21 21:50:24 -06:00
```
### Wiki
```bash
# List wiki pages
2026-04-26 08:16:52 -06:00
fj wiki list
2026-03-21 21:50:24 -06:00
# View a wiki page
2026-04-26 08:16:52 -06:00
fj wiki view "Home"
2026-03-21 21:50:24 -06:00
# Create a wiki page
2026-04-26 08:16:52 -06:00
fj wiki create "Setup Guide" -b "# Setup\n\nFollow these steps..."
2026-03-21 21:50:24 -06:00
# Create from file
2026-04-26 08:16:52 -06:00
fj wiki create "API Docs" --body-file docs/api.md
2026-03-21 21:50:24 -06:00
# Edit a wiki page
2026-04-26 08:16:52 -06:00
fj wiki edit "Home" -b "Updated content"
2026-03-21 21:50:24 -06:00
# Delete a wiki page
2026-04-26 08:16:52 -06:00
fj wiki delete "Old Page"
2025-12-08 09:49:07 +01:00
```
### Repositories
```bash
# View repository details
2026-04-26 08:16:52 -06:00
fj repo view owner/repo
2025-12-08 09:49:07 +01:00
# List your repositories
2026-04-26 08:16:52 -06:00
fj repo list
2025-12-08 09:49:07 +01:00
2026-03-13 18:20:21 +01:00
# Create a repository
2026-04-26 08:16:52 -06:00
fj repo create my-repo
fj repo create my-repo -d "My project" --private --add-readme -g Go -l MIT
2026-03-13 18:20:21 +01:00
2025-12-08 09:49:07 +01:00
# Clone a repository
2026-04-26 08:16:52 -06:00
fj repo clone owner/repo
2025-12-08 09:49:07 +01:00
# Clone via SSH
2026-04-26 08:16:52 -06:00
fj repo clone owner/repo -p ssh
2025-12-08 09:49:07 +01:00
# Fork a repository
2026-04-26 08:16:52 -06:00
fj repo fork owner/repo
2026-03-21 21:50:24 -06:00
# Edit repository settings
2026-04-26 08:16:52 -06:00
fj repo edit owner/repo --public
fj repo edit owner/repo --private
fj repo edit owner/repo -d "New description" --homepage https://example.com
fj repo edit --default-branch develop
fj repo edit owner/repo --name new-name
feat: v0.3.0d — add PR checks, iostreams, aliases, and broad enhancements
Add PR checks command, iostreams/text packages for colored table output,
top-level run/workflow aliases matching gh CLI structure. Enhance actions,
issues, PRs, releases, repos, labels, milestones, and wiki commands with
improved flags, JSON output, and error handling.
2026-03-23 11:42:44 -06:00
# Rename a repository (shorthand)
2026-04-26 08:16:52 -06:00
fj repo rename new-name
fj repo rename new-name -R owner/old-name
2025-12-08 09:49:07 +01:00
```
2026-01-05 12:57:37 +01:00
### Releases
```bash
# List releases
2026-04-26 08:16:52 -06:00
fj release list
2026-01-05 12:57:37 +01:00
# View a release (or use "latest")
2026-04-26 08:16:52 -06:00
fj release view v1.2.3
2026-01-05 12:57:37 +01:00
# Create a release with notes and optional assets
2026-04-26 08:16:52 -06:00
fj release create v1.2.3 -t "v1.2.3" -n "Release notes" ./dist/app.tar.gz
2026-01-05 12:57:37 +01:00
# Upload assets to an existing release
2026-04-26 08:16:52 -06:00
fj release upload v1.2.3 ./dist/app.tar.gz --clobber
2026-01-05 12:57:37 +01:00
# Delete a release (keeps the Git tag)
2026-04-26 08:16:52 -06:00
fj release delete v1.2.3
2026-01-05 12:57:37 +01:00
```
2025-12-16 12:57:36 +01:00
### Forgejo Actions
```bash
2026-01-16 10:51:37 +01:00
# List workflows
2026-04-26 08:16:52 -06:00
fj actions workflow list
2026-01-16 10:51:37 +01:00
# View a workflow
2026-04-26 08:16:52 -06:00
fj actions workflow view ci.yml
2026-01-16 10:51:37 +01:00
# Run a workflow (trigger workflow_dispatch)
2026-04-26 08:16:52 -06:00
fj actions workflow run deploy.yml
2026-01-16 10:51:37 +01:00
# Run a workflow with inputs
2026-04-26 08:16:52 -06:00
fj actions workflow run deploy.yml -f environment=production -f version=1.2.3
2026-01-16 10:51:37 +01:00
# Run a workflow on a specific branch
2026-04-26 08:16:52 -06:00
fj actions workflow run deploy.yml -r feature-branch
2026-01-16 10:51:37 +01:00
2026-03-13 18:20:21 +01:00
# Enable or disable a workflow
2026-04-26 08:16:52 -06:00
fj actions workflow enable ci.yml
fj actions workflow disable ci.yml
2026-03-13 18:20:21 +01:00
2025-12-16 12:57:36 +01:00
# List workflow runs
2026-04-26 08:16:52 -06:00
fj actions run list
2025-12-16 12:57:36 +01:00
# View a specific run
2026-04-26 08:16:52 -06:00
fj actions run view 123
2025-12-16 12:57:36 +01:00
# View run with job details
2026-04-26 08:16:52 -06:00
fj actions run view 123 --verbose
2025-12-16 12:57:36 +01:00
# View run logs
2026-04-26 08:16:52 -06:00
fj actions run view 123 --log
2025-12-16 12:57:36 +01:00
# View specific job logs
2026-04-26 08:16:52 -06:00
fj actions run view 123 --job 456 --log
2025-12-16 12:57:36 +01:00
2026-03-13 18:20:21 +01:00
# Watch a run until completion
2026-04-26 08:16:52 -06:00
fj actions run watch 123
2026-03-13 18:20:21 +01:00
# Rerun a workflow run
2026-04-26 08:16:52 -06:00
fj actions run rerun 123
2026-03-13 18:20:21 +01:00
# Cancel a running workflow
2026-04-26 08:16:52 -06:00
fj actions run cancel 123
2026-03-13 18:20:21 +01:00
2025-12-16 12:57:36 +01:00
# List secrets
2026-04-26 08:16:52 -06:00
fj actions secret list
2025-12-16 12:57:36 +01:00
# Create a secret
2026-04-26 08:16:52 -06:00
fj actions secret create MY_SECRET
2025-12-16 12:57:36 +01:00
# Delete a secret
2026-04-26 08:16:52 -06:00
fj actions secret delete MY_SECRET
2025-12-16 12:57:36 +01:00
# List variables
2026-04-26 08:16:52 -06:00
fj actions variable list
2025-12-16 12:57:36 +01:00
# Get a variable
2026-04-26 08:16:52 -06:00
fj actions variable get MY_VAR
2025-12-16 12:57:36 +01:00
# Create a variable
2026-04-26 08:16:52 -06:00
fj actions variable create MY_VAR "value"
2025-12-16 12:57:36 +01:00
# Update a variable
2026-04-26 08:16:52 -06:00
fj actions variable update MY_VAR "new value"
2025-12-16 12:57:36 +01:00
# Delete a variable
2026-04-26 08:16:52 -06:00
fj actions variable delete MY_VAR
2025-12-16 12:57:36 +01:00
```
2026-03-21 21:50:24 -06:00
### Raw API Access
```bash
# GET request (auto-detects owner/repo from git context)
2026-04-26 08:16:52 -06:00
fj api /repos/{owner}/{repo}/pulls
2026-03-21 21:50:24 -06:00
# POST with fields
2026-04-26 08:16:52 -06:00
fj api /repos/{owner}/{repo}/issues -X POST -f title="Bug report" -f body="Description"
2026-03-21 21:50:24 -06:00
# Explicit method and hostname
2026-04-26 08:16:52 -06:00
fj api /repos/myorg/myrepo/labels --hostname my-forgejo.example.com
2026-03-21 21:50:24 -06:00
# Read request body from file
2026-04-26 08:16:52 -06:00
fj api /repos/{owner}/{repo}/issues -X POST --input issue.json
2026-03-21 21:50:24 -06:00
# Read from stdin
2026-04-26 08:16:52 -06:00
echo '{"title":"test"}' | fj api /repos/{owner}/{repo}/issues -X POST --input -
2026-03-21 21:50:24 -06:00
# Include response headers
2026-04-26 08:16:52 -06:00
fj api /repos/{owner}/{repo} -i
2026-03-21 21:50:24 -06:00
# Suppress output (useful for DELETE)
2026-04-26 08:16:52 -06:00
fj api /repos/{owner}/{repo}/issues/123 -X DELETE --silent
2026-03-21 21:50:24 -06:00
```
2026-03-13 18:20:21 +01:00
## Shell Completions and Man Pages
```bash
# Generate shell completion scripts
2026-04-26 08:16:52 -06:00
fj completion bash > /etc/bash_completion.d/fj
fj completion zsh > "${fpath[1]}/_fj"
fj completion fish > ~/.config/fish/completions/fj.fish
2026-03-13 18:20:21 +01:00
# Generate man pages to a directory
2026-04-26 08:16:52 -06:00
fj manpages --dir ~/.local/share/man/man1
2026-03-13 18:20:21 +01:00
```
## JSON Output
Most list and view commands support `--json` for machine-readable output:
```bash
2026-04-26 08:16:52 -06:00
fj pr list --json
fj issue view 456 --json
fj release list --json
fj actions run list --json
fj actions workflow view ci.yml --json
2026-03-21 21:50:24 -06:00
# Get JSON output from PR comment/review
2026-04-26 08:16:52 -06:00
fj pr comment 123 -b "LGTM" --json
fj pr review 123 --approve -b "Ship it" --json
2026-03-21 21:50:24 -06:00
```
### Structured Error Output
For machine consumption (ideal for AI agents and scripts), use `--json-errors` to get structured JSON errors on stderr:
```bash
# Errors are written to stderr as JSON
2026-04-26 08:16:52 -06:00
fj pr view 9999 --json-errors
2026-03-21 21:50:24 -06:00
# stderr: {"error":{"code":"not_found","message":"...","status":404}}
# Combine with --json for fully machine-readable I/O
2026-04-26 08:16:52 -06:00
fj pr list --json --json-errors
2026-03-13 18:20:21 +01:00
```
2025-12-08 09:49:07 +01:00
## Configuration
2026-04-26 08:16:52 -06:00
Configuration is stored in `~/.config/fj/config.yaml` :
2025-12-08 09:49:07 +01:00
```yaml
hosts:
feat: v0.3.0a — add api command, pr diff/comment/review, structured errors
New commands:
- fgj api: raw REST API passthrough with field inference and path interpolation
- fgj pr diff: view PR diffs with color, --name-only, --stat
- fgj pr comment: add comments to pull requests
- fgj pr review: approve, request changes, or comment on PRs
Agentic enhancements:
- --json-errors flag for structured JSON error output on stderr
- APIError type wrapping HTTP status codes for machine consumption
- Error codes: auth_required, not_found, api_error, invalid_input, etc.
Docs updated for forgejo.zerova.net/sid/fgj-sid fork.
2026-03-21 21:50:24 -06:00
forgejo.zerova.net:
hostname: forgejo.zerova.net
2025-12-08 09:49:07 +01:00
token: your_token_here
user: your_username
feat: v0.3.0a — add api command, pr diff/comment/review, structured errors
New commands:
- fgj api: raw REST API passthrough with field inference and path interpolation
- fgj pr diff: view PR diffs with color, --name-only, --stat
- fgj pr comment: add comments to pull requests
- fgj pr review: approve, request changes, or comment on PRs
Agentic enhancements:
- --json-errors flag for structured JSON error output on stderr
- APIError type wrapping HTTP status codes for machine consumption
- Error codes: auth_required, not_found, api_error, invalid_input, etc.
Docs updated for forgejo.zerova.net/sid/fgj-sid fork.
2026-03-21 21:50:24 -06:00
git_protocol: ssh
2026-03-23 13:11:43 -06:00
match_dirs:
- / # catch-all: use this host when no git remote is detected
feat: v0.3.0a — add api command, pr diff/comment/review, structured errors
New commands:
- fgj api: raw REST API passthrough with field inference and path interpolation
- fgj pr diff: view PR diffs with color, --name-only, --stat
- fgj pr comment: add comments to pull requests
- fgj pr review: approve, request changes, or comment on PRs
Agentic enhancements:
- --json-errors flag for structured JSON error output on stderr
- APIError type wrapping HTTP status codes for machine consumption
- Error codes: auth_required, not_found, api_error, invalid_input, etc.
Docs updated for forgejo.zerova.net/sid/fgj-sid fork.
2026-03-21 21:50:24 -06:00
codeberg.org:
hostname: codeberg.org
2025-12-08 09:49:07 +01:00
token: another_token
user: another_username
feat: v0.3.0a — add api command, pr diff/comment/review, structured errors
New commands:
- fgj api: raw REST API passthrough with field inference and path interpolation
- fgj pr diff: view PR diffs with color, --name-only, --stat
- fgj pr comment: add comments to pull requests
- fgj pr review: approve, request changes, or comment on PRs
Agentic enhancements:
- --json-errors flag for structured JSON error output on stderr
- APIError type wrapping HTTP status codes for machine consumption
- Error codes: auth_required, not_found, api_error, invalid_input, etc.
Docs updated for forgejo.zerova.net/sid/fgj-sid fork.
2026-03-21 21:50:24 -06:00
git_protocol: https
2026-03-23 13:11:43 -06:00
match_dirs:
- ~/repos/codeberg # use this host for repos under this directory
2025-12-08 09:49:07 +01:00
```
2026-03-23 13:11:43 -06:00
### Directory-Based Host Selection (`match_dirs`)
2026-04-26 08:16:52 -06:00
When you work with multiple Forgejo/Gitea instances, `fj` can automatically select the right host based on your current working directory — no `--hostname` flag needed.
2026-03-23 13:11:43 -06:00
2026-04-26 08:16:52 -06:00
Each host entry supports a `match_dirs` list of directory paths. When `fj` can't determine the host from a git remote, it finds the host whose `match_dirs` entry is the **longest prefix match** for your current directory.
2026-03-23 13:11:43 -06:00
```yaml
hosts:
work.example.com:
# ...
match_dirs:
- ~/work # any repo under ~/work uses this host
personal.example.com:
# ...
match_dirs:
- ~/personal
- ~/side-projects # multiple directories can map to the same host
codeberg.org:
# ...
match_dirs:
- / # catch-all fallback (shortest prefix, lowest priority)
```
- Paths support `~` expansion and symlink resolution
- More specific (longer) paths always win over shorter ones
- Use `/` as a catch-all to override the default `codeberg.org` fallback
- On ties (same prefix length), the host appearing first in the config file wins
2025-12-08 09:49:07 +01:00
### Environment Variables
2026-04-26 08:23:48 -06:00
- `FJ_HOST` : Override the default instance (auto-detected from git remote if not set)
- `FJ_TOKEN` : Provide authentication token
2025-12-08 09:49:07 +01:00
2026-01-05 12:47:28 +01:00
Hostname is resolved in this priority order:
1. Command-specific flags (e.g., `--hostname` )
2026-04-26 08:23:48 -06:00
2. `FJ_HOST` environment variable
2026-01-05 12:47:28 +01:00
3. Auto-detected from git remote URL
2026-03-23 13:11:43 -06:00
4. `match_dirs` lookup (longest prefix match against current directory)
5. Default to `codeberg.org`
2026-01-05 12:47:28 +01:00
2025-12-08 09:49:07 +01:00
### Command-line Flags
feat: v0.3.0a — add api command, pr diff/comment/review, structured errors
New commands:
- fgj api: raw REST API passthrough with field inference and path interpolation
- fgj pr diff: view PR diffs with color, --name-only, --stat
- fgj pr comment: add comments to pull requests
- fgj pr review: approve, request changes, or comment on PRs
Agentic enhancements:
- --json-errors flag for structured JSON error output on stderr
- APIError type wrapping HTTP status codes for machine consumption
- Error codes: auth_required, not_found, api_error, invalid_input, etc.
Docs updated for forgejo.zerova.net/sid/fgj-sid fork.
2026-03-21 21:50:24 -06:00
- `--hostname` : Specify instance for a command (overrides auto-detection and environment variables)
2025-12-08 09:49:07 +01:00
- `--config` : Use a custom config file
2026-04-26 08:16:52 -06:00
When working in a git repository, `fj` automatically detects the instance from your origin remote URL, so you typically don't need to specify `--hostname` unless working with multiple instances.
2026-01-05 12:47:28 +01:00
2025-12-08 09:49:07 +01:00
## Use with AI Coding Agents
2026-04-26 08:16:52 -06:00
`fj` is designed to work seamlessly with AI coding agents like Claude Code. Use `--json` and `--json-errors` for fully machine-readable I/O:
2025-12-08 09:49:07 +01:00
```bash
# Create PR from agent's changes
2026-04-26 08:16:52 -06:00
fj pr create -R owner/repo -t "feat: add new feature" -b "$(cat < < EOF
2025-12-08 09:49:07 +01:00
## Summary
- Added new feature X
- Fixed bug Y
Generated with AI assistance
EOF
2026-03-21 21:50:24 -06:00
)" --json
2025-12-08 09:49:07 +01:00
# Check PR status during development
2026-04-26 08:16:52 -06:00
fj pr list -R owner/repo --state open --json
2026-03-21 21:50:24 -06:00
# Review a PR diff, then approve
2026-04-26 08:16:52 -06:00
fj pr diff 123
fj pr review 123 --approve -b "LGTM" --json
2026-03-21 21:50:24 -06:00
# Post review feedback
2026-04-26 08:16:52 -06:00
fj pr comment 123 -b "Consider using a map here for O(1) lookup" --json
2026-03-21 21:50:24 -06:00
# Request changes with detailed feedback
2026-04-26 08:16:52 -06:00
fj pr review 123 --request-changes --body-file feedback.md --json
2026-03-21 21:50:24 -06:00
# Use raw API for anything not covered by commands
2026-04-26 08:16:52 -06:00
fj api /repos/{owner}/{repo}/topics --json-errors
fj api /repos/{owner}/{repo}/labels -X POST -f name=agent-reviewed -f color="#00ff00 "
2025-12-08 09:49:07 +01:00
2026-03-21 21:50:24 -06:00
# Fully machine-readable error handling
2026-04-26 08:16:52 -06:00
fj pr view 9999 --json --json-errors 2>errors.json
2025-12-08 09:49:07 +01:00
```
feat: v0.3.0a — add api command, pr diff/comment/review, structured errors
New commands:
- fgj api: raw REST API passthrough with field inference and path interpolation
- fgj pr diff: view PR diffs with color, --name-only, --stat
- fgj pr comment: add comments to pull requests
- fgj pr review: approve, request changes, or comment on PRs
Agentic enhancements:
- --json-errors flag for structured JSON error output on stderr
- APIError type wrapping HTTP status codes for machine consumption
- Error codes: auth_required, not_found, api_error, invalid_input, etc.
Docs updated for forgejo.zerova.net/sid/fgj-sid fork.
2026-03-21 21:50:24 -06:00
## Supported Instances
2025-12-08 09:49:07 +01:00
2026-04-26 08:16:52 -06:00
`fj` works with any Forgejo or Gitea instance, including:
2025-12-08 09:49:07 +01:00
- Self-hosted Forgejo instances
feat: v0.3.0a — add api command, pr diff/comment/review, structured errors
New commands:
- fgj api: raw REST API passthrough with field inference and path interpolation
- fgj pr diff: view PR diffs with color, --name-only, --stat
- fgj pr comment: add comments to pull requests
- fgj pr review: approve, request changes, or comment on PRs
Agentic enhancements:
- --json-errors flag for structured JSON error output on stderr
- APIError type wrapping HTTP status codes for machine consumption
- Error codes: auth_required, not_found, api_error, invalid_input, etc.
Docs updated for forgejo.zerova.net/sid/fgj-sid fork.
2026-03-21 21:50:24 -06:00
- Self-hosted Gitea instances
- [Codeberg.org ](https://codeberg.org )
2025-12-08 09:49:07 +01:00
## Contributing
2026-04-26 08:16:52 -06:00
Contributions are welcome! Please feel free to submit a Pull Request at [forgejo.zerova.net/public/fj ](https://forgejo.zerova.net/public/fj ).
2025-12-08 09:49:07 +01:00
2026-01-16 10:51:37 +01:00
## Missing Features / Roadmap
2026-04-26 08:16:52 -06:00
`fj` aims to be a drop-in replacement for `gh` when working with Forgejo and Gitea instances. While we've implemented the core features, some `gh` commands are not yet available:
2026-01-16 10:51:37 +01:00
**Not Yet Implemented:**
2026-01-16 10:56:05 +01:00
- `run delete` - Delete a workflow run
- `run download` - Download workflow run artifacts
2026-03-21 21:50:24 -06:00
- `pr checkout` , `pr close/reopen`
- `pr checks` , `pr ready/draft`
2026-03-13 18:20:21 +01:00
- `issue reopen` , `issue assign`
- `release edit` , `release download` , `release generate-notes`
feat: v0.3.0d — add PR checks, iostreams, aliases, and broad enhancements
Add PR checks command, iostreams/text packages for colored table output,
top-level run/workflow aliases matching gh CLI structure. Enhance actions,
issues, PRs, releases, repos, labels, milestones, and wiki commands with
improved flags, JSON output, and error handling.
2026-03-23 11:42:44 -06:00
- `repo delete`
2026-01-16 10:51:37 +01:00
feat: v0.3.0a — add api command, pr diff/comment/review, structured errors
New commands:
- fgj api: raw REST API passthrough with field inference and path interpolation
- fgj pr diff: view PR diffs with color, --name-only, --stat
- fgj pr comment: add comments to pull requests
- fgj pr review: approve, request changes, or comment on PRs
Agentic enhancements:
- --json-errors flag for structured JSON error output on stderr
- APIError type wrapping HTTP status codes for machine consumption
- Error codes: auth_required, not_found, api_error, invalid_input, etc.
Docs updated for forgejo.zerova.net/sid/fgj-sid fork.
2026-03-21 21:50:24 -06:00
We welcome contributions to implement any of these features!
## Acknowledgments
2026-04-26 08:16:52 -06:00
Based on [fj by romaintb ](https://codeberg.org/romaintb/fj ). Enhanced with agentic dev features for AI-assisted workflows.
2026-01-16 10:51:37 +01:00
2025-12-08 09:49:07 +01:00
## License
MIT License