Sentrux — Architectural Feedback Sensor for AI Agents
Real-time code quality sensor written in pure Rust that closes the feedback loop for AI coding agents. Monitors architecture patterns and feeds improvement signals back to agents. 800+ stars.
What it is
Sentrux is a real-time architectural sensor written in pure Rust that helps AI coding agents close the feedback loop for code quality improvement. It monitors your codebase for architectural patterns, complexity metrics, and code smells, then feeds structured feedback back to AI agents so they can iteratively improve their own output.
Sentrux targets teams using AI agents in production who want to ensure code quality does not degrade over time. It works with Claude Code, Cursor, and any agent that accepts structured feedback.
How it saves time or tokens
Without Sentrux, AI agents operate without visibility into the architectural quality of the code they generate. They may introduce high cyclomatic complexity, tight coupling, or naming inconsistencies that accumulate over time. Sentrux provides continuous monitoring with structured JSON output that agents can parse and act on, creating a self-improving loop. The estimated overhead is 2,400 tokens per analysis cycle.
How to use
- Install Sentrux:
cargo install sentrux
- Run watch mode for continuous monitoring:
sentrux watch ./src --rules complexity,coupling,naming
- Integrate with your AI agent:
# Agent writes code, then Sentrux analyzes it
sentrux analyze ./src --format json | your-agent
# Example output:
# {"file": "src/auth/handler.rs", "line": 45,
# "severity": "warn",
# "rule": "complexity",
# "message": "Cyclomatic complexity 23 (threshold: 15)"}
Example
The agent feedback loop in practice:
# Step 1: Agent writes code
codex --auto 'Implement the payment processing module'
# Step 2: Sentrux analyzes the result
sentrux analyze ./src/payments --format json > feedback.json
# Step 3: Agent reads feedback and improves
codex --auto 'Fix the issues in feedback.json:
- Reduce complexity in process_payment() from 23 to under 15
- Extract helper functions for validation logic
- Fix naming: use snake_case consistently'
# Step 4: Verify improvements
sentrux analyze ./src/payments --format pretty
# [OK] All checks pass
Related on TokRepo
- Coding tools — More code quality and developer tools on TokRepo.
- AI tools for testing — Browse testing and validation tools.
Common pitfalls
- Setting complexity thresholds too low generates excessive warnings that agents cannot prioritize. Start with standard thresholds and tighten gradually.
- Running Sentrux on generated code (tests, migrations) produces false positives. Exclude auto-generated directories from the analysis path.
- Relying solely on Sentrux for code review misses semantic issues that static analysis cannot catch. Use Sentrux as a complement to human code review, not a replacement.
Frequently Asked Questions
Sentrux monitors cyclomatic complexity, module coupling scores, naming convention compliance, code duplication, function length, and configurable custom rules. Each metric has a configurable threshold and severity level.
No. Sentrux focuses on architectural-level metrics (complexity, coupling, module structure) rather than syntax and formatting. Use Sentrux alongside your existing linter for comprehensive code quality monitoring.
Sentrux supports Rust, Python, TypeScript, JavaScript, Go, and Java through language-specific analyzers. Language support is extensible through plugins.
The agent writes code, Sentrux analyzes it and produces structured JSON feedback, and the agent reads the feedback to make targeted improvements. This creates an iterative self-improvement cycle.
Yes. Written in Rust, Sentrux analyzes most codebases in under a second. Watch mode re-analyzes only changed files, making the feedback loop near-instantaneous.
Citations (3)
- Sentrux GitHub— Sentrux architectural feedback sensor
- Wikipedia— Cyclomatic complexity in software engineering
- Anthropic Research— AI agent self-improvement patterns
Related on TokRepo
Source & Thanks
Discussion
Related Assets
Conda — Cross-Platform Package and Environment Manager
Install, update, and manage packages and isolated environments for Python, R, C/C++, and hundreds of other languages from a single tool.
Sphinx — Python Documentation Generator
Generate professional documentation from reStructuredText and Markdown with cross-references, API autodoc, and multiple output formats.
Neutralinojs — Lightweight Cross-Platform Desktop Apps
Build desktop applications with HTML, CSS, and JavaScript using a tiny native runtime instead of bundling Chromium.