SIGN IN SIGN UP

[rules] Add packages/flutter_tools/gradle/AGENTS.md rules (#191486)

This work came in response to pr
https://github.com/flutter/flutter/pull/191218 and a conversation with
@gmackall about how I did not think the new dsl migration counted as
"agentic engineering" because I was not doing the work like we have as
part of project one shot in camera_android_camerax. Really the new dsl
work is a great opportunity to lay out some of the patterns we have
found.

@gmackall to double check the engineering principals and add any others
he thinks are important.
@camsim99 to help review agents.md. @camsim99 we have no skills or
really much documentation so the agents.md file has more primary logic
than I would normally like but I think in this case it is ok.

The purpose is to give agents working on the flutter gradle plugin
guidance for what we consider important and how we want to architect
work.

There are no evals in flutter/flutter so I have not written any. This is
acknowledged technical debt so we can get the benefit of this steering
on follow-up new dsl prs (4-11).

I consider this newDsl pr 3.1. 

- @reidbaker 

---
Agent authored description
## Description

This PR introduces `packages/flutter_tools/gradle/AGENTS.md` following
Jetski's directory-scoped `AGENTS.md` standard. This defines workspace
architectural rules, configuration cache compatibility, and development
practices for the Flutter Gradle Plugin (FGP).

### Key Rules Included:
1. **Zero Pollution of Customer-Facing Build Scripts**: Enforces
consumer build isolation in composite builds (`includeBuild`); forbids
contributor verification tasks or lifecycle hooks
(`check.dependsOn`/`test.dependsOn`) in `build.gradle.kts`, requiring
standard JUnit tests or CI shards instead.
2. **Type-Safe AGP & Gradle API Usage (No `@Suppress`)**: Prohibits raw
wildcard casts and `@Suppress("UNCHECKED_CAST")` when dealing with AGP
domain objects; mandates type-safe APIs and compatibility bridges.
3. **Lazy Configuration & Execution Avoidance**: Prohibits eager
`.get()` during configuration phase; requires Gradle Lazy Provider
chaining.
4. **Strict Configuration Cache Compatibility**: Forbids storing
`Project`, `SourceSet`, or `Configuration` references in task instances.
5. **Build Avoidance & Path Normalization**: Requires
`@PathSensitive(RELATIVE)` or `NAME_ONLY` to maximize local and remote
cache hits across machines.
6. **Worker API for Heavy Computation**: Decouples heavy computation,
parsing, and tooling execution to non-blocking worker threads.
7. **Namespace & Environment Hygiene**: Enforces `flutter.internal.`
property prefixing and full matrix verification across supported
AGP/Gradle versions.
8. **Scope & Legacy Code Policy (The Ratchet Principle)**: Enforces
compliance on all new and modified code while preventing unapproved
scope expansion on legacy code, while instructing agents to surface
adjacent improvement opportunities to the user.

## Related Issues
- Related to FGP architecture, AGP 8/9 compatibility, and Jetski agent
directory rules.

## Tests
- Documentation and rule file only (test-exempt).

## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] All existing and new tests are passing.

---------

Co-authored-by: Reid Baker <1063596+reidbaker@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
R
Reid-Agent committed
7c25794b41a050689bff2399829990f530e61199
Parent: 3479680
Committed by GitHub <noreply@github.com> on 8/21/2026, 7:03:05 PM