Skip to content
Agentmart
Submit a tool

flutter-lib-refactor

Audit and refactor a Flutter project's lib/ folder into a feature-first layered architecture.

Skill by ersanyamarya

IndexedMIT
Write a review

Chalk Labs

Need help deploying flutter-lib-refactor?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/ersanyamarya-flutter-lib-refactor

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Audit and refactor a Flutter project's lib/ folder into a feature-first layered architecture. Use when reorganizing Flutter code, migrating to clean architecture, restructuring lib/, moving screens/providers/models into core/data/features/widgets, or verifying a refactor did not break the app. Triggers: refactor lib, clean architecture, feature-first structure, reorganize flutter, move providers, migrate screens.

Use cases: data, security

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/flutter-lib-refactor

What's inside

Skill name
flutter-lib-refactor
Description
Audit and refactor a Flutter project's lib/ folder into a feature-first layered architecture. Use when reorganizing Flutter code, migrating to clean architecture, restructuring lib/, moving screens/providers/models into core/data/features/widgets, or verifying a refactor did not break the app. Triggers: refactor lib, clean architecture, feature-first structure, reorganize flutter, move providers, migrate screens.
License
MIT
Instructions
97 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Flutter lib/ Refactor Skill

Audits the current `lib/` layout, proposes a migration to a layered, feature-first structure, applies the migration when approved, and verifies the app still builds and tests pass.

Follow the repo's code checklist (see `CLAUDE.md` → "Before Writing Any Code"): a refactor **moves and reuses** existing code — it must not rewrite working code or add new abstractions/dependencies that YAGNI would reject. Prefer moving files over recreating them; only extract a shared file/widget when something is genuinely reused.

## When to Use

- The `lib/` folder has grown organically and needs structural cleanup.
- You want to move from flat folders (`pages`, `providers`, `models`) to `core` / `data` / `features/<feature>` / `widgets`.
- You need to keep the app working while moving files and rewriting imports.
- You want a documented, reversible refactor plan before any file is touched.

## Target Architecture (Default)

```
lib/
├── main.dart
├── core/
│   ├── localization/    # Easy Localization helpers and keys
│   ├── router/          # go_router configuration
│   ├── theme/           # ThemeData + Google Fonts
│   └── utils/           # UUID generators and small helpers
├── data/
│   ├── api/             # Generated API client + Dio interceptors (stubbed today)
│   ├── local/           # Hive CE boxes + SharedPreferences wrappers
│   └── repository/      # App-wide repositories
├── features/
│   └── <feature>/
│       ├── data/        # Feature repositories + models
│       ├── presentation/# Screens/pages for the feature
│       └── providers/   # Riverpod providers for the feature
└── widgets/             # Shared reusable UI components
```

The exact target can be overridden with a JSON or YAML file passed as the skill argument.

## Procedure

1. **Discover current structure**
   - List every Dart file under `lib/`.
   - Read `pubspec.yaml` and note existing dependencies.
   - Build an import graph so we know which files depend on which.
   - Detect current conventions: `pages`, `providers`, `models`, `state`, `data`, `theme`, `router`, `utils`, `mqtt`, etc.

2. **Map files to the target structure**
   - Use heuristics and the import graph to propose a new location for each file.
   - Screens/pages map into `features/<feature>/presentation/`.
   - App-wide state maps into `features/<feature>/providers/` or a shared `core/providers/` if truly global.
   - Models and repositories map into `data/` or `features/<feature>/data/`.
   - Theme, routing, localization helpers, and generic utils map into `core/`.
   - Shared UI components map into `widgets/`.
   - Flag ambiguous files for user review instead of guessing.

3. **Generate a refactor plan**
   - Write `REFACTOR_PLAN.md` in the project root with:
     - Proposed directory tree
     - Every file move
     - Import rewrites required
     - New stub files/directories to create (e.g. `data/api/`)
     - Any files that need manual review
   - Default to dry-run: no files are moved yet.

4. **Get user approval**
   - Show the plan summary and ask the user to approve, edit, or abort.
   - If the user wants edits, update the plan and re-present.

5. **Apply the refactor**
   - Ensure the repo is under git and the working tree is clean (or create a backup branch).
   - Create target directories.
   - Move files with `git mv` when possible.
   - Rewrite Dart imports to match new relative paths.
   - Update or create barrel files (`export` statements) only when safe.
   - Create stub `data/api/` contents with a README explaining where the generated client will go.
   - Update `pubspec.yaml` only if needed packages are missing (do not add API packages until the user supplies an API spec).

6. **Verify the refactor**
   - Run `dart fix --apply`.
   - Run `dart format .`.
   - Run `flutter analyze`.
   - Run `flutter test`.
   - Capture output in `REFACTOR_LOG.md`.
   - If verification fails, report the errors and suggest fixes; do not hide failures.

7. **Report results**
   - Summarize what moved, what was stubbed, and any remaining manual steps.
   - Point to `REFACTOR_PLAN.md` and `REFACTOR_LOG.md`.

## Safety Rules

- Dry-run by default.
- Require a clean git working tree or create a backup branch.
- Never delete source files; only move them.
- Preserve file contents except for import paths.
- Do not auto-apply changes if `flutter analyze` or `flutter test` fails unless the user explicitly opts in.

From ersanyamarya/agentry-labs, MIT.

More from ersanyamarya/agentry-labs

Signals

Stars
0
Forks
0
Open issues
0
Last commit (this folder)
Oct 18, 2026 (12 days ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from ersanyamarya

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get flutter-lib-refactor running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying flutter-lib-refactor?

CallGet help
Cite this page

flutter-lib-refactor skill. Agent Mart. https://agentmart.dev/skills/ersanyamarya-flutter-lib-refactor (last updated 2026-10-24)