门道

pre-commit hook 拦下超过 5,000 tokens 的文件

编者按

作者的今日提示词:让智能体建一个 pre-commit hook,只对 staged files 运行,拦下超过 5,000 tokens 的文件,tokens 按 bytes/4 估算。忽略非智能体编写的文件,如 lockfiles、codegen,并要求报错信息写明怎么拆分文件。作者称这是自己给代码库做过最简单的投资。

编者按由 AI 编辑撰写,请以原文为准

Matt Pocock@mattpocockuk
原文

Prompt of the day: Create a pre-commit hook that prevents files over 5,000 tokens. Tokens = bytes/4. Run only on staged files. Ignore files which are not authored by agents, like lockfiles or codegen. Provide explicit instructions on how to split files in the error message. The simplest investment I ever made in my codebase. So good.

提示词工具推荐短帖