Skip to content

Commit 3295d05

Browse files
adalpariclaude
andauthored
Add run-app skill for Claude Code (#22647)
* Add run-app skill for Claude Code Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Improve run-app skill robustness - Poll sys.boot_completed after adb wait-for-device - Snapshot device list to resolve new emulator serial - Use dynamic APK path discovery instead of hardcoded filename Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent dd30b6b commit 3295d05

1 file changed

Lines changed: 128 additions & 0 deletions

File tree

.claude/skills/run-app/SKILL.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
---
2+
name: run-app
3+
description: >
4+
Build and run the Jetpack Android app on a device or emulator.
5+
This skill should be used when the user asks to run the app,
6+
launch the app, or invokes /run-app.
7+
---
8+
9+
# Run App
10+
11+
Build and run the Jetpack wasabi debug variant on a connected Android
12+
device or emulator. By default this skill builds and runs the
13+
**Jetpack** app. Only build the WordPress app if the user explicitly
14+
asks for it.
15+
16+
## Steps
17+
18+
### 1. Build the app
19+
20+
By default, build the Jetpack wasabi debug variant:
21+
22+
```bash
23+
./gradlew assembleJetpackWasabiDebug
24+
```
25+
26+
If the user explicitly asks for the WordPress app instead, run:
27+
28+
```bash
29+
./gradlew assembleWordPressWasabiDebug
30+
```
31+
32+
### 2. Check for connected devices
33+
34+
List all connected/running devices and emulators:
35+
36+
```bash
37+
adb devices -l
38+
```
39+
40+
Parse the output to identify running devices. Ignore the header line
41+
and any lines that do not contain a device serial.
42+
43+
### 3. Determine which device to target
44+
45+
- **One device connected**: use it automatically.
46+
- **Multiple devices connected**: present the list to the user with
47+
`AskUserQuestion` and let them pick which device to use.
48+
- **No devices connected**: go to step 4.
49+
50+
### 4. Handle no connected devices
51+
52+
List available (offline) AVDs:
53+
54+
```bash
55+
emulator -list-avds
56+
```
57+
58+
- **AVDs available**: present the list to the user with
59+
`AskUserQuestion` and let them pick one. Before starting the
60+
emulator, snapshot the current device list so you can identify
61+
the new serial afterwards:
62+
63+
```bash
64+
adb devices -l # snapshot before
65+
emulator -avd <avd_name> &
66+
adb wait-for-device
67+
```
68+
69+
After `wait-for-device` returns, poll until the device has
70+
finished booting:
71+
72+
```bash
73+
adb [-s <serial>] shell getprop sys.boot_completed
74+
```
75+
76+
Repeat every 2 seconds until the output is `1`. Then run
77+
`adb devices -l` again and diff against the earlier snapshot to
78+
resolve the new emulator's serial for subsequent `-s` flags.
79+
80+
- **No AVDs available**: warn the user that no devices or emulators
81+
are available and suggest they connect a device or create an AVD
82+
through Android Studio.
83+
84+
### 5. Install and launch the app
85+
86+
Find the built APK dynamically (the exact filename may change across
87+
Gradle versions):
88+
89+
**Jetpack (default):**
90+
91+
```bash
92+
APK=$(find WordPress/build/outputs/apk/jetpackWasabi/debug \
93+
-name '*.apk' ! -name '*androidTest*' | head -1)
94+
```
95+
96+
**WordPress (only if the user explicitly requested it):**
97+
98+
```bash
99+
APK=$(find WordPress/build/outputs/apk/wordpressWasabi/debug \
100+
-name '*.apk' ! -name '*androidTest*' | head -1)
101+
```
102+
103+
Install the APK on the target device (use `-s <serial>` when multiple
104+
devices are present):
105+
106+
```bash
107+
adb [-s <serial>] install -r "$APK"
108+
```
109+
110+
Then launch the app:
111+
112+
- **Jetpack**: `adb [-s <serial>] shell am start -n com.jetpack.android.beta/org.wordpress.android.ui.WPLaunchActivity`
113+
- **WordPress**: `adb [-s <serial>] shell am start -n org.wordpress.android.beta/org.wordpress.android.ui.WPLaunchActivity`
114+
115+
### 6. Report the result
116+
117+
Tell the user whether the app was successfully installed and launched,
118+
or report any errors encountered during the process.
119+
120+
## Important Rules
121+
122+
- Always build before installing to ensure the APK is up to date.
123+
- When multiple devices are connected, NEVER pick one silently —
124+
always ask the user.
125+
- When starting an emulator, run it in the background so it does not
126+
block the agent.
127+
- If the build fails, report the error and do NOT attempt to install
128+
a stale APK.

0 commit comments

Comments
 (0)