dgent — de-agent your code
Clean AI tells from code and commit messages. Runs as git hooks automatically, or on-demand via CLI.
When to use
- - Before committing code written by an AI agent
- When asked to "clean up" or "de-agent" output
- To check if code has AI naming patterns, catch-rethrow, section headers, or noise comments
- To check if a commit message has AI vocabulary, emoji, or trailers
Quick check a file
CODEBLOCK0
Returns JSON with clean, fixes[], flags[], and output (cleaned content). Exit codes: 0 = clean or fixes applied, 1 = flags found.
Quick check — exit code only
CODEBLOCK1
Silent. Exit 0 if clean or fixes applied, 1 if flags found. Use in pre-commit scripts.
Scan entire directory
CODEBLOCK2
Returns JSON with per-file results. Use before committing multi-file changes.
Fix a file in place
CODEBLOCK3
Applies all deterministic fix rules (strip trailers, emoji, section headers) and writes back.
Check a commit message
CODEBLOCK4
Stdin with short non-code input auto-detects as commit-msg. Returns fixes (emoji, trailers) and flags (AI vocabulary).
Get the full rule catalog
CODEBLOCK5
Returns every rule with name, phase, type, enabled status, and complete pattern lists. Use this to know exactly what to avoid.
Patterns to avoid
These trigger flags (from dgent rules --json):
Commit message words: enhance, streamline, comprehensive, utilize, leverage, facilitate, robust, optimize
Commit message phrases: "this commit", "this change", "in order to", "aims to", "is designed to"
Naming suffixes: Manager, Handler, Processor, Service, Factory, Builder, Validator, Controller, Orchestrator, Coordinator
Identifier length: over 40 characters
Catch-rethrow: catch (e) { console.error(e); throw e; } — either handle the error or let it propagate
Suppress a specific flag
CODEBLOCK6
Supports // dgent-ignore, // dgent-ignore-next-line, // dgent-ignore <rule1> <rule2>.
Workflow for agents
- 1. Write code
- Run
dgent run --json <file> on each modified file - Fix any flags (rename identifiers, remove catch-rethrow, etc.)
- Run
echo "commit message" | dgent run --json --commit-msg - on the message - Fix any message flags (remove AI vocabulary, rephrase)
- Commit — dgent hooks will clean trailers and emoji automatically
dgent — 为你的代码去AI化
从代码和提交信息中清除AI痕迹。可作为Git钩子自动运行,或通过CLI按需执行。
使用场景
- - 提交由AI助手编写的代码前
- 被要求清理或去AI化输出时
- 检查代码是否存在AI命名模式、捕获重抛、章节标题或噪声注释
- 检查提交信息是否包含AI词汇、表情符号或尾部标记
快速检查文件
bash
dgent run --json <文件>
返回包含clean、fixes[]、flags[]和output(清理后内容)的JSON。退出码:0=已清理或已修复,1=发现标记。
快速检查——仅退出码
bash
dgent run --check <文件>
静默模式。若已清理或已修复则退出0,发现标记则退出1。用于预提交脚本。
扫描整个目录
bash
dgent scan --json [目录]
返回包含每个文件结果的JSON。在提交多文件变更前使用。
原地修复文件
bash
dgent run --fix <文件>
应用所有确定性修复规则(去除尾部标记、表情符号、章节标题)并写回文件。
检查提交信息
bash
echo 你的信息 | dgent run --json --commit-msg -
通过标准输入传入短的非代码内容会自动检测为提交信息。返回修复项(表情符号、尾部标记)和标记项(AI词汇)。
获取完整规则目录
bash
dgent rules --json
返回每条规则的名称、阶段、类型、启用状态及完整模式列表。用于精确了解应避免的内容。
应避免的模式
以下内容会触发标记(来自dgent rules --json):
提交信息词汇: 增强、精简、全面、利用、运用、促进、稳健、优化
提交信息短语: 本次提交、此变更、为了、旨在、设计用于
命名后缀: Manager、Handler、Processor、Service、Factory、Builder、Validator、Controller、Orchestrator、Coordinator
标识符长度: 超过40个字符
捕获重抛: catch (e) { console.error(e); throw e; } ——要么处理错误,要么让它传播
抑制特定标记
typescript
// dgent-ignore flag-naming
class DataProcessor { ... } // 不会被标记
支持// dgent-ignore、// dgent-ignore-next-line、// dgent-ignore <规则1> <规则2>。
AI助手工作流程
- 1. 编写代码
- 对每个修改的文件运行dgent run --json <文件>
- 修复所有标记(重命名标识符、移除捕获重抛等)
- 对提交信息运行echo 提交信息 | dgent run --json --commit-msg -
- 修复信息中的标记(移除AI词汇、重新措辞)
- 提交——dgent钩子会自动清理尾部标记和表情符号