piyushverma0/android-agent-skills/biometrics

Claude Code and agent skill by piyushverma0/android-agent-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Biometric authentication for Android AI agents. Use this skill whenever implementing fingerprint authentication, face unlock, biometric login, BiometricPrompt, BiometricManager, CryptoObject, Keystore encryption with biometrics, Class 2 vs Class 3 biometrics, biometric availability check, fallback to PIN/pattern, secure credential storage, or any biometric/fingerprint/face authentication flow in Android.

Install

npx vskill@latest install piyushverma0/android-agent-skills/biometrics

SKILL.md

The same SKILL.md was published earlier as piyushverma0/android-agent-skills/biometrics.

Biometric Authentication

Rule 1: Check availability before showing biometric UI

kotlin
// ✅ Check what's available before prompting
fun BiometricManager.canAuthenticateWithBiometrics(): Boolean {
val authenticators = BIOMETRIC_STRONG or DEVICE_CREDENTIAL
return canAuthenticate(authenticators) == BiometricManager.BIOMETRIC_SUCCESS
}
// ✅ Detailed availability check
sealed interface BiometricAvailability {
data object Available : BiometricAvailability
data object NoHardware : BiometricAvailability
data object NotEnrolled : BiometricAvailability
data object Unavailable : BiometricAvailability
}
fun checkBiometricAvailability(context: Context): BiometricAvailability {
val manager = BiometricManager.from(context)
return when (manager.canAuthenticate(BIOMETRIC_STRONG or DEVICE_CREDENTIAL)) {
BiometricManager.BIOMETRIC_SUCCESS -> BiometricAvailability.Available
BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE,
BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE -> BiometricAvailability.NoHardware
BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED -> BiometricAvailability.NotEnrolled
else -> BiometricAvailability.Unavailable
}
}

Rule 2: BiometricPrompt — correct setup in ComponentActivity

kotlin
// ✅ Must be created in Activity, not in Composable
class MainActivity : ComponentActivity() {
private lateinit var biometricPrompt: BiometricPrompt
private lateinit var promptInfo: BiometricPrompt.PromptInfo
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setupBiometrics()
setContent { MyApp(onAuthenticateClick = ::showBiometricPrompt) }
}
private fun setupBiometrics() {
val executor = ContextCompat.getMainExecutor(this)
biometricPrompt = BiometricPrompt(this, executor, object : BiometricPrompt.AuthenticationCallback() {
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
// Handle success — result.cryptoObject available if using CryptoObject
viewModel.onBiometricSuccess()
}
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
if (errorCode != BiometricPrompt.ERROR_USER_CANCELED &&
errorCode != BiometricPrompt.ERROR_NEGATIVE_BUTTON) {
viewModel.onBiometricError(errString.toString())
}
}
override fun onAuthenticationFailed() {
// Biometric recognized but not matched — DO NOT lock out here
// BiometricPrompt handles lockout automatically
}
})
promptInfo = BiometricPrompt.PromptInfo.Builder()
.setTitle("Authenticate")
.setSubtitle("Use your biometric to unlock the app")
.setAllowedAuthenticators(BIOMETRIC_STRONG or DEVICE_CREDENTIAL)
// Don't set setNegativeButtonText when DEVICE_CREDENTIAL is allowed
.build()
}
fun showBiometricPrompt() {
biometricPrompt.authenticate(promptInfo)
}
}

Rule 3: Crypto-backed biometrics for secure key operations

kotlin
// ✅ Biometric-protected Keystore key
object BiometricCryptoHelper {
private const val KEY_NAME = "biometric_key"
fun generateKey() {
val keyGen = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore")
keyGen.init(
KeyGenParameterSpec.Builder(KEY_NAME,
KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT)
.setBlockModes(KeyProperties.BLOCK_MODE_CBC)
.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_PKCS7)
.setUserAuthenticationRequired(true)
.setUserAuthenticationParameters(0, KeyProperties.AUTH_BIOMETRIC_STRONG)
.setInvalidatedByBiometricEnrollment(true)
.build()
)
keyGen.generateKey()
}
fun getCipher(): Cipher {
val key = KeyStore.getInstance("AndroidKeyStore").run {
load(null)
getKey(KEY_NAME, null) as SecretKey
}
return Cipher.getInstance("${KeyProperties.KEY_ALGORITHM_AES}/${KeyProperties.BLOCK_MODE_CBC}/${KeyProperties.ENCRYPTION_PADDING_PKCS7}").apply {
init(Cipher.ENCRYPT_MODE, key)
}
}
}
// Authenticate with CryptoObject for maximum security
fun showSecureBiometricPrompt() {
val cipher = BiometricCryptoHelper.getCipher()
biometricPrompt.authenticate(promptInfo, BiometricPrompt.CryptoObject(cipher))
}

Common Mistakes

❌ Creating BiometricPrompt in Composable — create in Activity, pass lambda to Compose ❌ Setting setNegativeButtonText when DEVICE_CREDENTIAL is allowed — crash ❌ Not checking availability before showing prompt — shows broken UI on unsupported devices ❌ Locking user out on onAuthenticationFailed — BiometricPrompt handles lockout ❌ Using BIOMETRIC_WEAK for sensitive operations — use BIOMETRIC_STRONG with CryptoObject

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/piyushverma0/android-agent-skills/biometrics/badge)](https://verified-skill.com/skills/piyushverma0/android-agent-skills/biometrics)

Something wrong with this skill or its page? Tell us.