Overview
Run Claude Code non-interactively in a locked-down virtual machine with a narrowly scoped Forgejo token, so it can work on issues and open pull requests but never merge or deploy.
Problem or Objective
More in Coding and Code Review
AI Agents and Models
Tools and Integrations
- Tools
- Claude Code · Forgejo
- Prerequisites
- Claude Code access, a Forgejo instance with permission to issue scoped tokens, and a virtual machine you can lock down. Also needed: a virtual machine.
How It Works
Build a virtual machine that holds only the repository checkout, with no production credentials and network access limited to your Forgejo server and the model API. Create a Forgejo access token with only the issue and repository scopes the agent needs, and hand it over through a secrets broker or an environment variable rather than a file in the repository. Run Claude Code with claude -p and an explicit list of allowed tools, point it at an issue, and let it push a branch and open a pull request. You review and merge manually, and your normal CI does the deploying.
Implementation Workflow
Steps assembled from the agents, tools and prompt of this entry. Adapt them to your own setup.
- Choose the agentSet up Claude Code.
- Connect the toolsConnect the tools this workflow relies on: Claude Code, Forgejo.
- Check the prerequisitesClaude Code access, a Forgejo instance with permission to issue scoped tokens, and a virtual machine you can lock down. Also needed: a virtual machine.
- Gather your detailsCollect what the prompt asks for: Issue number, Repository, Test command, Branch name.
- Run the starter promptPaste the starter prompt below into Claude Code and adapt it to your case.
- Check against the documentationCompare what you get with the documentation at code.claude.com before you rely on it.
Practical Starter Prompt: Fix one issue on a branch for review
Fill the fields to adapt the prompt. Empty fields stay as visible [placeholders].
Read issue [Issue number] in the repository [Repository]. Work only inside the checked-out folder, run only [Test command] to check your work, and make the smallest change that fixes the problem. Push the change to a new branch named [Branch name] and open a pull request that links the issue and lists what you changed and what you could not test. Do not merge, deploy, change repository settings or touch other branches, and stop and ask if the fix would need any of those.Test the setup on a throwaway repository before pointing it at real work.
Expected Results and Benefits
This is a suggested workflow, not a reported result. The points below are what the cited documentation says the tools can do.
This is a suggested workflow, not a reported outcome. Anthropic's documentation says Claude Code can edit files, run commands and work with git, and can run non-interactively with the tools you list in advance, and Forgejo's documentation says its access tokens can be limited to selected API routes. Neither covers the virtual machine, the secrets broker or how Claude Code reaches Forgejo, so those parts rest on your own setup and testing.
Limitations and Considerations
A claude -p run connects the servers in the project's .mcp.json without a trust dialog or approval prompt (--bare skips them), so list only servers you trust; the allowed-tools list and the token scopes are your real safety limits, so start narrow and widen them only when a task needs it. Keep deployment credentials out of the machine entirely, and review every pull request as you would a stranger's. The cited pages do not cover how Claude Code reaches Forgejo, so check which API calls, command-line tool or MCP server you use. Results depend on your setup and were not independently reproduced by Top 200 Repos.
GitHub Repositories
AI Agent Repository
Source code of the agent that does the work.
Official Website
The official site of the main tool or project in this use case.
Visit Website (opens in a new tab)code.claude.com
Related Videos
About anthropics/claude-code
The SECRET Claude Code Upgrade That Has Everyone Going Nuts (Full Guide) (opens in a new tab)
The title names the project, the description links the project website.
Watch on YouTube (opens in a new tab)About anthropics/claude-code
The only Claude Code guide you'll ever need (Opus 4.5) (opens in a new tab)
The title names the project, the description links the project website.
Watch on YouTube (opens in a new tab)Independent creators. Listing a video implies no endorsement, sponsorship or partnership.
Sources
- Run Claude Code programmatically - Claude Code Docs (opens in a new tab)
Project documentation · code.claude.com · Undated · Source checked 26 Nov 2026, 17:27 UTC
What this source supports
- Runs non-interactively with claude -p, or from Python and TypeScript through the Agent SDK, for scripts and automation.
- Without --bare, a -p session connects the servers in the project's .mcp.json and shows no workspace trust dialog or per-server approval prompt; with --bare those servers do not run.
- --allowedTools lets Claude use the listed tools without prompting.
- Overview - Claude Code Docs (opens in a new tab)
Project documentation · code.claude.com · Undated · Source checked 25 Nov 2026, 11:57 UTC
What this source supports
- Claude Code is an agentic coding tool that reads your codebase, edits files and runs commands.
- Claude Code works directly with git: it stages changes, writes commit messages, creates branches and opens pull requests.
- Access Token Scope | Forgejo – Beyond coding. We forge. (opens in a new tab)
Project documentation · forgejo.org · Undated · Source checked 26 Nov 2026, 17:53 UTC
What this source supports
- Forgejo supports scoped access tokens, which restrict a token to selected URL routes, with read and write levels.

