Caution
This project is no longer active. The current and maintained version is now Agent Enforcer 2. It provides a robust, language-agnostic reference architecture for local CI systems.
Agent Enforcer is a powerful and flexible code quality checking tool designed to be used by both developers and AI agents. It integrates multiple linters and formatters to provide comprehensive feedback, and it can be used as a standalone CLI tool or as an MCP server within compatible editors like Cursor.
Agent Enforcer is part of the larger Artemonim's Agent Tools ecosystem:
- Agent Compass — A comprehensive policy framework for AI-assisted development in Cursor IDE
- Agent Enforcer 2 — Local CI blueprint and reference architecture (maintained successor)
- Agent Docstrings (Archived) — File-level structure summaries (legacy)
- Agent Viewport (On Hold / Uncertain) — UI markup understanding concept for AI assistants
- Features
- Installation
- Usage
- Configuration
- MCP Integration (Cursor IDE)
- Logging
- Sponsorship
- Contributing
- Development Setup
- Changelog
- License
- Flexible CLI: Check specific files/directories, or only files modified in git.
- Smart File Discovery: Automatically respects
.gitignoreand excludes common test fixture/submodule directories by default. - Dynamic Configuration: Uses a project-local
.enforcer/config.jsonthat is reloaded on every check, so no server restart is needed. - MCP Server: Exposes its functionality as a
checkertool for AI agents in editors like Cursor. - Robust and Loggable: Executes external tools safely with timeouts and generates detailed logs for diagnostics.
- Supported Languages: Python, C#, Kotlin, JavaScript, TypeScript
The recommended installation method depends on your use case.
This is the standard way to use the tool in your projects.
A) Global Installation: Install it once system-wide. This is the easiest method for MCP integration.
pip install agent-enforcerB) Project-specific Installation: Install it as a dependency in your project's virtual environment.
# In your activated virtual environment
pip install agent-enforcerIf you want to contribute to Agent Enforcer itself, clone the repository and install it in editable mode.
# Clone the repository
git clone --recursive https://github.com/Artemonim/AgentEnforcer.git
cd AgentEnforcer
# Create and activate a virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Linux/macOS
# venv\Scripts\activate # On Windows
# Install in editable mode with development dependencies
pip install -e .[dev]You can run Agent Enforcer from your terminal to check a path. If no path is provided, it checks the current directory.
# Check the current directory
agent-enforcer
# Check a specific file
agent-enforcer src/game.py
# Check a whole directory
agent-enforcer src/For more advanced CLI options, use agent-enforcer-cli --help.
On its first run, the tool creates a .enforcer/config.json file in your project root. You can modify this file to customize behavior. Changes are applied immediately on the next check.
debug_mode_enabled(boolean, default:false): Enables Enforcer dev-output.check_fixtures(boolean, default:false): Includes test fixture files in checks.check_submodules(boolean, default:false): Includes git submodules in checks.disabled_rules(object): Disables specific linter rules (e.g.,{"python": ["E501"]}).custom_fixture_patterns(object): Defines custom patterns for fixture detection.
To use Agent Enforcer within Cursor, you need to configure the MCP server.
- Go to
File > Settings > Cursor. - Scroll to the MCP section and click "Open mcp.json".
- Add a configuration based on your installation method.
{
"mcpServers": {
"agent_enforcer": {
"command": "agent-enforcer-mcp"
}
}
}If you installed the package locally in a virtual environment, you must provide the full path to the executable.
- Windows:
{
"mcpServers": {
"agent_enforcer": {
"command": "./venv/Scripts/agent-enforcer-mcp.exe"
}
}
}- macOS/Linux:
{
"mcpServers": {
"agent_enforcer": {
"command": "./venv/bin/agent-enforcer-mcp"
}
}
}The main tool that runs comprehensive code quality checks.
Parameters:
resource_uris(list[str], optional): File URIs to check.check_git_modified_files(bool, default:false): Check only modified files.verbose(bool, default:false): Provide detailed, per-file output.timeout_seconds(int, default:0): Timeout for the check (0 = no timeout).root(str, optional): Repository root path (usually auto-detected).debug(bool, default:false): Enable extra-verbose debug logging (must also be enabled inconfig.json).
The server provides three prompts for structured AI interactions.
fix-this-file: Generates a prompt asking the AI to fix specific linting issues in a file.summarize-lint-errors: Creates a prompt for the AI to summarize and prioritize critical errors.explain-rule: Generates a prompt for the AI to explain a specific linting rule.
Note: Prompts are part of the MCP protocol but are not currently supported in Cursor. They may work in other MCP-compatible clients that support the prompts API.
Agent Enforcer generates two log files inside the .enforcer/ directory in your project root, which can be useful for diagnostics and analysis.
Enforcer_last_check.log: A machine-readable JSON log containing detailed information about all issues found during the last check. This is useful for integrations or for tools that need to programmatically access the results.Enforcer_stats.log: A historical log that tracks the frequency of each violated rule over time. Analyzing this file can help identify recurring problems in a codebase, which can inform decisions about custom rule configurations or prompt-engineering problems.
It is recommended to add this logs to your project's .gitignore file to avoid committing these logs and local configuration to version control.
# Agent Enforcer logs
.enforcer/Enforcer_last_check.log
.enforcer/Enforcer_stats.logThis project is archived. If you find it useful and want to support my work, thank you!
You can support my work in two ways:
- Give a Star: Star the repositories you use on GitHub.
- Support on Sponsr: Support me on Sponsr.
Thank you for your support!
We welcome contributions! Please see our CONTRIBUTING.md for detailed instructions on how to get started, our development workflow, and coding standards.
The project includes the Model Context Protocol (MCP) specification as a git submodule. Make sure you clone it correctly if you plan to contribute.
# When cloning for the first time
git clone --recursive https://github.com/Artemonim/AgentEnforcer.git
# Or if you have already cloned it without submodules
git submodule update --init --recursiveThe MCP specification is located in Doc/modelcontextprotocol/.
See CHANGELOG.md for a list of changes and version history.
This project is licensed under the MIT License. See the LICENSE file for details.