Safe, reliable local coding agent backend. Forge + coding-specific guardrails.
Project description
coding-guardrails
Safe, reliable local coding agent backend. Open-source, pip-installable.
coding-guardrails is a proxy that sits between your coding agent and a local LLM, adding two layers of protection:
- Forge (Layer 1) — Rescue parsing, retries, validation. Makes local models actually work for tool calling.
- Coding Guardrails (Layer 2) — Read-before-edit, path safety, command blocking, secret masking, test-after-change suggestions.
One command to go from "I have a GPU" to "I have a safe local coding agent backend."
Quick Start
# Install
pip install coding-guardrails
# Start llama-server (your local LLM backend)
llama-server -m model.gguf --jinja --fit on --flash-attn auto \
--port 8080 -c 16384 --spec-type draft-mtp -np 1
# Start the proxy
coding-guardrails serve \
--backend-url http://localhost:8080 \
--model Qwen3.6-35B-A3B-UD-Q3_K_M \
--port 8081
# Point your agent at http://localhost:8081/v1
That's it. Your agent sees a standard OpenAI-compatible API.
What It Blocks
| Rule | Blocks | Example |
|---|---|---|
| Path safety | Reads/writes outside workspace | read_file("/etc/passwd") ❌ |
| Command safety | Destructive shell commands | bash("rm -rf /") ❌ |
| Secret detection | API keys, tokens, private keys | bash("export AWS_SECRET_ACCESS_KEY=...") ❌ |
| Prerequisites | Edit before read (soft nudge) | edit_file() without read_file() ⚠️ |
| Sequencing | Missing test runs (soft nudge) | Edit without pytest ⚠️ |
| Tool resolution | Empty/error results (soft nudge) | Tool returns "" ⚠️ |
All rules are configurable. See docs/rules.md.
Supported Models
Optimized for the Qwen 3.6 family with llama-server:
| Model | VRAM | Context | SWE-bench |
|---|---|---|---|
| Qwen3.6-35B-A3B Q3_K_M ⭐ | 21.6 GB | 16K | 73.4% |
| Qwen3.6-27B Q4_K_M | 22.0 GB | 4K | 77.2% |
Works with any OpenAI-compatible backend. See docs/models.md.
Agent Setup
Point any OpenAI-compatible agent at http://localhost:8081/v1:
- Pi —
api_base: "http://localhost:8081/v1" - Aider —
OPENAI_API_BASE=http://localhost:8081/v1 - Continue —
"apiBase": "http://localhost:8081/v1" - Cline / Roo — set API base in settings
See docs/agents.md for detailed setup guides.
Configuration
Create a guardrail-config.yaml (or use defaults):
path_safety:
enabled: true
blocked_prefixes: ["/etc/", "/sys/", "/proc/"]
command_safety:
enabled: true
strength: hard # hard = block, soft = warn
secrets:
enabled: true
strength: hard
mask_value: "[REDACTED]"
Pass with --config guardrail-config.yaml.
Architecture
Agent → coding-guardrails (:8081) → llama-server (:8080) → GPU
│
├─ Layer 1 (Forge): rescue, validate, retry
└─ Layer 2 (Guardrails): 6 safety rules
See docs/architecture.md for details.
Docker
docker compose up
Or standalone:
docker run -p 8081:8081 ghcr.io/stawils/coding-guardrails:latest \
serve --backend-url http://host.docker.internal:8080 --model your-model
Eval
coding-guardrails eval --backend-url http://localhost:8081
Runs scenarios from eval/scenarios/ and reports pass/fail by category.
Development
git clone https://github.com/stawils/coding-guardrails.git
cd coding-guardrails
uv venv && source .venv/bin/activate
uv pip install -e ".[dev]"
# Run tests
pytest tests/unit/ -v
# Run against live backend
pytest tests/integration/ -v -m integration
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.1.0.tar.gz.
File metadata
- Download URL: coding_guardrails-0.1.0.tar.gz
- Upload date:
- Size: 46.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 |
e01349d7c0cb45f6587ae2799c198c4628e88949d366aec4bc13262f2627ce9e
|
|
| MD5 |
da622e614df6a19872cd7f7f187c9a51
|
|
| BLAKE2b-256 |
5edb20feca0f016d064a68f05efdf98bd74c9de5e58cbc4c9f49155a1dd144fa
|
Provenance
The following attestation bundles were made for coding_guardrails-0.1.0.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.1.0.tar.gz -
Subject digest:
e01349d7c0cb45f6587ae2799c198c4628e88949d366aec4bc13262f2627ce9e - Sigstore transparency entry: 1603167950
- Sigstore integration time:
-
Permalink:
stawils/coding-guardrails@8ea206abfbca6b09ae818e5449885367b38d8ec2 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/stawils
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yaml@8ea206abfbca6b09ae818e5449885367b38d8ec2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file coding_guardrails-0.1.0-py3-none-any.whl.
File metadata
- Download URL: coding_guardrails-0.1.0-py3-none-any.whl
- Upload date:
- Size: 38.0 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 |
bd9d5817ec495e3f43cb83ce52e088a1226f6230435f76fa61fa8e87b8dd374d
|
|
| MD5 |
67def0ce9fa08e95d66c2d093afefc1d
|
|
| BLAKE2b-256 |
9f5f22d3915ac75dc5522fc781708098ad673b3deabae373524654a0aea39dc8
|
Provenance
The following attestation bundles were made for coding_guardrails-0.1.0-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.1.0-py3-none-any.whl -
Subject digest:
bd9d5817ec495e3f43cb83ce52e088a1226f6230435f76fa61fa8e87b8dd374d - Sigstore transparency entry: 1603168083
- Sigstore integration time:
-
Permalink:
stawils/coding-guardrails@8ea206abfbca6b09ae818e5449885367b38d8ec2 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/stawils
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yaml@8ea206abfbca6b09ae818e5449885367b38d8ec2 -
Trigger Event:
push
-
Statement type: