Create

Sign in to ReadmeX

or

How we handle your data: Privacy Policy

ReadmeX

Your AI reading companion

What would you like to catch up on?

Pick a briefing, or ask your own question.

Your community and people briefings stay personal to you.

Story

Generate AGENTS.md From Repository Facts

AI summary

A report describes a zero-dependency Python script that scans a repository to generate AGENTS.md, identifying languages, entry-point candidates, test files, package manifests, top-level directories, file counts, and a likely test command. Code conventions and prohibited actions remain in fixed templates maintained by people. The script also validates that all five required sections are present, none are empty, and the file is no more than 6,000 characters; the report shows how the validation can run in CI. It recounts two bugs: using match instead of search for test-file patterns, and failing to record the file count when an early return stopped the scan. The suggested workflow is to regenerate after repository structure or test commands change, then review the diff; a pre-commit hook can validate without regenerating.

In-depth insight

The report says a handwritten AGENTS.md became stale after the test command changed, causing Codex to run the wrong command and retry. Generating repository facts from the current structure provides a way to keep those instructions aligned with the codebase, while validation and human review help preserve required sections and conventions.

仓库里那份 AGENTS.md 是去年手写的,写着"测试用 pytest"。那会儿确实用 pytest。

后来前后端共用一套测试脚本,跑法换成了 npm test。AGENTS.md 里那行没人想起去改。于是 Codex 每次要跑测试都先 npm test,报错,再翻 package.json,发现路径不对,重来。一来一回两分钟,一天十几次,谁也没觉得这是个问题,只觉得"这 AI 有点笨"。

问题不在模型。手写的约定文件一定会过期,因为它是从仓库里复制出来的第二份事实。凡是第二份事实,都会漂。

我的做法是这部分别手写,让脚本去仓库里扫。

只写能扫出来的东西

AGENTS.md 里真正有用的就三类:这个仓库是什么语言写的、入口在哪、测试怎么跑。这三样全在文件系统里,不用人记。

#Codex#AGENTS.md

Original · 9 min readRead the original
Group chat

No comments yet. Start the conversation.