AGENTS.md - contribution guide for LLMs - #9895
Conversation
Give AI agents and human contributors one authoritative set of rules for working in this repository. * Capture the contribution and coding conventions in AGENTS.md, covering scope discipline, code style, code comments, wikitext conventions, backwards compatibility, tests, security, and the pull request and commit workflow. * Point the Claude Code and Gemini CLI tools at AGENTS.md so each agent reads the same guidance instead of a separate copy that could drift. * Keep AGENTS.md as the single place to update when the rules change, so the tool files stay thin pointers. * Link the Contributing tiddler to AGENTS.md and align its wording, so the human and agent contribution docs stay consistent.
✅ Deploy Preview for tiddlywiki-previews ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Confirmed: pmario has already signed the Contributor License Agreement (see contributing.md) |
|
|
Despite the content you provide is useful, why not using exising code of conduct.md / contributing.md , but use a new separate file AGENTS.md? LLM agent could still read existing md files. I'm not against your content, I'm thinking as TiddlyWiki, we could even have our own way to organize prompts. In my own game projects, I directly used the wiki as source of prompt, not MD. Perhaps we could simply use a new wiki edition for code of conduct + contributing + AGENTS. And I think the problem now is the speed of review and merge and testing, not the speed of generating new PR. I have long time not have my feature PRs merged. And our long wating translating framework and alternative store and LLM utils are still pending. If so, I could even donate some of my spear token to auto review the PRs based on those prompt. I have plenty of them, and even have free local deployed Deepseek, Minimax, and Gama at nighttime (US day time). |
|
TLDR; The AGENTS.md file in this PR has proven to work in a strong way. So the instructions there are like a LLM configuration, that should give us better code inline comments and especially better commit messages. I am sure it can be improved, but it has to be tested first, to get feedback.
The current .MD files in the repo root are fake. They are rendered HTML, which is not very useful for LLM's as configurations. They use much more tokens to be processed. LLMs like to read line per line and search for patterns like # headings. AGENTS.md is loaded only once at LLM session startup. So it only uses tokens once and LLM tools are designed to keep those instructions in permanent configuration memory. So they are strongly followed. Every other .md or .tid file that you point to in conversations, are weak and will or will not be followed in a consistent way. See: TLDR; |
|
Hi @pmario @linonetwo I made a mistake in #9894 by using a later, incomplete version of the AGENTS.md that I had been working on. I was investigating ways use TW transclusion to allow a single source of truth. |
|
I have had GREAT success actually writing AGENT "instructions" IN Tiddlywiki5 wikitext grammar. All the current AIs have been trained on TW as its open source, but the signals get buried in all the "oatmeal texture" of all-human-language-projected-on-top-of-itself. I have "claimed" a new macro/procedure namespace for all my "AI grammar", And I can say things like "Examine this poem at <<~ aperture(5) >>" VS "Examine this poem at <<~ aperture(20) >>" and get DISTINCTLY different results that match the definitions I provided. The bots accept LIVE grammar, you can make typos or use "pidgin" and they're try their best to adapt/understand. I also have a formal set of these that I use in the wikis with custom parsers. Another example:
|
|
I'll read the currently proposed AGENTS.md(s) and give more direct feedback later today. |
Make each AGENTS.md rule state its requirement level, and extend the testing and branch guidance. * Mark every rule with MUST, SHOULD, or MAY so agents can tell absolute rules from strong defaults. * Document the quick-test.js fast spec runner for Windows and quick iteration, which skips the slow build render step. * Note that out-of-order documentation changes belong on the tiddlywiki-com branch. * Fix the stale usage comment in quick-test.js to use the current filename.
Match each rule's RFC 2119 keyword to its true weight, and make conciseness an explicit target. * Downgrade quality and workflow rules from MUST to SHOULD so MUST marks only the non-negotiable ones. * Keep the marketing and filler ban at MUST NOT, since terse output is the point of these rules. * Add a concrete conciseness target: assume a first draft can lose up to 30 percent.
|
@Jermolene @joshuafontany ... See the last 2 commits.
@Jermolene I think we should merge it, so LLM users can use it from now on. We'll see what happens to the inline commments and commit messages. |
Require agents to deliver already-trimmed drafts: authors often approve unread, so review is a veto gate, not an editing pass. * Upgrade the trim rule to MUST and anchor it before the draft goes into commit-msg.md
joshuafontany
left a comment
There was a problem hiding this comment.
Looks good, we can iterate once we see how this affect behaviors.
|
|
||
| ## Scope discipline | ||
|
|
||
| - You SHOULD do exactly what was asked, and SHOULD NOT expand scope, refactor unrelated code, or "improve" things nobody requested |
There was a problem hiding this comment.
Lines like this make me wonder about the scope of this file. I would see the above line as something that's between a user and their LLM. We shouldn't be prescribing how they work together. Or perhaps it could be seen as part of the checklist we use to validate PRs
There was a problem hiding this comment.
AGENTS.md is for all LLM rules. The current focus it creating better comments and PR messages.
But imo this one is important to save tokens, if you have to pay for them. LLMs tend to "run away" and deal with or think about stuff that has never been permitted.
The rule uses SHOULD and SHOULD NOT ... So LLMs still have a lot of room to be "creative". But they tend to "run away" less often.
|
|
||
| - You SHOULD do exactly what was asked, and SHOULD NOT expand scope, refactor unrelated code, or "improve" things nobody requested | ||
| - One pull request SHOULD make one logical change. Open a consultation issue before investing time in a large PR | ||
| - Before creating a file or tiddler, you MUST check whether it already exists. If it does, read it and get confirmation before overwriting |
There was a problem hiding this comment.
Creating a tiddler is creating a file in this context
There was a problem hiding this comment.
An MCP server has direct access to the $tw.wiki structure and does not necessarily crate a file first. It can directly create tiddlers, that are then synchronised back to the filesystem and the browser store. So the LLM needs to check both, the filesystem and any other system that can create tiddlers.
| - You SHOULD do exactly what was asked, and SHOULD NOT expand scope, refactor unrelated code, or "improve" things nobody requested | ||
| - One pull request SHOULD make one logical change. Open a consultation issue before investing time in a large PR | ||
| - Before creating a file or tiddler, you MUST check whether it already exists. If it does, read it and get confirmation before overwriting | ||
| - Before editing documentation tiddlers, you MUST check `git status` / `git diff` first so you do not overwrite edits made by a human |
There was a problem hiding this comment.
This seems to restate line 13
There was a problem hiding this comment.
That's a guard against trap I fell into several times.
LLMs keep a local cache of files, that where read in the past conversation. If I did change and commit some of those files, they where overwritten with the cached content. That causes extremely hard to find problems.
Without this line telling the LLM, it needs to check git status first, this happened quite frequently.
After I did add this rule, LLMs usually tell me that there have been changes "out of order" and it asks what to do, instead of silently overwriting user changes.
|
Thanks @pmario. Can we test this AGENTS.md? Sat by producing PRs with and without it? |
|
We already have detailed documentation guidelines in https://github.com/TiddlyWiki/TiddlyWiki5/tree/master/editions/tw5.com/tiddlers/styleguide. Is it possible to transclude that information into AGENTS.md? |
Do you want to change the scope of AGENTS.md? -- Or is your goal to create AGENTS.md from TW wikitext source? Currently AGENTS.md defines coding styles for LLMs (~2600 tokens). It complements the wikitext documentation guidelines. The 10 tiddlers in the TW style guide directory contain about 6500 additional tokens, with a lot of tables and documentation macros. Those macros and tables do not really have value for LLMs. So, to be used for LLMs we should create one summary tiddler instead of 10. This summary tiddler can be transcluded into AGENTS.md. But we should keep the source tiddlers separate. Because: AGENTS.md now uses RFC 2119 style. Eg: The question is: Should AGENTS.md also contain rules, how to create TW prose and reference documentation. I think that change will more than double the size. I estimate about 6000 tokens in sum, instead of ~10k if we blindly merge AGENTS.md and the wikitext documentation guidelines in full. Currently we have no convenient way to "render" wikitext into .md text files. Currently our rendered .md's are HTML files in reality. LLM .md files have to be markdown, to be easily extendable and readable by humans too.
|
|
BTW: LLMs have their own syntax to transclude files, which is directly comparable to TWs transclusion. It's a real text substitution on the same level as the "calling" file. It consumes tokens immediately.
In contrast there are reference listings. Usually in README.md or index.md files. Those files are like table of contents listings, containing references and descriptions.
Those links only consume tokens if they are read on demand. LLMs are relatively good at knowing when to read those links. ... ConclusionI think we should start small and start with this "handcrafted" AGENTS.md to have something that, in my opinion, adds value for contributors and maintainers. Creating text/markdown |
Replace the percentage trim target with rules that catch what a first draft actually carries * Ask for a cut of more than half, since a percentage target is met while the text is still twice as long as it should be * Cut any sentence the reader already has in the linked issue, the diff, the code comments, or the review thread * Drop section headings and pre-emptive defence of unquestioned decisions from PR descriptions
This is a tested alternative to: Improving the quality of LLM generated PRs with an AGENTS.md #9894
The text below is an example, that was created using the AGENTS.md file from this PR.
The PR title has also been created using the same settings.
Give AI agents one authoritative set of rules for working in this repository.
I can explain every single line in the agents.md file and describe which issue it solves. It is useful for Windows developers, that also use unix environments to run and test TiddlyWiki.