Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Automated Format-on-Save for Non-Editor File Writes

说明与用途

“onwrite” 工具自动化了由脚本或代理创建的文件代码格式化。它利用现有的项目配置(Prettier, Ruff)并确保原子文件替换,防止风格不一致和错误。

问题

Files generated by scripts, shell commands, or coding agents are not automatically formatted, leading to style inconsistencies detected later by pre-commit hooks or CI.

结果

The 'onwrite' tool successfully intercepts file writes from generators and agents, applying existing project formatters (Prettier, Ruff, etc.) automatically. It handles edge cases like partial writes and formatter loops, ensuring code consistency at the point of creation.

工作流

  • Install the 'onwrite' tool via the provided shell script.
  • Run 'onwrite doctor' to verify tool detection and configuration.
  • Wrap generation commands with 'onwrite run -- <command>' to auto-format changed files.
  • Use 'onwrite watch' for monitoring file writes that cannot be wrapped directly.
  • For coding agents, use the hook to notify the agent of formatting changes so it can re-read the updated file.

证据

onwrite run waits for the wrapped command to finish, works out which files it changed, and formats only those files.

来源

The implementation is deliberately cautious. A formatter never receives the real source file. The contents go in through stdin, the result comes back through stdout, and the file is replaced atomically only after the formatter chain has succeeded.

来源

The first release has 87 tests, including partial writes, hanging tools, ignored files and write-loop cases.

来源

  • 记录日期: 2026-09-06T23:22:16.053Z