Problem/Motivation

As discussed in #3585585#comment-16564365, we should keep a clear boundary between documentation and skills:

Docs are declarative. Skills are procedural.

Drupal.org docs, API docs, change records, module documentation, and local source code should remain the canonical sources for what exists and how it works.

Skills should not become another documentation tree. They should stay thin and tell an agent what to do first, what order to do things in, what to check, which defaults to prefer, and when to escalate.

That creates a practical problem for our system:

  • Package-owned documentation can be useful to agents, but it does not always belong inside a skill.
  • If we put all documentation into skills, we risk duplicating docs and making skills too large.
  • If we put skill-specific supporting docs into a generic docs directory, we lose the connection to the skill that owns them.
  • If every package invents its own AI documentation location, tooling cannot reliably point agents to the right docs.
  • If tooling rewrites all of AGENTS.md, user-owned project instructions can be lost.

So we need a small convention for package-owned agent documentation.

This issue is specifically about documentation that belongs to a Drupal package, module, theme, library, or core, and may be useful across skills, AGENTS.md, or agents in general.

It is not about documentation that is required for one specific skill to work. That should stay with the skill, for example in:

.ai/skills/{skill-name}/references/

The goal is:

Drupal packages can expose package-owned agent documentation in a predictable place, and tooling can update a managed block in AGENTS.md with pointers to those docs.

This follows the same general idea as the current Next.js AI agent guidance: docs stay where they belong, and AGENTS.md tells agents where to read before coding and combines it with https://laravel.com/docs/13.x/boost#third-party-package-ai-guidelines

Proposed resolution

Adopt a two-layer convention:

1. Source convention: Drupal packages may ship package-owned agent documentation context in .ai/docs/

Drupal modules, themes, core, custom module code, and standalone Drupal.org packages may place AI-readable documentation context in:

.ai/docs/

This makes .ai/docs/ the Drupal package source convention for package-owned agent documentation context.

It is tool-neutral and does not imply a specific agent harness.

A Drupal module is usually not primarily a documentation package. It is a Drupal package that may also ship AI-readable context. Using .ai/docs/ makes that clear.

Package-owned documentation context in .ai/docs/ should be:

  • plain Markdown;
  • owned and maintained by the package that ships it;
  • small and focused;
  • specific to the package, module, theme, library, or integration;
  • clear about which sources are canonical;
  • linked to Drupal.org docs, API docs, change records, module docs, examples, or local source where those are the source of truth;
  • not meant to duplicate all documentation.
  • Versioned with the package/module

This convention should not prevent packages from also having normal human-facing documentation.

The .ai/docs/ convention is for extra package-owned agent context when a package wants to provide it.

2. AGENTS.md convention: generate a managed Drupal documentation block

The root AGENTS.md should contain a managed block that tells agents to read installed Drupal package documentation and canonical sources before coding.

Instead of copying documentation into a generated runtime directory, tooling should discover relevant package-owned documentation and update AGENTS.md with pointers to where those docs already live.

For example:

<!-- BEGIN:drupal-agent-docs -->

Drupal: read relevant package docs before coding

Before making Drupal code changes, read the relevant documentation and source files for the installed Drupal packages.

Your training data may be outdated. Prefer the installed codebase, Drupal.org docs, API docs, change records, and module documentation over model memory.

  • web/modules/contrib/ai_best_practices/.ai/docs/best-practices.md
  • web/modules/contrib/group/.ai/docs/subgroups.md

<!-- END:drupal-agent-docs -->

The AGENTS.md file should stay small enough to be useful. It should not contain the full documentation content. It should contain instructions and pointers.

This follows the same idea as the current Next.js pattern: the agent is told where the local, version-relevant docs live before it starts coding.

Only the managed block in AGENTS.md should be updated by tooling.

Users can add project-specific instructions anywhere outside the managed block. Tooling must preserve that content.

Discovery behavior

The tooling should discover package-owned agent documentation context from installed Drupal code and Composer packages using this source convention:

.ai/docs/**/*.md

This should include at least:

  • custom modules and themes;
  • contrib modules and themes;
  • libraries and projects;
  • Drupal core, if core ships documentation context this way later;
  • ai_best_practices/docs itself would then also be included.

The generated AGENTS.md block should group documentation pointers by source package, not just by filename. That should make it easier for agents to understand where the documentation came from.

For example:

  • drupal/core
  • drupal/group
  • drupal/webform
  • custom/my_custom_module
  • drupal/ai_best_practices

Update behavior

When a package updates its package-owned agent documentation context, the consuming project should be able to update the generated AGENTS.md pointers without manual editing. We can just collect all discovered package docs in the project again.

At minimum, this should happen when the user runs a sync command, for example:

composer drupal-ai docs-sync

It could also happen automatically during package install/update when the ai_best_practices Composer plugin is enabled.

The managed block in AGENTS.md should be treated as generated output.

Users should be able to add their own project-specific instructions outside the managed block without those instructions being overwritten.

Documentation

Update the relevant documentation to explain:

  • where maintainers should place package-owned agent documentation context in their module/project source tree;
  • how AGENTS.md is updated with a managed Drupal documentation block;
  • how user-owned project instructions can be added outside the managed block;

This issue should only define the package-owned documentation context source convention and the expected AGENTS.md behavior.

Change record extraction, deprecation notice extraction etc. can build on top of this later.

Remaining tasks

  • Agree that .ai/docs/ is the recommended source layout for package-owned agent documentation context in Drupal packages.
  • Agree that AGENTS.md should contain a generated managed block with pointers to relevant package-owned documentation, or we should aggregate all .ai/docs similar to our skills and point AGENTS.md to that directory
  • Confirm that the generated documentation pointers can be updated during install/update or by a manual sync command.
  • Implement discovery from .ai/docs/**/*.md.
  • Document how maintainers should ship package-owned agent documentation context in modules, themes, core, and standalone packages.
  • What is (is there any?) the different with MCP Resources

Related issues

AI usage note: This issue summary was drafted with AI assistance and reviewed before posting.

Comments

ronaldtebrake created an issue. See original summary.

webchick’s picture

Hmmm. For this one, would we not follow the Agent Skills specification and put this supporting documentation in the references/ subdirectory?

(Once again, not blocking feedback, just asking questions :D)

I’m too tired to debug why that link doesn’t work lol

https://agentskills.io/specification

webchick’s picture

Status: Active » Needs review
webchick’s picture

Ok, I read this in more detail now and I think I see. Docs are not necessarily tied to one or more skills, and a directive like “always read the docs in {folder}” allows us to update things like change records.

I guess I’m trying to see though how this wouldn’t have all of the same complexity as skills, with some docs defined in core, some in contrib module X, some in custom module Y… and need the ability to aggregate and override just the same as well.

Hence I wonder how far we could get by packaging skills + docs together (according to the spec, I agree reference text and procedural text should be separated) so we ideally only have to write and maintain the “source from everywhere, smoosh into one directory (.agents/docs?) following this override logic” mechanism once.

^ if that makes no sense feel free to ignore it is very late lol

ronaldtebrake’s picture

Issue summary: View changes

Ok, I read this in more detail now and I think I see. Docs are not necessarily tied to one or more skills, and a directive like “always read the docs in {folder}” allows us to update things like change records.

Exactly my thoughts! And it would then also be versioned with the module/project itself as a nice bonus.

I guess I’m trying to see though how this wouldn’t have all of the same complexity as skills, with some docs defined in core, some in contrib module X, some in custom module Y… and need the ability to aggregate and override just the same as well.

Hence I wonder how far we could get by packaging skills + docs together (according to the spec, I agree reference text and procedural text should be separated) so we ideally only have to write and maintain the “source from everywhere, smoosh into one directory (.agents/docs?) following this override logic” mechanism once.

Hehe, good point, and thanks for your reviews, even at this time!

I think packaging could work, it even adds value where people have more control over the docs that end up in their project root, and how to deal with overriding. Saving up some context in AGENTS.md as well, as we only have to point to one directory.

The only thing I'm still breaking my brain on is whether or not we are better of using MCP (resources) for most of the use cases, or where the distinction is between these two options. We don't want to have people "misuse" this system, on the other hand given the state of documentation this might be an easy quick win for now.

If I look at https://www.drupal.org/project/ai_best_practices/issues/3585585#comment-16564365 both seem to have value.

I've updated the issue summary with your suggestion and the above concern.

webchick’s picture

Re-reading that excellent comment again, I think I agree that docs living canonically on Drupal.org and then being exposed to agents via MCP is the right (or at least, right-er :)) approach.

Is anyone working on the problem of exposing eg API references, handbook, change notices, etc. to MCP? (The Drupal.org team seems very focused on the GitLab migration atm.)

ronaldtebrake’s picture

I've also just noticed #3587321: Add a Composer plugin that harvests project context and injects a "This project" section into AGENTS.md and it seems they are proposing a same conclusion for a more specific use case.
I'll mark this as duplicate for now, and will mention our discussion in that issue so we can keep the conversation flowing.

Also an accompanying Slack thread https://drupal.slack.com/archives/C0APH70JV18/p1777883655644939

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

webchick’s picture

Interesting note: https://www.linkedin.com/posts/dachary_astro-just-removed-all-of-their-l...

We might need an llms.txt too:

When you swap an llms.txt for an MCP server, you're not making a one-for-one substitution. You're trading two very different agent populations:

- llms.txt works for any agent that can issue an HTTP GET. No installation, no configuration, no platform requirement. The casual agent user, the new developer, the locked-down enterprise environment all get a navigation layer for free.
- An MCP server works for users whose harness supports MCP, who know your specific server exists, and who have configured it. Capable, invested users. A narrower population today.

Both populations exist, but they behave differently.

webchick’s picture

Draft of an issue for Drupal.org to add these things... GULP! :) https://docs.google.com/document/d/14l5BwfqnU4PoPGCbM0OFq49a2jLDZ6lR1goy...