app-context
Skill0 starsChanged 4 days agoMITView on GitHub
How the assistant knows what is on screen, through the screen-context table keyed by route, bounded summaries, selection reporting, and navigation only through the navigate action. Use when adding a route, changing what a screen shows, or making the assistant aware of a selection.
In this repository29 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- accessibilitySkill
- actionsSkill
- adding-a-featureSkill
- agent-workflowSkill
- approval-and-safetySkill
- backend-proxySkill
- background-workSkill
- build-an-appSkill
- capture-learningsSkill
- clean-architectureSkill
- customizing-the-assistantSkill
- delegate-to-agentSkill
- edit-boundariesSkill
- i18n-and-rtlSkill
- model-providersSkill
- performanceSkill
- permissions-and-platformSkill
- read-the-docsSkill
- reliable-mutationsSkill
- routingSkill
- secretsSkill
- state-managementSkill
- storing-dataSkill
- testingSkill
- ui-designSkill
- upgrade-the-frameworkSkill
- verifySkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
Don't load this for the actions themselves or for what the assistant may do without asking.
- Very specific: line 12
Every route has one entry in buildScreenContexts in lib/ai/screen_contexts.dart, keyed by its route pattern (/, /settings).
- Very specific: line 21
Every message carries a <current-screen> block: {"navigation": {"route", "location", "params", "selectedIds"}, "screen": {...}}.
- Very specific: line 25
Add the entry next to the others.
- Distinctive: line 51
Run the app, open the screen and ask the assistant what it sees.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
App context
Don't load this for the actions themselves or for what the assistant may do without asking; see actions and approval-and-safety.
Rule
- Every route has one entry in
buildScreenContextsinlib/ai/screen_contexts.dart, keyed by its route pattern (/,/settings). - An entry returns a short summary of what the screen shows: counts plus the first rows, ids always, never a key or secret.
- A screen with a selection reports it through
AppContext.setSelection. - The assistant moves between screens only with the
navigateaction.
Enforced by test/ai/parity_test.dart (a route without an entry, or an entry matching no route, fails it). Summary size and content are not checked.
Why
Every message carries a <current-screen> block: {"navigation": {"route", "location", "params", "selectedIds"}, "screen": {...}}. The screen part comes from your entry. Small models have little context, so a summary has to be short; ids let the model act on rows with update_item instead of guessing.
How
Add the entry next to the others. ScreenContext takes a function from the navigation state to a map, sync or async:
<!-- @example:begin -->/inlib/ai/screen_contexts.dartreadsgetItems(limit: _visibleRows)(10) andgetItemCount(), and returnstotal, a list of{id, title, description}(cut short), anoteandselectedIds. The total shows what the list leaves out.
<!-- @example:end -->/settingsreads providers, not the database, and reports the model preset and whether it is configured, never the key.- A screen with nothing to report uses
const ScreenContext.nothing().
Selection. The home screen's provider in lib/presentation/providers/items_provider.dart calls getIt<AppContext>().setSelection(...) on every change. Do the same wherever a person can pick rows, so "delete these" works.
Navigation. lib/ai/go_router_adapter.dart keeps the route, location and params in step with GoRouter and connects the navigate action to router.go. The assistant never calls context.go or setNavigation; navigate fails with unknown_route for a location that matches no table key. List the screens in assets/assistant/instructions.md.
A view that takes longer than AppContext.viewTimeout (2 s) is cut off, so read local data only.
Anti-patterns
- Dumping a whole table into the summary.
- Rows without ids.
- Putting an API key, token or setting's secret value in a summary.
- A route added to
lib/utils/routes/app_router.dartwith no table entry. - Calling
setNavigationfrom a screen. - Letting the assistant reach a screen by any path other than
navigate.
Verification
test/ai/parity_test.dartfor route coverage;test/ai/screen_contexts_test.dartfor the entries;test/ai/go_router_adapter_test.dartfor the adapter.- Run the app, open the screen and ask the assistant what it sees.
tool/check.shends withAll checks passed.
Related skills
adding-a-feature— the whole checklist this entry is part of.actions— the actions a model uses with the ids you report.approval-and-safety— keeping secrets out of what the model sees.routing— adding the route the entry belongs to.performance— keeping screen summaries small.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

