feature-locale

feature-locale is a cursor rule for Cursor from sampaio-tech/flutter-core-modules. It costs 0 tokens per session (786 once invoked), scanned A, original, MIT.

A set of rules for the locale feature in a Flutter package, covering saved language choices, use cases, repositories, and how another app should add reactive state or a language picker.

In plain words
What is it for?
Use it when reading, saving, resetting, or extending language-selection code, including SharedPreferences persistence and integration in a consuming app.
Why use it?
It prevents duplicate implementations by identifying which locale operations already exist and clarifies that the package does not provide locale UI or reactive state.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/sampaio-tech/flutter-core-modules/feature-locale
Clone the repo
git clone --depth 1 https://github.com/sampaio-tech/flutter-core-modules

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for feature-locale

README.md
[![agentmods](https://agentmods.dev/badge/rules/sampaio-tech/flutter-core-modules/feature-locale.svg)](https://agentmods.dev/rules/sampaio-tech/flutter-core-modules/feature-locale)
Your own site
<a href="https://agentmods.dev/rules/sampaio-tech/flutter-core-modules/feature-locale"><img src="https://agentmods.dev/badge/rules/sampaio-tech/flutter-core-modules/feature-locale.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 786 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00786
Opus 5 $0.00000 $0.00393
Sonnet 5 $0.00000 $0.00157
Haiku 4.5 $0.00000 $0.00079

Measured 3d ago against content hash 32607c2d7d5a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

feature-locale scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/feature-locale.mdc · 95 lines

How it starts

The opening of the file, as written. The whole thing — 95 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Feature: Locale — Rules

What Is Already Implemented — Check Before Building

Capability Status
Persist locale to SharedPreferences SetLocaleUsecase — do NOT reimplement
Read persisted locale (sync) GetLocaleUsecase — do NOT reimplement
Remove persisted locale (reset to system) RemoveLocaleUsecase — do NOT reimplement
Debug/prod key separation DatabaseKeys.locale — automatic
Reactive locale StateNotifier ❌ Not in package — implement in consuming app following ThemeStateNotifier pattern
Locale picker UI ❌ Not in package — implement in consuming app

Before adding locale-related code, check if the above use cases already satisfy the requirement.


Layer Structure

lib/src/features/locale/
├── domain/
│   ├── repositories/locale_repository.dart      # abstract LocaleRepository
│   └── usecases/
│       ├── get_locale_usecase.dart
│       ├── set_locale_usecase.dart
│       └── remove_locale_usecase.dart
└── data/
    └── repositories/locale_repository.dart      # LocaleRepositoryImpl + provider

There is no presentation/ layer — locale has no UI in this package.


Correct Usage Patterns

Reading locale on app start (sync)

// Read once; null means user has not selected a locale (use system locale)
final savedLocale = ref.read(getLocaleUsecaseProvider)(); // Locale?

Persisting a locale change

final setLocale = ref.read(setLocaleUsecaseProvider);
await setLocale(locale: const Locale('pt', 'BR'));

Resetting to system locale

await ref.read(removeLocaleUsecaseProvider)();

Wiring into CupertinoApp / MaterialApp

CupertinoApp(
  locale: savedLocale,       // null = let the OS decide
  supportedLocales: const [Locale('en'), Locale('pt', 'BR')],
  localizationsDelegates: const [...],
)

Reactive locale (consuming app, not this package)

Follow the ThemeStateNotifier pattern — create a LocaleStateNotifier extends SafeStateNotifier<Locale?> in the consuming app that wraps the use cases.

Read the full file on GitHub · 95 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 95 lines · 0 tokens per session scan A 32607c2d7d5a

Subscribe to this mod's changes

feature-locale is a cursor rule published in the GitHub repository sampaio-tech/flutter-core-modules (2 stars, last pushed 12d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 786 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.