Developing Skill
Use this skill when modifying code, adding features, or verifying changes. It covers the entire lifecycle from compilation to on-device testing.
1. Environment Setup
Prerequisites
- •Rust Toolchain: Stable (latest)
- •Target:
aarch64-linux-android(for Android) - •Android NDK: Required for cross-compilation.
- •Environment Variables: You MUST source
android.sourcebefore running any Android build commands.
# Always run this first in a new shell session source android.source
2. Build Workflows
Host Build (Linux)
Use for quick syntax checking and logic verification that doesn't depend on Android-specific hardware.
# Check syntax cargo check # Run generic tests cargo test
Android Build (Target)
The primary build artifact is the generate binary or test_backend.
# Build main inference binary (Release recommended for performance) cargo build --target aarch64-linux-android --release --bin generate # Build backend verification tool cargo build --target aarch64-linux-android --release --bin test_backend
3. Testing & Verification
We employ a 3-tier testing strategy.
Tier 1: Local Unit Tests (Host)
Run standard Rust tests. This catches logic errors in platform-agnostic code (tokenizers, shape inference, etc.).
cargo test
Tier 2: Backend Verification (On-Device)
Verifies that the OpenCL/CPU kernels produce mathematically correct results on the actual hardware. Crucial for kernel development.
Use Testing Skill:
./.agent/skills/testing/scripts/run_android.sh test_backend
Tier 3: Integration/E2E Test (On-Device)
Runs the full generate pipeline.
Use Testing Skill:
./.agent/skills/testing/scripts/run_android.sh generate --prompt "Hello" -n 128
4. Code Quality (Automation)
Sanity Check Script: Run this script before verification to ensure code style and linting are correct.
./.agent/skills/developing/scripts/sanity_check.sh
- •Runs
cargo fmt(auto-fixes if needed). - •Runs
cargo clippyto catch common mistakes.
5. Development Tips
Kernel Development (OpenCL)
[!WARNING] DO NOT modify
.clkernel files unless explicitly instructed by the user. These are highly optimized and stable.
- •
.clfiles are inkernels/. - •Embedded into the binary at build time.
- •Workflow: Modify
.cl-> Buildtest_backend-> Push -> Run on device. - •Debugging: Use
printfinside OpenCL kernels (requires flushing stdout) or checktest_backendoutput for mismatches.
6. Finalizing (Definition of Done)
ALWAYS perform these steps before marking a task as complete:
- •
Update Documentation: Reflect any architectural changes, new commands, or findings in
PROJECT_CONTEXT.mdor relevantGUIDE.mdfiles. - •
Update Artifacts: Ensure
task.mdandwalkthrough.mdare up to date.Update Artifacts: Ensure
task.mdandwalkthrough.mdare up to date.
7. Version Control & Commits
If the user requests to commit changes:
- •Scope: Commit only the changes relevant to the current task. Stage files selectively (
git add <file>). - •Style: Always check
git logfirst to follow the project's existing commit message conventions.
8. Cheat Sheet
| Action | Command |
|---|---|
| Setup Env | source android.source |
| Sanity Check | ./.agent/skills/developing/scripts/sanity_check.sh |
| Build (Android) | cargo build --target aarch64-linux-android --release |
| Verify Backend | ./.agent/skills/testing/scripts/run_android.sh test_backend |