|
| 1 | +# Copyright 2025 The Flutter Authors. |
| 2 | +# Use of this source code is governed by a BSD-style license that can be |
| 3 | +# found in the LICENSE file. |
| 4 | + |
| 5 | +# This command will be invoked via: /flutter:modify |
| 6 | + |
| 7 | +description = "Perform a modification of your Flutter or Dart project." |
| 8 | + |
| 9 | +prompt = """ |
| 10 | +We're going to modify some code. |
| 11 | +
|
| 12 | +## Problem specification |
| 13 | +
|
| 14 | +First, prompt the user for a description of what the purpose and details of the modification will be. |
| 15 | +
|
| 16 | +Once the user has specified the description and purpose of the modification, outline the information that you will be collecting before creating the design and implementation plan, and present the list to the user, along with your first question. |
| 17 | +
|
| 18 | +## Collecting Information |
| 19 | +
|
| 20 | +Next, collect remaining information from the user, one question at a time. |
| 21 | +
|
| 22 | +The information you need to collect includes, but might not be limited to: |
| 23 | +
|
| 24 | +- If there are ambiguous elements to the modification, ask the user questions to clarify. When the goal is clear, or the user says to, then move on. |
| 25 | +- Whether to do the work on the current git branch, or a new feature branch. |
| 26 | + - Suggest a branch name, making sure it is a valid git branch name. |
| 27 | +
|
| 28 | +## Initialize workspace |
| 29 | +
|
| 30 | +First, make sure there are no uncommitted changes on the current branch. If there are, notify the user and ask what they would like to do about them before proceeding. |
| 31 | +
|
| 32 | +If the user wants the work done on a new branch, create the branch now. |
| 33 | +
|
| 34 | +## Modification design document |
| 35 | +
|
| 36 | +Develop a **DETAILED** Markdown-formatted design document that follows all of the guidance you have about Dart and Flutter design patterns, rules, best practices, and core principles. Save the design document in MODIFICATION_DESIGN.md in the top directory of the workspace. Feel free to use your available tools to research any aspects of the modification that are unclear. |
| 37 | +
|
| 38 | +The design doc should (at least) include: |
| 39 | +
|
| 40 | +- An overview |
| 41 | +- A detailed analysis of the goal or problem |
| 42 | +- Alternatives considered |
| 43 | +- A detailed design for the modification |
| 44 | +- Any diagrams needed to explain the modification or the design, in Mermaid format. |
| 45 | + - Be sure to put quotes around labels that include special characters (e.g. parenthesis). |
| 46 | +- A summary of the design |
| 47 | +- References to research URLs used to arrive at the design. |
| 48 | +
|
| 49 | +Be sure to **actually fetch and read** the research URLs **before** writing the design document. Do actual web research on the topics that are important to the design. |
| 50 | +
|
| 51 | +You must ask the user to review this design document and they must approve it before you continue on to create the implementation plan. They must review and approve it first because if they ask for any changes, it may affect the implementation plan. |
| 52 | +
|
| 53 | +## Implementation plan |
| 54 | +
|
| 55 | +After getting explicit approval from the user for the MODIFICATION_DESIGN.md document, develop a **DETAILED** Markdown-formatted phased implementation plan of checkboxed tasks that need to be performed in order to finish the modification. Save the implementation plan in MODIFICATION_IMPLEMENTATION.md in the top of the repo. |
| 56 | +
|
| 57 | +The implementation plan should include a section for a "Journal" which will be updated after each phase and contain a log of the actions taken, things learned, surprises, and deviations from the plan. It should be in chronological order. |
| 58 | +
|
| 59 | +The plan should include instructions similar to: "After completing a task, if you added any TODOs to the code or didn't fully implement anything, make sure to add new tasks so that you can come back and complete them later." to prevent leaving tasks unfinished. |
| 60 | +
|
| 61 | +In the first phase of the implementation plan, include: |
| 62 | +- [ ] Run all tests to ensure the project is in a good state before starting modifications. |
| 63 | +
|
| 64 | +The implementation plan should specify after each phase that you should: |
| 65 | +
|
| 66 | +- [ ] Create/modify unit tests for testing the code added or modified in this phase, if relevant. |
| 67 | +- [ ] Run the dart_fix tool to clean up the code. |
| 68 | +- [ ] Run the analyze_files tool one more time and fix any issues. |
| 69 | +- [ ] Run any tests to make sure they all pass. |
| 70 | +- [ ] Run dart_format to make sure that the formatting is correct. |
| 71 | +- [ ] Re-read the MODIFICATION_IMPLEMENTATION.md file to see what, if anything, has changed in the implementation plan, and if it has changed, take care of anything the changes imply. |
| 72 | +- [ ] Update the MODIFICATION_IMPLEMENTATION.md file with the current state, including any learnings, surprises, or deviations in the Journal section. Check off any checkboxes of items that have been completed. |
| 73 | +- [ ] Use `git diff` to verify the changes that have been made, and create a suitable commit message for any changes, following any guidelines you have about commit messages. Be sure to properly escape dollar signs and backticks, and present the change message to the user for approval. |
| 74 | +- [ ] Wait for approval. Don't commit the changes or move on to the next phase of implementation until the user approves the commit. |
| 75 | +- [ ] After commiting the change, if an app is running, use the hot_reload tool to reload it. |
| 76 | +
|
| 77 | +In the last phase of the plan, include steps to: |
| 78 | +
|
| 79 | +- [ ] Update any README.md file for the package with relevant information from the modification (if any). |
| 80 | +- [ ] Update any GEMINI.md file in the project directory so that it still correctly describes the app, its purpose, and implementation details and the layout of the files. |
| 81 | +- [ ] Ask the user to inspect the package (and running app, if any) and say if they are satisfied with it, or if any modifications are needed. |
| 82 | +
|
| 83 | +You must ask the user to review this implementation plan and they must approve it before starting implementation. They must review and approve it before you begin because if they ask for any changes, the changes may affect the implementation. |
| 84 | +
|
| 85 | +## Implementation |
| 86 | +
|
| 87 | +After getting explicit approval from the user for the MODIFICATION_IMPLEMENTATION.md document, begin implementing the plan. |
| 88 | +""" |
0 commit comments