| name | manage-commits |
| description | Use when working with a skill for creating, amending, formatting, and uploading commits in the AndroidX frameworks/support project |
| metadata | {"author":"androidx"} |
Manage Commits Skill (AndroidX)
Enforces AndroidX conventions for formatting, updating APIs, drafting commit messages, and uploading changes in frameworks/support. Follow steps in order.
Steps
0. Workspace Preparation & Branching
AndroidX development in the frameworks/support directory uses Git and the Repo tool.
- Ensure you are in the correct workspace directory (
frameworks/support/).
- Ensure you are on a working branch.
- Start branch:
repo start <branch_name> ..
- You can start a branch even with existing uncommitted changes.
1. Analyze Changes (Initial Status)
Identify modified or added files to know what needs formatting and API updates.
- Identify changed and untracked files:
git status
- Note modified
.kt, .ktx, .java files, and potential public API changes.
2. Format Code, Run Lint, and Update APIs
Format modified files, run lint, and update public APIs using the list from Step 1.
-
Kotlin Formatting:
-
Java Formatting:
-
Markdown Files:
- There is no automatic formatter for Markdown (
.md) files.
- You must remove trailing whitespaces (spaces or tabs at the end of lines) in modified
.md files before committing.
- Run the following command to remove trailing whitespaces:
-
Public API Tracking:
-
Lint:
3. Review Final Diff
Review the final clean state of the changes (including formatting and API updates) before drafting the commit message.
- Review the full diff of all uncommitted changes:
git diff
Or for staged changes: git diff --staged
- Verify only intended changes are included.
4. Draft Commit Message & Handle Tags
Write a clear commit message adhering to conventions based on the final diff, and group all tags in a contiguous block at the very end.
-
Subject: Concise imperative summary (e.g., "Fix Popup positioning offset bugs"), <100 characters.
-
Body: Explain why changes were made (rationale/background), not just what changed. Separate from subject with a blank line.
-
Test: tag (REQUIRED):
- AndroidX is a test-first repository. Almost all meaningful code changes should include new or updated tests.
- Every commit MUST have a
Test: stanza detailing how it was verified. This should describe the test that validates the behavior changed.
- Provide exact test command:
Test: ./gradlew :compose:ui:ui:connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=androidx.compose.ui.window.PopupTest
- If tests aren't applicable (e.g., docs), provide a clear rationale:
Test: markdown file change only
- NEVER use
none or N/A.
-
Bug: or Fixes: tag:
- For Buganizer issues (provided by the user):
- Use
Fixes: <bug_id> for full resolution.
- Use
Bug: <bug_id> for partial/tracking.
- Use the integer ID only (e.g.,
484057256). Do not include the b/ prefix.
- Ask the user for bug ID if not provided, or ask user to make one, keep no bugs to a minimum
-
Relnote: tag:
- Required for changes in release artifacts (source files under
src/main/, src/commonMain/, or src/androidMain/, excluding buildSrc/).
- This must be a one-sentence description of the public API change or observable behavior change to a library. Note that relnotes must be specific about the observable changes from the CL that a developer may see.
- Format:
Relnote: "Developer-friendly release note" (quotes recommended if it has special characters).
- Omit entirely if not applicable (e.g., tests, tooling, docs).
- Use
Relnote: N/A only to bypass presubmits for minor source-only changes that don't need a public note.
-
Sample Commit Message
Here is an example of a complete, correctly formatted commit message:
Fix: Avoid redundant recomposition in LazyColumn animations
This change optimizes LazyColumn to prevent unnecessary recompositions
when item animations are playing. Previously, even if only the offset
of an item was changing due to animation, a full recomposition was
triggered. By separating the animated offset from the layout pass,
we can achieve smoother animations with less overhead.
Test: ./gradlew :compose:foundation:foundation:connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=androidx.compose.foundation.lazy.LazyColumnAnimationTest
Relnote: Improved performance of LazyColumn animations by reducing redundant recompositions.
Fixes: 298765432
Change-Id: Iabcdef1234567890abcdef1234567890abcdef12345
5. Commit, Best Practices & Upload
Once uploaded successfully, present the Gerrit URL to the user and explain that Treehugger presubmit checks will run automatically on the Gerrit change page.
6. Presubmit Triggering & Monitoring
After committing changes locally, the agent should coordinate verification and upload:
-
Pre-Upload Verification:
-
Post-Upload Monitoring:
Source: androidx/androidx — distributed by TomeVault.