Add web-frontend, web-project-audit and web-project-scaffold-containerized-python skills

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Neil Bantoc 2026-11-04 14:46:25 -08:00
parent 59fc08fa5f
commit 5201aa9bd5
63 changed files with 3042 additions and 0 deletions

View file

@ -0,0 +1,56 @@
---
name: scaffold-new-android-project
description: Scaffold a new Android project from scratch. Use when the user wants to start/create/bootstrap a new Android app, set up an Android project skeleton, or verify their Android dev environment (SDK, JDK, Gradle) before building. Verifies tooling, picks compatible AGP/Gradle/Kotlin versions, and produces a minimal Kotlin+Compose skeleton that `./gradlew build` passes before any feature work begins.
---
# Scaffold a New Android Project
Goal: hand back a skeleton where **`./gradlew build` exits 0** before any feature code is written. A green build is the contract — everything below serves it. Never write feature code on top of a skeleton that has not built.
## Step 1 — Check the environment (never install silently)
Run the doctor and read its report:
```bash
bash "$SKILL_DIR/scripts/doctor.sh"
```
It checks JDK (needs 17+), the Android SDK (ANDROID_HOME / ANDROID_SDK_ROOT / common locations), the cmdline-tools (adb/sdkmanager/avdmanager), installed platforms & build-tools, and a Gradle binary to bootstrap the wrapper.
- **Do not download or install anything.** If something is missing, the doctor already prints copy-pasteable commands. Surface those to the user and stop — let them run installs (suggest they use the `! <command>` prompt prefix so output lands in the session).
- If the doctor exits non-zero, **flag the blocker to the user and wait** — do not scaffold blind.
## Step 2 — Pick compatible versions
The single most common failure is an incompatible **AGP ↔ Gradle ↔ Kotlin** triple. Before scaffolding:
1. Note what's actually available: the doctor lists installed `platforms` (→ `compileSdk`) and any cached Gradle distributions.
2. If the user specified versions, use them. Otherwise pick a known-good triple and confirm against the AGP release notes (AGP's "Compatible Gradle/Kotlin" table) — **check, don't guess from memory.**
3. The default `scaffold.sh` template targets **AGP 9** with Kotlin built in (no `kotlin-android` plugin needed). If the user explicitly asks for AGP 8.x instead, adjust accordingly: apply `org.jetbrains.kotlin.android`, use `kotlinOptions`, and downgrade Gradle to ≥8.10.
4. Compose needs the Compose compiler plugin (`org.jetbrains.kotlin.plugin.compose`) for Kotlin 2.0+; the template already wires it.
## Step 3 — Generate the skeleton
```bash
bash "$SKILL_DIR/scripts/scaffold.sh" \
--dir <project-dir> --package com.example.app --name "My App" \
--compile-sdk 34 --min-sdk 24 \
--gradle-version <ver> --agp <ver> --kotlin <ver>
```
The script writes Kotlin-DSL Gradle files with a `libs.versions.toml` version catalog, a single `MainActivity` Compose screen, a theme, `res/`, `gradle.properties`, `.gitignore` (ignoring `local.properties`, `build/`, `.gradle/`, `.kotlin/`), and a `local.properties` pointing at the SDK. It then bootstraps the wrapper with a real gradle binary and runs `./gradlew build`.
The skeleton is deliberately minimal — **no Hilt, Room, Retrofit, or networking.** Those are project-specific; add them incrementally *after* this baseline builds, re-running `./gradlew build` after each addition.
## Step 4 — Confirm the contract
`scaffold.sh` runs `./gradlew build` for you. If it fails, fix the skeleton until it passes — do not proceed. If it passes, the baseline is real; report the versions used and hand off.
## Guardrails (these are why the skill exists)
- **Every claim of "it builds" must come from actually running `./gradlew build`** and seeing exit 0 — never from eyeballing the files.
- **One Gradle dialect: Kotlin DSL.** Do not mix Groovy `.gradle` files or write Kotlin syntax (`val`, `isMinifyEnabled =`) into a Groovy file.
- **Used ⇒ declared.** Every non-stdlib import must map to a declared dependency in the catalog.
- **Declared ⇒ used.** Don't add dependencies or classes the skeleton doesn't reference.
- **A referenced resource must exist** — themes, launcher icons, drawables named in the manifest. Missing resources fail resource linking, not compilation, so a Kotlin-only check won't catch them; `./gradlew build` will.
- **Secrets in `local.properties`**, never committed; read into `BuildConfig` via `buildConfigField` when needed (add `buildConfig = true`).

View file

@ -0,0 +1,96 @@
#!/usr/bin/env bash
# doctor.sh — inspect the Android/Gradle/JDK dev environment WITHOUT installing anything.
# Prints a report and, where a tool is missing, prints copy-pasteable commands the USER can run.
# Exit code: 0 if a usable environment was found (SDK + JDK 17+), 1 otherwise.
set -uo pipefail
ok() { printf ' \033[32m✓\033[0m %s\n' "$1"; }
warn() { printf ' \033[33m!\033[0m %s\n' "$1"; }
bad() { printf ' \033[31m✗\033[0m %s\n' "$1"; }
hdr() { printf '\n\033[1m%s\033[0m\n' "$1"; }
FAIL=0
# ---------------------------------------------------------------------------
hdr "JDK"
if command -v java >/dev/null 2>&1; then
JV=$(java -version 2>&1 | head -1)
JMAJOR=$(java -version 2>&1 | head -1 | sed -E 's/.*version "([0-9]+).*/\1/')
if [ "${JMAJOR:-0}" -ge 17 ] 2>/dev/null; then
ok "java: $JV"
[ -n "${JAVA_HOME:-}" ] && ok "JAVA_HOME=$JAVA_HOME" || warn "JAVA_HOME is unset (fine if 'java' works, but Gradle prefers it set)"
else
bad "java is $JV — Android Gradle Plugin needs JDK 17+"
FAIL=1
fi
else
bad "java not found on PATH"
echo " Look for a JDK 17 here, then export JAVA_HOME + add to PATH:"
echo " ls /usr/lib/jvm/ 2>/dev/null; ls /Library/Java/JavaVirtualMachines/ 2>/dev/null"
echo " # export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64"
echo " # export PATH=\"\$JAVA_HOME/bin:\$PATH\""
FAIL=1
fi
# ---------------------------------------------------------------------------
hdr "Android SDK"
SDK=""
for cand in "${ANDROID_HOME:-}" "${ANDROID_SDK_ROOT:-}" \
"$HOME/Android/Sdk" "$HOME/Library/Android/sdk" \
"/usr/lib/android-sdk" "/opt/android-sdk"; do
[ -n "$cand" ] && [ -d "$cand" ] && { SDK="$cand"; break; }
done
if [ -n "$SDK" ]; then
ok "SDK root: $SDK"
[ -n "${ANDROID_HOME:-}" ] && ok "ANDROID_HOME set" || warn "ANDROID_HOME unset — 'export ANDROID_HOME=$SDK'"
else
bad "No Android SDK found in ANDROID_HOME / ANDROID_SDK_ROOT or common locations."
echo " Search for one (do NOT download unless the user asks):"
echo " find \$HOME /opt /usr/lib -maxdepth 4 -type d -name platform-tools 2>/dev/null"
echo " If found at <dir>/platform-tools, set:"
echo " export ANDROID_HOME=<dir>; export PATH=\"\$ANDROID_HOME/platform-tools:\$ANDROID_HOME/cmdline-tools/latest/bin:\$PATH\""
FAIL=1
fi
# ---------------------------------------------------------------------------
hdr "SDK command-line tools"
for tool in adb sdkmanager avdmanager; do
P=$(command -v $tool 2>/dev/null)
if [ -n "$P" ]; then ok "$tool: $P"
elif [ -n "$SDK" ]; then
HIT=$(find "$SDK" -name "$tool" -type f 2>/dev/null | head -1)
[ -n "$HIT" ] && warn "$tool present but not on PATH: $HIT" || warn "$tool not found (sdkmanager can install it)"
else warn "$tool not found"; fi
done
# ---------------------------------------------------------------------------
hdr "Installed platforms & build-tools"
if [ -n "$SDK" ]; then
PLATS=$(ls "$SDK/platforms" 2>/dev/null | tr '\n' ' ')
BT=$(ls "$SDK/build-tools" 2>/dev/null | tr '\n' ' ')
[ -n "$PLATS" ] && ok "platforms: $PLATS" || warn "no platforms installed — e.g. 'sdkmanager \"platforms;android-34\"'"
[ -n "$BT" ] && ok "build-tools: $BT" || warn "no build-tools installed — e.g. 'sdkmanager \"build-tools;34.0.0\"'"
fi
# ---------------------------------------------------------------------------
hdr "Gradle (for generating the wrapper)"
GRADLE_BIN=""
if command -v gradle >/dev/null 2>&1; then
GRADLE_BIN=$(command -v gradle); ok "gradle on PATH: $GRADLE_BIN ($(gradle --version 2>/dev/null | awk '/^Gradle/{print $2}'))"
else
warn "gradle not on PATH — searching disk for a cached distribution..."
for g in /opt/gradle-*/bin/gradle "$HOME"/.gradle/wrapper/dists/gradle-*/*/gradle-*/bin/gradle; do
[ -x "$g" ] && { echo " found: $g"; GRADLE_BIN="$g"; }
done
if [ -n "$GRADLE_BIN" ]; then
ok "Use one of the above to bootstrap the wrapper, e.g.: \"$GRADLE_BIN\" wrapper --gradle-version <ver>"
else
bad "No gradle binary found. Once a skeleton with a committed wrapper exists, ./gradlew self-bootstraps."
echo " If you have NO wrapper and NO gradle, ask the user to install one or copy a gradle-wrapper.jar."
fi
fi
hdr "Result"
if [ "$FAIL" -eq 0 ]; then ok "Environment looks usable for an Android build."; else bad "Blockers above must be resolved (or flagged to the user) before scaffolding."; fi
exit $FAIL

View file

@ -0,0 +1,230 @@
#!/usr/bin/env bash
# scaffold.sh — generate a MINIMAL Android + Compose skeleton that "./gradlew build" passes.
# Kotlin DSL + version catalog. No Hilt/Room/networking — add those per project after this builds.
#
# Usage:
# scaffold.sh --dir <path> --package <com.foo.bar> [--name "App"] \
# [--compile-sdk 34] [--min-sdk 24] [--target-sdk 34] \
# [--gradle-version 9.5] [--agp 9.0.0] [--kotlin 2.1.0]
set -euo pipefail
DIR="" ; PKG="" ; NAME="My App"
COMPILE_SDK=34 ; MIN_SDK=24 ; TARGET_SDK=""
GRADLE_VER="" ; AGP="" ; KOTLIN=""
while [ $# -gt 0 ]; do case "$1" in
--dir) DIR="$2"; shift 2;;
--package) PKG="$2"; shift 2;;
--name) NAME="$2"; shift 2;;
--compile-sdk) COMPILE_SDK="$2"; shift 2;;
--min-sdk) MIN_SDK="$2"; shift 2;;
--target-sdk) TARGET_SDK="$2"; shift 2;;
--gradle-version) GRADLE_VER="$2"; shift 2;;
--agp) AGP="$2"; shift 2;;
--kotlin) KOTLIN="$2"; shift 2;;
*) echo "unknown arg: $1" >&2; exit 2;;
esac; done
[ -n "$DIR" ] || { echo "--dir required" >&2; exit 2; }
[ -n "$PKG" ] || { echo "--package required" >&2; exit 2; }
[ -n "$TARGET_SDK" ] || TARGET_SDK="$COMPILE_SDK"
# --- version defaults: KEEP THIS TABLE CURRENT. AGP<->Gradle<->Kotlin must be compatible. ---
# AGP 9 has Kotlin built in — no kotlin-android plugin needed.
[ -n "$GRADLE_VER" ] || GRADLE_VER="9.4.1"
[ -n "$AGP" ] || AGP="9.2.1"
[ -n "$KOTLIN" ] || KOTLIN="2.2.10"
echo ">> Scaffolding $PKG at $DIR (compileSdk=$COMPILE_SDK, AGP=$AGP, Gradle=$GRADLE_VER, Kotlin=$KOTLIN)"
PKG_PATH=$(echo "$PKG" | tr '.' '/')
APP_SRC="$DIR/app/src/main/java/$PKG_PATH"
mkdir -p "$APP_SRC" "$DIR/app/src/main/res/values" "$DIR/gradle/wrapper"
# --- root settings ---------------------------------------------------------
cat > "$DIR/settings.gradle.kts" <<EOF
pluginManagement {
repositories { google(); mavenCentral(); gradlePluginPortal() }
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories { google(); mavenCentral() }
}
rootProject.name = "${NAME}"
include(":app")
EOF
# --- version catalog -------------------------------------------------------
cat > "$DIR/gradle/libs.versions.toml" <<EOF
[versions]
agp = "${AGP}"
kotlin = "${KOTLIN}"
coreKtx = "1.13.1"
activityCompose = "1.9.1"
composeBom = "2024.06.00"
junit = "4.13.2"
[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
androidx-compose-ui = { group = "androidx.compose.ui", name = "ui" }
androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
EOF
# --- root build ------------------------------------------------------------
cat > "$DIR/build.gradle.kts" <<EOF
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.compose) apply false
}
EOF
# --- app build -------------------------------------------------------------
cat > "$DIR/app/build.gradle.kts" <<EOF
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.compose)
}
android {
namespace = "${PKG}"
compileSdk = ${COMPILE_SDK}
defaultConfig {
applicationId = "${PKG}"
minSdk = ${MIN_SDK}
targetSdk = ${TARGET_SDK}
versionCode = 1
versionName = "1.0"
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlin {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
}
}
buildFeatures { compose = true }
}
dependencies {
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.ui.tooling.preview)
implementation(libs.androidx.compose.material3)
testImplementation(libs.junit)
}
EOF
# --- gradle.properties -----------------------------------------------------
cat > "$DIR/gradle.properties" <<EOF
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
org.gradle.caching=true
android.useAndroidX=true
kotlin.code.style=official
android.nonTransitiveRClass=true
EOF
# --- manifest + source + resources ----------------------------------------
cat > "$DIR/app/src/main/AndroidManifest.xml" <<EOF
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:label="${NAME}"
android:supportsRtl="true"
android:theme="@style/Theme.App">
<activity android:name=".MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
EOF
cat > "$DIR/app/src/main/res/values/themes.xml" <<EOF
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.App" parent="android:Theme.Material.Light.NoActionBar" />
</resources>
EOF
cat > "$APP_SRC/MainActivity.kt" <<EOF
package ${PKG}
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent { MaterialTheme { Surface { Greeting() } } }
}
}
@Composable
fun Greeting() {
Text(text = "Hello from ${NAME}")
}
EOF
# --- git hygiene + local.properties ---------------------------------------
cat > "$DIR/.gitignore" <<EOF
local.properties
**/build/
build/
.gradle/
.kotlin/
*.iml
.idea/
EOF
# Point Gradle at the SDK (never commit this — it's gitignored).
SDK="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-}}"
[ -n "$SDK" ] && printf 'sdk.dir=%s\n' "$SDK" > "$DIR/local.properties"
# --- bootstrap the wrapper -------------------------------------------------
GRADLE_BIN="$(command -v gradle || true)"
if [ -z "$GRADLE_BIN" ]; then
for g in /opt/gradle-*/bin/gradle "$HOME"/.gradle/wrapper/dists/gradle-*/*/gradle-*/bin/gradle; do
[ -x "$g" ] && GRADLE_BIN="$g" && break
done
fi
if [ -z "$GRADLE_BIN" ]; then
echo "!! No gradle binary to generate the wrapper. Run doctor.sh and flag to the user." >&2
exit 3
fi
echo ">> Generating wrapper with $GRADLE_BIN"
( cd "$DIR" && "$GRADLE_BIN" wrapper --gradle-version "$GRADLE_VER" >/dev/null )
echo ">> Building"
( cd "$DIR" && ./gradlew build )
echo ">> DONE. Skeleton at $DIR builds successfully."