Skip to content

aspelldenny/quality-gate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quality Gate

Filter AI output before it reaches your users.

Strip banned phrases, internal leaks, and thinking artifacts from LLM responses. Configurable per project via TOML. Ships with sane defaults.

Install

cargo install --git https://github.com/aspelldenny/quality-gate

Requires Rust 1.70+ (stable).

Usage

Quality Gate has three modes: filter, check, and serve.

Filter (pipe mode)

Read from stdin, write cleaned output to stdout:

echo "Great! Based on pipeline COMPLEX, Claude Opus analyzed..." | quality-gate filter
# Output: "Great! Based on , analyzed..."

# With project-specific rules:
echo "..." | quality-gate filter --rules .quality-gate.toml

Check (lint mode)

Check a file for violations. Exit 0 = clean, exit 1 = violations found:

quality-gate check --input response.txt
quality-gate check --input response.txt --rules .quality-gate.toml

Serve (MCP mode)

Start an MCP stdio server for integration with Claude Code and other AI tooling:

quality-gate serve

Exposes two tools over JSON-RPC: filter_text and check_text.

Commands

Command Description Key Flags
filter Pipe filter — stdin to stdout --rules <path>
check Lint file for violations --input <path>, --rules <path>
serve MCP stdio server

What gets filtered

Base rules (always active, built into the binary)

  • Thinking artifacts<thinking>...</thinking>, <reflection>...</reflection> blocks
  • Model/vendor names — Claude Opus/Sonnet/Haiku, Gemini Flash/Pro, GPT-3/4, OpenRouter, OpenAI, Anthropic

Project rules (.quality-gate.toml)

Drop a .quality-gate.toml in your project root to add project-specific rules. All sections are optional:

[banned_phrases]
items = [
  "Based on the information",
  "That's a great question",
]

[internal_leaks]
patterns = [
  "pipeline",
  "Sprint\\s*\\d+",
  "READY_FOR_SPREAD",
]

[thinking]
strip = true  # default — set false to keep thinking blocks
  • Banned phrases — exact text, case-insensitive, stripped from output
  • Leak patterns — regex, case-insensitive, stripped from output
  • Thinking — toggle stripping of <thinking> blocks (on by default)

Project rules merge with base rules (union). They never replace them.

TOML escaping note: regex backslashes need double-escaping in TOML basic strings. \s becomes \\s, \d+ becomes \\d+.

Configuration

If --rules is not provided:

  1. Quality Gate looks for .quality-gate.toml in the current directory
  2. If not found, only base rules apply

In MCP mode, the client passes rules_path as a tool parameter.

Status

v0.1 — rules engine and CLI scaffold are functional. Filter pipeline and MCP server are stubbed and under active development. The rules loading, merging, and validation layer is complete and tested.

Project Structure

quality-gate/
├── src/
│   ├── main.rs          # CLI entry point (clap derive)
│   ├── lib.rs           # Core API: error types, re-exports
│   └── rules/
│       ├── mod.rs       # RuleSet struct + merge logic
│       ├── loader.rs    # TOML → RuleSet parser with regex validation
│       └── defaults.rs  # Embeds base.toml at compile time
├── rules/
│   └── base.toml        # Base rules shipped with the binary
└── tests/
    └── rules_test.rs    # Integration tests for rules loading + merge

Requirements

  • Rust stable (1.70+)
  • No runtime dependencies — single static binary

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages