Skip to content

Conversation

@mcmire
Copy link
Contributor

@mcmire mcmire commented Jan 28, 2026

Explanation

As more and more people use AI tools at the company, we need to make sure that generated code follows the standards that we want engineers to follow as well.

AGENTS.md is a standard that is used by many AI agents (Cursor, Claude Code, etc.). This commit introduces a basic version that describes how the monorepo is structured, how to perform various tasks, and what kind of guidelines to follow.

References

https://consensyssoftware.atlassian.net/browse/WPC-79

Testing

To test these agent rules, I had AI create a controller package. You can see the results here: 88bde44. The only tweaks I made after the initial generation was to fix lint errors, everything else is coming straight from AI.

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Low Risk
Low risk: this PR only adds documentation and does not change runtime code, build output, or dependencies.

Overview
Adds a new AGENTS.md document with repo-specific guidance for AI agents, covering monorepo structure, common Yarn commands (testing/linting/building), changelog expectations, and coding standards for packages/controllers/data services.

Written by Cursor Bugbot for commit 9dc59fc. This will update automatically on new commits. Configure here.

As more and more people use AI tools at the company, we need to make
sure that generated code follows the standards that we want engineers to
follow as well.

`AGENTS.md` is a standard that is used by many AI agents (Cursor, Claude
Code, etc.). This commit introduces a basic version that describes how
the monorepo is structured, how to perform various tasks, and what kind
of guidelines to follow.
@mcmire mcmire force-pushed the add-agents-config branch from 2108113 to cfb4857 Compare January 28, 2026 18:03
@mcmire mcmire marked this pull request as ready for review January 28, 2026 18:28
Copy link
Contributor

@cryptodev-2s cryptodev-2s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, I left a few minor suggestions. We can follow up by adding a “skills” section to each of the existing pattern docs (Data Service, Selectors, etc.).

Comment on lines 34 to 38
### Configuration files

The monorepo uses a hierarchical configuration approach for different tools:

### Contributing teams and codeowners
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Configuration files
The monorepo uses a hierarchical configuration approach for different tools:
### Contributing teams and codeowners
### Configuration files
The monorepo uses a hierarchical configuration approach for different tools. Root-level config files define shared settings, while package-level files extend or customize them.
#### Contributing teams and codeowners

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated here: 75a2174

AGENTS.md Outdated

- Run `yarn workspace <package-name> run <script>` to run a package script within a package.
- Run `yarn workspace <package-name> exec <command>` to run a command within a package.
- Run `yarn workspace foreach --all run <script>` to run a package script across all repos.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Run `yarn workspace foreach --all run <script>` to run a package script across all repos.
- Run `yarn workspace foreach --all run <script>` to run a package script across all packages.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated here: 75a2174

AGENTS.md Outdated
- Run `yarn workspace <package-name> run <script>` to run a package script within a package.
- Run `yarn workspace <package-name> exec <command>` to run a command within a package.
- Run `yarn workspace foreach --all run <script>` to run a package script across all repos.
- Run `yarn workspace foreach --all exec <command>` to run a command across all repos.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Run `yarn workspace foreach --all exec <command>` to run a command across all repos.
- Run `yarn workspace foreach --all exec <command>` to run a command across all packages.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated here: 75a2174

AGENTS.md Outdated
- Run `yarn workspace foreach --all run <script>` to run a package script across all repos.
- Run `yarn workspace foreach --all exec <command>` to run a command across all repos.
- Run `yarn run <script>` to run a package script defined in the root `package.json`.
- Run `yarn exec <command>` to run a command available at the root of the project.
Copy link
Contributor

@cryptodev-2s cryptodev-2s Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: might be worth adding a note on how to add a dependency too.

Suggested change
- Run `yarn exec <command>` to run a command available at the root of the project.
- Run `yarn exec <command>` to run a command available at the root of the project.
- Run `yarn workspace <package-name> add <dependency>` to add a dependency to a specific package.
- Run `yarn workspace <package-name> add -D <dependency>` to add a dev dependency to a specific package.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Updated here: 75a2174

- Run `yarn workspace <package-name> run jest --no-coverage <file>` to run a specific test file.
- Prefer the above two commands, but if you must, run `yarn test` to run tests for all packages in the monorepo.

### Linting and formatting
Copy link
Contributor

@cryptodev-2s cryptodev-2s Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: should we add a short section here about CI?

Suggested change
### Linting and formatting
### Continuous integration
Pull requests trigger automated checks including:
- **Lint** — Runs ESLint and Prettier to check code quality and formatting.
- **Tests** — Runs Jest tests across affected packages.
- **Type checking** — Ensures TypeScript compiles without errors.
- **Changelog validation** — Verifies changelog entries are properly formatted.
Ensure all checks pass locally before pushing changes.
### Linting and formatting

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Cursor tends to handle linting and typechecking automatically without my having to tell it what to do. (Claude Code I'm not sure about.)

That said, you're right that there are some missing instructions in the "General development workflow" section. I've added some more words there: 75a2174

AGENTS.md Outdated

### Controllers

When adding or updating controllers in packages, make sure to abide by the guidelines in `docs/controller-guidelines.md`. Use `SampleGasPricesController` and `SamplePetnamesController` in the `sample-controllers` package as examples for implementation and tests.
Copy link
Contributor

@cryptodev-2s cryptodev-2s Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: maybe worth expanding this a bit more, then we can add “skills” for each of these later.

Suggested change
When adding or updating controllers in packages, make sure to abide by the guidelines in `docs/controller-guidelines.md`. Use `SampleGasPricesController` and `SamplePetnamesController` in the `sample-controllers` package as examples for implementation and tests.
When adding or updating controllers in packages, make sure to abide by the guidelines in `docs/controller-guidelines.md`. Key patterns include:
- Controllers extend `BaseController` and use a messenger for inter-controller communication.
- Actions and events should be explicitly typed on the controller's messenger.
Use `SampleGasPricesController` and `SamplePetnamesController` in the `sample-controllers` package as examples for implementation and tests.

Copy link
Contributor Author

@mcmire mcmire Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that Cursor was basically able to read sample-controllers and figure out what to do. That said, it couldn't hurt. I added some controller guidelines here: 75a2174

AGENTS.md Outdated

### Services

When adding or updating services in packages, use the `sample-gas-prices-service/` directory in the `sample-controllers` package as examples for implementation and tests.
Copy link
Contributor

@cryptodev-2s cryptodev-2s Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: maybe worth expanding this a bit, feel free to update it.

Suggested change
When adding or updating services in packages, use the `sample-gas-prices-service/` directory in the `sample-controllers` package as examples for implementation and tests.
When adding or updating services in packages, follow these patterns:
- Services encapsulate external API calls and data fetching logic.
- They should be stateless and injectable into controllers.
- Use dependency injection to allow mocking in tests.
Use the `sample-gas-prices-service/` directory in the `sample-controllers` package as examples for implementation and tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that Cursor was basically able to read sample-controllers and figure out what to do. That said, it couldn't hurt. I added some (data) service guidelines here: 75a2174

cryptodev-2s
cryptodev-2s previously approved these changes Jan 28, 2026
Copy link
Contributor

@cryptodev-2s cryptodev-2s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mcmire mcmire enabled auto-merge January 28, 2026 22:31
@mcmire
Copy link
Contributor Author

mcmire commented Jan 28, 2026

We can follow up by adding a “skills” section to each of the existing pattern docs (Data Service, Selectors, etc.).

Agreed!

github-merge-queue bot pushed a commit to MetaMask/snaps that referenced this pull request Jan 29, 2026
Add AGENTS.md file with instructions for AI agents that operate on the
repository. The goal is to outline our requirements for feature
development and any quirks in using the repo.

Mostly written by Claude as an experiment, but with edits and guidance
from myself. Also with inspiration from
MetaMask/core#7765

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Low risk: documentation-only addition plus a small `lint-staged`
pattern tweak that only affects formatting behavior for `CLAUDE.md`. No
runtime or package code changes.
> 
> **Overview**
> Adds `AGENTS.md`, a repository guide for AI coding agents covering
stack/tooling, monorepo conventions, build/test/lint commands, changelog
requirements, and high-level Snaps platform architecture/naming
guidelines.
> 
> Adds `CLAUDE.md` pointing to `AGENTS.md`, and updates `lint-staged` in
`package.json` to exclude `CLAUDE.md` (alongside `CHANGELOG.md`) from
Prettier formatting.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
4ade350. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com>
@mcmire mcmire closed this Jan 29, 2026
auto-merge was automatically disabled January 29, 2026 14:15

Pull request was closed

@mcmire mcmire deleted the add-agents-config branch January 29, 2026 14:15
@mcmire
Copy link
Contributor Author

mcmire commented Jan 29, 2026

Oops, I thought I merged this 😂

@mcmire mcmire restored the add-agents-config branch January 29, 2026 18:38
@mcmire mcmire reopened this Jan 29, 2026
@mcmire mcmire enabled auto-merge January 29, 2026 18:51
Copy link
Contributor

@cryptodev-2s cryptodev-2s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mcmire mcmire added this pull request to the merge queue Jan 29, 2026
Merged via the queue into main with commit 6282894 Jan 29, 2026
306 checks passed
@mcmire mcmire deleted the add-agents-config branch January 29, 2026 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants