Flutter Agent Plugins

repository·main·Indexed 25 days ago

https://github.com/flutter/agent-plugins

A collection of plugins and MCP server configurations designed to extend AI agent capabilities for Flutter development. It provides specialized 'Agent Skills' for tasks such as testing, architecture, and layout fixing. The repository also includes dart_skills_lint, a tool to validate Agent Skills against official specifications, and a two-tiered evaluation architecture for testing skill quality and consistency.

Tokens
43.7K
Snippets
105
Records
205
Agent score
83%

What's inside Flutter Agent Plugins

  1. Evaluate dart_skills_lint production readiness

    main

    The dart_skills_lint tool is currently in Beta / Tooling Candidate status. It is suitable for internal use by Dart-savvy teams but has the following limitations for production environments:

    • Dependency Requirement: Requires a Dart SDK to be installed (no pre-compiled binaries available).
    • Output Format: Only provides human-readable logs; lacks machine-readable formats like JSON, SARIF, or JUnit XML for CI/CD integration.
    • Suppression: Does not support granular suppression (e.g., // ignore: rule-name) for specific lines.
    • Discovery: Uses a rigid directory mode rather than recursive discovery of SKILL.md files.
    • Extensibility: Rules are hardcoded in the Validator class and cannot be added without a code change.
  2. Understand the Skill Evaluation Architecture

    main

    The evaluation system uses a two-tiered architecture to separate domain-specific skill requirements from universal quality standards.

    1. Per-Skill Evals: Located in <skill_dir>/evals/evals.json. These define specific tasks for a single skill.
    2. Cross-Skill Evals: Located in evals/*_rubric.json. These are modular rubric classes that define universal quality expectations (e.g., code quality) applied across multiple skills.

    Note: These evaluations are unit tests for skills within the dart_skills_lint package and are not intended as a generic framework for external agent plugins.

  3. Understand the `dart_skills_lint` architecture

    main

    The dart_skills_lint tool is designed to validate Agent Skill specifications (typically SKILL.md files). It follows a layered architecture that separates CLI handling, configuration parsing, and validation logic.

    Key Components

    • CLI Entry Point: Handles argument parsing (e.g., --skills-directory), workspace discovery (searching .agents/skills or .claude/skills), and log management.
    • Configuration Parser: Loads custom settings from dart_skills_lint.yaml to manage directory-specific rule overrides and severity defaults.
    • Validation Engine: The core component that scans SKILL.md files using regular expressions to extract Frontmatter and validates directory structures, field constraints, and relative links.
    • Predefined Rules: A collection of global definitions for standard checks using CheckType.
    • Core Data Models: Defines the structure for ValidationError, CheckType, and IgnoreEntry (used for suppressing errors via JSON).
  4. Test CLI applications with integration tests

    main

    Use test_process and test_descriptor to write high-fidelity integration tests that validate filesystem mutations and process execution.

    Testing Workflow:

    1. Define expected filesystem states using test_descriptor (d.dir, d.file).
    2. Create the mock filesystem with await d.Descriptor.create().
    3. Spawn the CLI process using TestProcess.start('dart', ['run', 'bin/cli.dart', ...args]).
    4. Validate stdout and stderr using StreamQueue matchers (e.g., emitsThrough, emits).
    5. Assert the exit code using await process.shouldExit(0).
    6. Validate filesystem changes using await d.Descriptor.validate().
    import 'package:test/test.dart';
    import 'package:test_process/test_process.dart';
    import 'package:test_descriptor/test_descriptor.dart' as d;
    
    void main() {
      test('CLI test example', () async {
        await d.dir('project', [d.file('config.json', '{}')]).create();
    
        final process = await TestProcess.start(
          'dart',
          ['run', 'bin/cli.dart', 'process', '--path', '${d.sandbox}/project']
        );
    
        await expectLater(process.stdout, emitsThrough('Processing complete.'));
        await process.shouldExit(0);
        await d.dir('project', [d.file('config.json', '{}')]).validate();
      });
    }
  5. Best practices and constraints for FFIgen

    main

    When using package:ffigen, adhere to these constraints:

    • Never write manual bindings: If native headers exist, always use FfiGenerator instead of manual DynamicLibrary.lookup or @Native functions.
    • Standard Locations: Place the generator at tool/ffigen.dart. Place third-party headers in third_party/ or src/ at the package root.
    • Output Directory: Generated files for third-party libraries must be placed under lib/src/third_party/.
    • File Extensions: The primary generated FFI bindings file must use the .g.dart extension.
    • Preamble: Always include a preamble in the Output class that specifies the license, includes the native copyright header, and contains an automatic generation warning (e.g., // Generated by package:ffigen. Do not edit manually.).
    • Tree Shaking: To support native asset tree shaking, set recordUse: (_) => true in Functions and specify a recordUseMapping target in Output (e.g., lib/src/third_party/sqlite3.record_use_mapping.g.dart).
  6. Generate LCOV Coverage Reports

    main

    Use the test_with_coverage script to automatically run tests, collect JSON coverage data from the Dart VM, and format it into an LCOV report. This will create a coverage/ directory in your project root containing coverage.json (raw data) and lcov.info (formatted report).

    For standard projects:

    dart run coverage:test_with_coverage

    For Dart workspaces (monorepos), specify the test directories explicitly:

    dart run coverage:test_with_coverage -- pkgs/foo/test pkgs/bar/test
  7. Audit Dart dependencies

    main

    Periodically run an audit to identify stale, retracted, or discontinued packages that may impact stability.

    1. Run dart pub outdated.
    2. Review the Upgradable column for packages that can be updated without modifying pubspec.yaml.
    3. Review the Resolvable column for packages that require constraint modifications in pubspec.yaml to update.
    4. Identify any packages marked as retracted or discontinued.
  8. Resolve Dart Static Analysis Errors

    main

    Use the following sequential workflow to identify, fix, and verify static analysis errors in a Dart project.

    1. Run static analyzer: Identify all static errors.
    2. Apply automated fixes: Use dart fix for standard linting and analysis issues.
    3. Resolve remaining errors manually: Address specific error types (Null Safety, Type Mismatches, or Invalid Overrides) based on logic.
    4. Verify fixes: Run the validator and tests to ensure no new errors or runtime TypeError exceptions were introduced.
    # 1. Run static analyzer
    dart analyze . --fatal-infos
    
    # 2. Apply automated fixes
    dart fix --dry-run
    dart fix --apply
    
    # 4. Verify fixes
    dart analyze .
    dart test
  9. Implement a new feature using the architectural workflow

    main

    Follow these steps sequentially when adding a new feature:

    1. Define Domain Models: Create immutable data classes (e.g., using freezed).
    2. Implement Services: Create classes to handle external API communication.
    3. Implement Repositories: Create the Repository to consume Services and return Domain Models.
    4. Apply Conditional Logic (Domain Layer): Create a Use Case class only if the feature requires complex data transformation or cross-repository logic.
    5. Implement the ViewModel: Create a ChangeNotifier ViewModel. Inject Repositories/Use Cases and expose immutable state.
    6. Implement the View: Create the UI widget. Use ListenableBuilder or AnimatedBuilder to listen to the ViewModel.
    7. Inject Dependencies: Register the Service, Repository, and ViewModel in your DI container (e.g., provider or get_it).
    8. Run Validator: Execute unit tests for the ViewModel and Repository.