.cursor/skills/kotlin-java-android-patterns/SKILL.md
--- name: kotlin-java-android-patterns description: Guides Kotlin/Java Android integration patterns: platform channels, method channels, native Android features, BLE implementation. Use when implementing Android-specific features, native platform channels, or Kotlin/Java integration. --- # Kotlin/Java Android Integration Patterns ## Core Purpose Kotlin/Java integration enables Flutter apps to use Android-specific features via platform channels. ## Method Channel Pattern ### Kotlin Side ```k
npx skillsauth add avra-cadavra/avrai .cursor/skills/kotlin-java-android-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Kotlin/Java integration enables Flutter apps to use Android-specific features via platform channels.
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
class MainActivity: FlutterActivity() {
private val CHANNEL = "com.avrai.app/methods"
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL)
.setMethodCallHandler { call, result ->
when (call.method) {
"getPlatformVersion" -> {
result.success("Android ${android.os.Build.VERSION.SDK_INT}")
}
"performNativeOperation" -> {
val params = call.arguments as? Map<*, *>
performNativeOperation(params, result)
}
else -> {
result.notImplemented()
}
}
}
}
private fun performNativeOperation(
params: Map<*, *>?,
result: MethodChannel.Result
) {
try {
// Perform native Android operation
val resultData = "Operation completed"
result.success(resultData)
} catch (e: Exception) {
result.error("OPERATION_ERROR", e.message, null)
}
}
}
import 'package:flutter/services.dart';
class PlatformChannelService {
static const MethodChannel _channel = MethodChannel('com.avrai.app/methods');
Future<String> getPlatformVersion() async {
try {
final String version = await _channel.invokeMethod('getPlatformVersion');
return version;
} on PlatformException catch (e) {
developer.log('Platform version error: ${e.message}');
return 'Unknown';
}
}
}
import android.bluetooth.BluetoothAdapter
import android.bluetooth.le.ScanCallback
import android.bluetooth.le.ScanResult
class AndroidBLEService(private val context: Context) {
private val bluetoothAdapter: BluetoothAdapter? =
(context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager)
.adapter
fun startScanning(callback: (ScanResult) -> Unit) {
val scanner = bluetoothAdapter?.bluetoothLeScanner
val scanCallback = object : ScanCallback() {
override fun onScanResult(callbackType: Int, result: ScanResult) {
callback(result)
}
}
scanner?.startScan(scanCallback)
}
fun stopScanning() {
val scanner = bluetoothAdapter?.bluetoothLeScanner
scanner?.stopScan(scanCallback)
}
}
import android.app.Notification
import android.app.Service
import android.content.Intent
import android.os.IBinder
class BLEForegroundService : Service() {
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
// Create notification for foreground service
val notification = createNotification()
startForeground(NOTIFICATION_ID, notification)
// Start BLE operations
startBLEScanning()
return START_STICKY
}
private fun createNotification(): Notification {
return Notification.Builder(this, CHANNEL_ID)
.setContentTitle("SPOTS BLE")
.setContentText("Scanning for nearby devices")
.setSmallIcon(R.drawable.icon)
.build()
}
}
private fun performOperation(result: MethodChannel.Result) {
try {
val resultData = performWork()
result.success(resultData)
} catch (e: Exception) {
result.error(
"OPERATION_ERROR",
e.message,
e.stackTraceToString()
)
}
}
android/app/src/main/java/ - Android native codedevelopment
--- name: world-model-development description: Guides world model development patterns: state/action encoders, ONNX inference, feature extraction pipeline, latency budgets. Use when implementing world model components, state encoders, action encoders, feature extractors, or ONNX models. Core skill for Phases 3-6. --- # World Model Development Patterns ## Core Principle All world model components follow LeCun's autonomous machine intelligence framework. State observations flow through a percep
tools
Implements base workflow controller patterns for multi-step processes. Use when creating complex workflows that require orchestration of multiple steps with error handling and rollback.
testing
--- name: widget-test-patterns description: Guides widget test patterns: BLoC testing, user interactions, state changes, material app setup. Use when writing widget tests, testing UI components, or validating widget behavior. --- # Widget Test Patterns ## Core Pattern Widget tests verify UI behavior: user interactions, state changes, and visual display. ## Basic Widget Test Setup ```dart testWidgets('widget displays correctly', (WidgetTester tester) async { // Arrange: Create widget awa
testing
--- name: test-template-generation description: Generates test templates: unit, widget, integration, service tests following project patterns. Use when creating new tests or ensuring tests follow project standards. --- # Test Template Generation ## Available Templates Test templates are located in `test/templates/`: - `unit_test_template.dart` - `widget_test_template.dart` - `integration_test_template.dart` - `service_test_template.dart` ## Unit Test Template ```dart /// SPOTS Component Uni