Harmony
Repo rules enforcement for AI agents. Harmony checks diffs against the repository rule set and blocks violations before they land.
Version
v0.1.5
License
MIT
Platforms
Node 18 or newer, Any MCP client
Interfaces
CLI, MCP
Overview
Harmony gives AI agents the same guard rails a senior reviewer would. It reads the rules a repository declares, in AGENTS.md or in a dedicated rules file, and checks every diff against them before the patch is applied. No trailing whitespace, no debug leftovers, no committed secrets, and any custom policy the repository defines.
Setup
npm install -g harmony-mcp
Add the server to your MCP client.
{
"mcpServers": {
"harmony": {
"command": "harmony-mcp",
"args": []
}
}
}
Define custom rules in .harmony/rules.json at the repository root. Each rule declares an id, a regex, a message, matching files, and a severity.
{
"rules": [
{
"id": "no-hyphens-ui",
"regex": "[a-z]-[a-z]",
"message": "No dashes in UI text",
"files": ["**/*.astro", "**/*.md", "**/*.html"],
"severity": "warning"
}
]
}
Usage
rules.loadload the rule set for a repository. Returns the built in rules plus any custom rules.rules.checkcheck a diff against the rule set. If no diff is provided, the working tree diff of the repository is used.
Built in rules:
| id | severity | checks |
|---|---|---|
| no-trailing-whitespace | warning | lines ending in spaces or tabs |
| no-debug-leftovers | warning | console.log, console.debug, debugger |
| no-committed-secrets | blocker | api keys, passwords, tokens, secret shapes |
| no-tabs | info | tab indentation in changed code |
Typical agent instructions:
- “Check the current diff against the repo rules.”
- “Block any change that adds a secret.”
- “Does the diff violate AGENTS.md?”
Gains
- Policy violations are caught at diff time, not review time.
- The rule set is declarative and lives with the repository.
- Custom rules encode conventions that generic linters cannot express.
- Deterministic output. The same diff produces the same findings.
Repository
- Repository: github.com/AbduljabbarBXR/harmony-mcp
- npm:
harmony-mcp - License: MIT
- Current version: 0.1.5