Tribunal — Usage Guide
Tribunal is a Claude Code quality enforcement plugin. Once installed (pip install tribunal && tribunal init), it hooks into every file write, test run, and agent interaction.
Core Commands
tribunal status
Show current config, hook health, and audit summary.
CODEBLOCK0
tribunal doctor
Pre-flight health check — all hooks, deps,
.claude/ wiring.
tribunal doctor # interactive
tribunal doctor --json # for CI
Exit code 1 = something broken. Follow the ✗ suggestions to fix.
tribunal ci — Standalone quality gate
Run all checks without Claude Code. Use in CI pipelines.
CODEBLOCK2
Exit codes: 0 = all pass · 1 = failures · 2 = warnings only
tribunal init — Project setup
CODEBLOCK3
Quality Modes
Control enforcement level per session via CLAUDE_CODE_MODE env var:
| Mode | Enforcement | TDD | Coverage |
|---|
| INLINECODE10 (default) | Strict — blocks on failure | Block | 80% |
| INLINECODE11 |
Advisory — warns only | Warn | 60% |
| Custom | Configure in
tribunal/modes/<name>.json | Configurable | Configurable |
Add a "tribunal" block to any mode JSON:
CODEBLOCK4
Hook Events
Tribunal intercepts these Claude Code lifecycle events:
| Event | Hook | What it does |
|---|
| INLINECODE14 (Write/Edit) | INLINECODE15 | Secrets, language quality, path traversal |
| INLINECODE16 (Bash) |
tdd_enforcer | Tests pass/fail, coverage threshold |
|
Stop |
context_monitor | Warns when context window filling up |
|
TeammateIdle |
teammate_idle | Blocks orchestrator if sub-agent left broken code |
|
TaskCompleted |
task_completed | Audits sub-agent session before marking done |
|
SessionEnd |
session_end | Writes session summary to audit log |
Plugin Packs
CODEBLOCK5
MCP Integration
Tribunal exposes MCP tools queryable by any Claude Code session:
CODEBLOCK6
Use via Claude Code's MCP connector pointing to the Tribunal MCP server.
Agent Teams Quality Gates
In multi-agent workflows, Tribunal gates quality between agents:
CODEBLOCK7
Configure in tribunal/rules/multi-agent-quality.md (auto-injected).
Audit Log
All hook events logged to .tribunal/audit.jsonl:
CODEBLOCK8
Fields: timestamp, hook_name, file_path, outcome, duration_ms, agent_id, INLINECODE34
Context Monitor Thresholds
Configure in tribunal/settings.json:
CODEBLOCK9
Set CLAUDE_CONTEXT_WINDOW=1000000 env var for 1M context window (thresholds auto-scale).
VS Code Extension
After install, open VS Code in your project. The Tribunal extension:
- - Shows
🏛 Passing / 🏛 1 Warning / 🏛 2 Blocked in status bar - Adds gutter icons (✅/⚠️/⛔) per file after hooks fire
- Streams hook events to the "Tribunal" output channel
- Reads
.tribunal/audit.jsonl automatically
Live Dashboard
CODEBLOCK10
Shows: live hook feed, context gauge, session stats, filterable audit log.
Full docs: https://tribunal.dev · GitHub: https://github.com/thebotclub/tribunal
Tribunal — 使用指南
Tribunal 是一个 Claude Code 质量强制插件。安装后(pip install tribunal && tribunal init),它会挂钩到每一次文件写入、测试运行和代理交互中。
核心命令
tribunal status
显示当前配置、钩子健康状态和审计摘要。
bash
tribunal status
tribunal status --json
tribunal doctor
预检健康检查——所有钩子、依赖项、.claude/ 连接。
bash
tribunal doctor # 交互式
tribunal doctor --json # 用于 CI
退出码 1 = 存在故障。按照 ✗ 建议进行修复。
tribunal ci — 独立质量门禁
无需 Claude Code 即可运行所有检查。用于 CI 流水线。
bash
tribunal ci # 检查 git diff 的文件
tribunal ci src/payments.py # 指定文件
tribunal ci --json # 机器可读报告
tribunal ci --coverage-threshold 80 # 覆盖率低于 80% 则失败
退出码:0 = 全部通过 · 1 = 失败 · 2 = 仅警告
tribunal init — 项目设置
bash
tribunal init # 交互式向导
tribunal init --non-interactive # CI/代理使用,合理默认值
tribunal init --project-dir /path # 指定目标目录
质量模式
通过 CLAUDECODEMODE 环境变量控制每个会话的强制级别:
| 模式 | 强制方式 | TDD | 覆盖率 |
|---|
| code(默认) | 严格——失败时阻止 | 阻止 | 80% |
| code--chill |
建议——仅警告 | 警告 | 60% |
| 自定义 | 在 tribunal/modes/<名称>.json 中配置 | 可配置 | 可配置 |
在任何模式 JSON 中添加 tribunal 块:
json
{
tribunal: {
tddEnforcement: advisory,
secretScanning: true,
coverageThreshold: 70,
blockOnFail: false
}
}
钩子事件
Tribunal 拦截以下 Claude Code 生命周期事件:
| 事件 | 钩子 | 功能 |
|---|
| PreToolUse(写入/编辑) | filechecker | 密钥、语言质量、路径遍历 |
| PostToolUse(Bash) |
tddenforcer | 测试通过/失败、覆盖率阈值 |
| Stop | context_monitor | 上下文窗口即将填满时发出警告 |
| TeammateIdle | teammate_idle | 如果子代理留下损坏代码则阻止编排器 |
| TaskCompleted | task_completed | 在标记完成前审计子代理会话 |
| SessionEnd | session_end | 将会话摘要写入审计日志 |
插件包
bash
tribunal list-packs # 浏览注册表
tribunal install python-strict # 90% 覆盖率、类型提示、文档字符串
tribunal install go-tdd # go test -cover、go vet、-race 标志
tribunal install nextjs-quality # TypeScript 严格模式、组件测试、可访问性
tribunal install https://github.com/org/custom-pack # 直接 URL
tribunal install ./local-pack/ # 本地目录
MCP 集成
Tribunal 暴露了任何 Claude Code 会话均可查询的 MCP 工具:
tribunal_status — 当前钩子配置、模式、版本
tribunal_audit — 最近的审计条目(可按结果/代理筛选)
tribunalcheckfile — 对任意路径运行 file_checker
tribunalagentsummary — 特定 agent_id 的质量摘要
通过指向 Tribunal MCP 服务器的 Claude Code MCP 连接器使用。
代理团队质量门禁
在多代理工作流中,Tribunal 在代理之间设置质量门禁:
编排器 → 生成子代理 A
子代理 A 写入文件
TeammateIdle 触发 → tribunal 检查 A 的文件
✅ 通过 → 编排器继续
❌ 失败 → 编排器被阻止,直到 A 修复问题
在 tribunal/rules/multi-agent-quality.md 中配置(自动注入)。
审计日志
所有钩子事件记录到 .tribunal/audit.jsonl:
bash
cat .tribunal/audit.jsonl | jq .[] | select(.outcome==blocked)
字段:timestamp、hookname、filepath、outcome、durationms、agentid、detail
上下文监控阈值
在 tribunal/settings.json 中配置:
json
{
contextMonitor: {
warnThreshold: 80,
handoffThreshold: 90
}
}
设置 CLAUDECONTEXTWINDOW=1000000 环境变量以使用 100 万上下文窗口(阈值自动缩放)。
VS Code 扩展
安装后,在项目中打开 VS Code。Tribunal 扩展:
- - 在状态栏显示 🏛 通过 / 🏛 1 个警告 / 🏛 2 个阻止
- 钩子触发后,在每个文件旁添加边栏图标(✅/⚠️/⛔)
- 将钩子事件流式传输到 Tribunal 输出通道
- 自动读取 .tribunal/audit.jsonl
实时仪表板
bash
启动 Claude Code 会话后在浏览器中打开
open tribunal/ui/viewer.html
显示:实时钩子流、上下文仪表盘、会话统计、可筛选的审计日志。
完整文档:https://tribunal.dev · GitHub:https://github.com/thebotclub/tribunal