AI reference
Commands
Rails ERB templateを扱うAI agent、editor integration、script向けの安定したcommand例です。
Hosted commands.md
machine-readableなcommand referenceはMarkdownとして配布します。
https://hinamimi.github.io/erbfmt/commands.md
Codex Skills、Claude Code Skills、editor integration、project固有のagent instructionsからこのURLを参照できます。Markdownは短く、command中心に保っています。
推奨workflow
Rails projectに Gemfile がある場合は、projectでpinされたBundler commandを優先します。
bundle exec erbfmt --version
Rails viewsを編集した後は、machine-readable outputでlint diagnosticsを確認します。
bundle exec erbfmt --lint --lint-format json app/views
fileを変更せずformat状態を確認します。
bundle exec erbfmt --check app/views
format変更を書き込むのは、userがformatを求めたか、formatterによる編集を承認した場合だけにします。
bundle exec erbfmt --write app/views
JSON lint output
--lint-format json はprocessed fileごとに1つのJSON objectを出力します。directoryやmulti-file runでもstream処理しやすい形式です。
{
"file": "app/views/users/show.html.erb",
"summary": {
"issues": 1,
"errors": 1,
"warnings": 0
},
"diagnostics": [
{
"severity": "error",
"message": "duplicate HTML attribute `class`",
"location": {
"line": 1,
"column": 32
}
}
]
}
file-level diagnosticでは location が null になることがあります。
Agent向けの安全ルール
--lint-format jsonが使える場合、prettyoutputをparseしない。- format変更が求められていない、または承認されていない場合は
--writeを実行しない。 - 安全な編集が明確でない複雑なRuby expressionは保持する。
- ignore directiveを追加するより、sourceの修正を優先する。
erbfmt-ignoreは意図的に管理外にするmarkupやgenerated markupにだけ使う。