ascii-diagram-validator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseASCII Diagram Validator
ASCII图表验证工具
Validate and fix alignment issues in ASCII box-drawing diagrams commonly used in architecture documentation, README files, and code comments.
验证并修复架构文档、README文件和代码注释中常用的ASCII框绘图表的对齐问题。
Overview
概述
ASCII diagrams using box-drawing characters (─│┌┐└┘├┤┬┴┼ and double-line variants ═║╔╗╚╝╠╣╦╩╬) require precise column alignment. This skill provides:
- Validation script - Detects misaligned characters with file:line:column locations
- Actionable fixes - Specific suggestions for correcting each issue
- Multi-file support - Validate individual files or entire directories
使用框绘字符(─│┌┐└┘├┤┬┴┼ 以及双线变体 ═║╔╗╚╝╠╣╦╩╬)的ASCII图表需要精确的列对齐。本工具提供:
- 验证脚本 - 检测错位字符并给出文件:行:列位置
- 可执行修复建议 - 针对每个问题的具体修正建议
- 多文件支持 - 验证单个文件或整个目录
When to Use This Skill
使用场景
Invoke when:
- Creating or editing ASCII architecture diagrams in markdown
- Reviewing documentation with box-drawing diagrams
- Fixing "diagram looks wrong" complaints
- Before committing docs/ARCHITECTURE.md or similar files
- When user mentions "ASCII alignment", "diagram alignment", or "box drawing"
在以下场景调用本工具:
- 在Markdown中创建或编辑ASCII架构图表时
- 审核包含框绘图表的文档时
- 解决“图表显示异常”的问题时
- 提交docs/ARCHITECTURE.md或类似文件之前
- 当用户提及“ASCII对齐”、“图表对齐”或“框绘字符”时
Supported Characters
支持的字符
Single-Line Box Drawing
单线框绘字符
Corners: ┌ ┐ └ ┘
Lines: ─ │
T-joins: ├ ┤ ┬ ┴
Cross: ┼Corners: ┌ ┐ └ ┘
Lines: ─ │
T-joins: ├ ┤ ┬ ┴
Cross: ┼Double-Line Box Drawing
双线框绘字符
Corners: ╔ ╗ ╚ ╝
Lines: ═ ║
T-joins: ╠ ╣ ╦ ╩
Cross: ╬Corners: ╔ ╗ ╚ ╝
Lines: ═ ║
T-joins: ╠ ╣ ╦ ╩
Cross: ╬Mixed (Double-Single)
混合(双-单线)
╞ ╟ ╤ ╧ ╪ ╫╞ ╟ ╤ ╧ ╪ ╫Quick Start
快速开始
Validate a Single File
验证单个文件
bash
/usr/bin/env bash << 'PREFLIGHT_EOF'
uv run ${CLAUDE_PLUGIN_ROOT}/skills/ascii-diagram-validator/scripts/check_ascii_alignment.py docs/ARCHITECTURE.md
PREFLIGHT_EOFbash
/usr/bin/env bash << 'PREFLIGHT_EOF'
uv run ${CLAUDE_PLUGIN_ROOT}/skills/ascii-diagram-validator/scripts/check_ascii_alignment.py docs/ARCHITECTURE.md
PREFLIGHT_EOFValidate Multiple Files
验证多个文件
bash
/usr/bin/env bash << 'PREFLIGHT_EOF_2'
uv run ${CLAUDE_PLUGIN_ROOT}/skills/ascii-diagram-validator/scripts/check_ascii_alignment.py docs/*.md
PREFLIGHT_EOF_2bash
/usr/bin/env bash << 'PREFLIGHT_EOF_2'
uv run ${CLAUDE_PLUGIN_ROOT}/skills/ascii-diagram-validator/scripts/check_ascii_alignment.py docs/*.md
PREFLIGHT_EOF_2Validate Directory
验证目录
bash
/usr/bin/env bash << 'PREFLIGHT_EOF_3'
uv run ${CLAUDE_PLUGIN_ROOT}/skills/ascii-diagram-validator/scripts/check_ascii_alignment.py docs/
PREFLIGHT_EOF_3bash
/usr/bin/env bash << 'PREFLIGHT_EOF_3'
uv run ${CLAUDE_PLUGIN_ROOT}/skills/ascii-diagram-validator/scripts/check_ascii_alignment.py docs/
PREFLIGHT_EOF_3Output Format
输出格式
The script outputs issues in a compiler-like format for easy navigation:
docs/ARCHITECTURE.md:45:12: error: vertical connector '│' at column 12 has no matching character above
→ Suggestion: Add '│', '├', '┤', '┬', or '┼' at line 44, column 12
docs/ARCHITECTURE.md:67:8: warning: horizontal line '─' at column 8 has no terminator
→ Suggestion: Add '┐', '┘', '┤', '┴', or '┼' to close the line脚本以类编译器的格式输出问题,便于导航:
docs/ARCHITECTURE.md:45:12: error: vertical connector '│' at column 12 has no matching character above
→ Suggestion: Add '│', '├', '┤', '┬', or '┼' at line 44, column 12
docs/ARCHITECTURE.md:67:8: warning: horizontal line '─' at column 8 has no terminator
→ Suggestion: Add '┐', '┘', '┤', '┴', or '┼' to close the lineSeverity Levels
严重级别
| Level | Description |
|---|---|
| error | Broken connections, misaligned verticals |
| warning | Unterminated lines, potential issues |
| info | Style suggestions (optional cleanup) |
| 级别 | 描述 |
|---|---|
| error | 连接断裂、垂直对齐错位 |
| warning | 未终止的线条、潜在问题 |
| info | 样式建议(可选清理) |
Validation Rules
验证规则
The script checks for:
- Vertical Alignment - Vertical connectors (│║) must align with characters above/below
- Corner Connections - Corners (┌┐└┘╔╗╚╝) must connect properly to adjacent lines
- Junction Validity - T-joins and crosses must have correct incoming/outgoing connections
- Line Continuity - Horizontal lines (─═) should terminate at valid endpoints
- Box Closure - Boxes should be properly closed (no dangling edges)
脚本检查以下内容:
- 垂直对齐 - 垂直连接器(│║)必须与上下字符对齐
- 边角连接 - 边角字符(┌┐└┘╔╗╚╝)必须与相邻线条正确连接
- 连接点有效性 - T型连接和交叉点必须有正确的进出连接
- 线条连续性 - 水平线(─═)应在有效端点终止
- 闭合性 - 框体应正确闭合(无悬空边缘)
Exit Codes
退出码
| Code | Meaning |
|---|---|
| 0 | No issues found |
| 1 | Errors detected |
| 2 | Warnings only (errors ignored with --warn-only) |
| 代码 | 含义 |
|---|---|
| 0 | 未发现问题 |
| 1 | 检测到错误 |
| 2 | 仅存在警告(使用--warn-only标志时忽略错误) |
Integration with Claude Code
与Claude Code集成
When Claude Code creates or edits ASCII diagrams:
- Run the validator script on the file
- Review any errors in the output
- Apply suggested fixes
- Re-run until clean
当Claude Code创建或编辑ASCII图表时:
- 在文件上运行验证脚本
- 查看输出中的错误
- 应用建议的修复
- 重新运行直到无问题
Example Workflow
示例工作流
bash
/usr/bin/env bash << 'PREFLIGHT_EOF_4'bash
/usr/bin/env bash << 'PREFLIGHT_EOF_4'After editing docs/ARCHITECTURE.md
After editing docs/ARCHITECTURE.md
uv run ${CLAUDE_PLUGIN_ROOT}/skills/ascii-diagram-validator/scripts/check_ascii_alignment.py docs/ARCHITECTURE.md
uv run ${CLAUDE_PLUGIN_ROOT}/skills/ascii-diagram-validator/scripts/check_ascii_alignment.py docs/ARCHITECTURE.md
If errors found, Claude Code can read the output and fix:
If errors found, Claude Code can read the output and fix:
docs/ARCHITECTURE.md:45:12: error: vertical connector '│' at column 12 has no matching character above
docs/ARCHITECTURE.md:45:12: error: vertical connector '│' at column 12 has no matching character above
→ Edit line 44, column 12 to add the missing connector
→ Edit line 44, column 12 to add the missing connector
PREFLIGHT_EOF_4
undefinedPREFLIGHT_EOF_4
undefinedLimitations
局限性
- Detects structural alignment issues, not aesthetic spacing
- Requires consistent use of box-drawing characters (no mixed ASCII like +---+)
- Tab characters may cause false positives (convert to spaces first)
- Unicode normalization not performed (use pre-composed characters)
- 检测结构对齐问题,不检查美观间距
- 需要一致使用框绘字符(不支持+---+这类混合ASCII格式)
- 制表符可能导致误报(先转换为空格)
- 不执行Unicode归一化(使用预组合字符)
Bundled Scripts
捆绑脚本
| Script | Purpose |
|---|---|
| Main validation script |
| 脚本 | 用途 |
|---|---|
| 主验证脚本 |
Related
相关链接
Troubleshooting
故障排除
| Issue | Cause | Solution |
|---|---|---|
| Script not found | Plugin not installed | Verify plugin installed with |
| False positives with tabs | Tab characters misalign | Convert tabs to spaces before validation |
| Mixed ASCII not detected | Using | Script only validates Unicode box-drawing chars |
| Column numbers off | Unicode width calculation | Use pre-composed characters, avoid combining marks |
| No issues but looks wrong | Aesthetic spacing not checked | Validator checks structure, not visual spacing |
| Exit code 2 unexpected | warnings only mode | Use --warn-only flag to treat warnings as success |
| Can't find validation error | Complex nested diagram | Check line numbers in output, validate section only |
| Unicode chars not rendering | Terminal font missing glyphs | Use font with full Unicode box-drawing support |
| 问题 | 原因 | 解决方案 |
|---|---|---|
| 脚本未找到 | 插件未安装 | 使用 |
| 制表符导致误报 | 制表符错位 | 验证前将制表符转换为空格 |
| 混合ASCII未被检测到 | 使用 | 脚本仅验证Unicode框绘字符 |
| 列号不正确 | Unicode宽度计算问题 | 使用预组合字符,避免组合标记 |
| 无问题但显示异常 | 未检查美观间距 | 验证器仅检查结构,不检查视觉间距 |
| 意外返回退出码2 | 仅警告模式 | 使用--warn-only标志将警告视为成功 |
| 找不到验证错误 | 复杂嵌套图表 | 查看输出中的行号,仅验证对应部分 |
| Unicode字符未渲染 | 终端字体缺少字形 | 使用支持完整Unicode框绘字符的字体 |