AgentPreview is a Gradle plugin that captures AndroidX Compose @Preview functions into files an AI agent can inspect:
<module>/build/agentPreviewSnapshots/<sanitized-preview-id>/<platform>-<viewport>/
screenshot.png
snapshot.json
Preview ids are sanitized for file paths: :app:main:LoginPreview becomes app-main-LoginPreview, and viewport folders include the platform, e.g. android-phone.
Use it when an agent is editing Compose UI and needs a quick screenshot plus structured preview data without driving the full app.
The plugin is not published yet. Add this checkout as an included build in the target project's settings.gradle.kts:
pluginManagement {
includeBuild("/path/to/AgentPreview")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}Apply the plugin to the Android app/library or Compose Multiplatform module that owns the previews:
plugins {
id("dev.staticvar.agentpreview")
}List previews first:
./gradlew :app:listComposePreviewsCapture previews:
./gradlew :app:captureComposePreviewsFor a focused capture while iterating:
./gradlew :app:captureComposePreviews \
-PagentPreview.previewNameFilter=Login \
-PagentPreview.viewportFilter=phone \
-PagentPreview.maxCaptures=4Outputs are written under:
- snapshots:
<module>/build/agentPreviewSnapshots/<sanitized-preview-id>/<platform>-<viewport>/ - capture report:
<module>/build/agentPreviewReports/capture-report.json
- Detailed setup and agent workflow:
docs/agent-usage.md - Agent workflow skill:
skills/agentpreview-compose-iteration/SKILL.md snapshot.jsonschema:docs/snapshot-schema.md
- Supports Android app/library modules and Compose Multiplatform modules through an Android target.
- Rendering is Android-backed; desktop and web Compose renderers are not separate targets yet.
@PreviewParameteris supported for one annotated user parameter.- Layout-tree source hints are experimental, best-effort, and sometimes missing.
- Fake renderer mode (
-PagentPreview.fakeRenderer=true) is for discovery/debug wiring only; do not judge UI from its placeholder outputs.
MIT. See LICENSE.