Agent skill

find-non-lambda-logs

Use when auditing or migrating Log calls to lambda overloads, after adding new logging, or checking for string interpolation in Log.d/i/w/e calls that waste allocations when the log level is filtered out

Stars 1,494
Forks 189

Install this agent skill to your Project

npx add-skill https://github.com/vitorpamplona/amethyst/tree/main/.claude/skills/find-non-lambda-logs

SKILL.md

Find Non-Lambda Log Calls

Overview

Locates Log.d/i/w/e calls that use string interpolation without the lambda overload, wasting string allocation when the log level is filtered out in release builds.

When to Use

  • After merging branches that add new logging
  • Periodic audit of logging hygiene
  • After migrating android.util.Log usages to the shared Log wrapper

What to Flag

Calls with string interpolation ($ in message) that do not pass a throwable:

kotlin
// FLAG - interpolation without lambda, no throwable
Log.d("Tag", "Processing ${event.id}")
Log.w("Tag", "Failed for $url")

// IGNORE - passes throwable (lambda overload doesn't accept throwable)
Log.w("Tag", "Error: ${e.message}", e)
Log.e("Tag", "Failed for $url", throwable)

// IGNORE - no interpolation (no allocation benefit from lambda)
Log.d("Tag", "Initialization complete")

Search Commands

Important: Tags can be string literals ("Tag") or variables (tag, LOG_TAG). Run both patterns for each step.

Step 1: Find interpolated Log.d/Log.i (highest priority — filtered in release)

pattern: Log\.(d|i)\("[^"]+",\s*"[^"]*\$
type: kotlin
pattern: Log\.(d|i)\(\w+,\s*"[^"]*\$
type: kotlin

Step 2: Find interpolated Log.w/Log.e without throwable

pattern: Log\.(w|e)\("[^"]+",\s*"[^"]*\$
type: kotlin
pattern: Log\.(w|e)\(\w+,\s*"[^"]*\$
type: kotlin

Then manually exclude lines where a throwable is passed as third argument (ending with , e), , throwable), etc.). Check the actual line — a catch block catching e doesn't mean e is passed to the Log call.

Step 3: Verify no android.util.Log leakage

pattern: android\.util\.Log\.(d|i|w|e|v)\(
type: kotlin

These bypass the Log.minLevel filter entirely. Exclude PlatformLog.android.kt which is the wrapper implementation.

Fix Pattern

kotlin
// Before
Log.d("Tag", "Processing event ${event.id} from ${relay.url}")

// After
Log.d("Tag") { "Processing event ${event.id} from ${relay.url}" }

Do NOT Convert

  • Calls passing a Throwable parameter - the lambda overload (tag) { message } has no throwable parameter
  • Static string calls with no $ interpolation - no allocation benefit
  • Commented-out log calls

Expand your agent's capabilities with these related and highly-rated skills.

vitorpamplona/amethyst

quartz-integration

1,494 189
Explore
vitorpamplona/amethyst

android-expert

1,494 189
Explore
vitorpamplona/amethyst

desktop-expert

1,494 189
Explore
vitorpamplona/amethyst

compose-expert

Advanced Compose Multiplatform UI patterns for shared composables. Use when working with visual UI components, state management patterns (remember, derivedStateOf, produceState), recomposition optimization (@Stable/@Immutable visual usage), Material3 theming, custom ImageVector icons, or determining whether to share UI in commonMain vs keep platform-specific. Delegates navigation to android-expert/desktop-expert. Complements kotlin-expert (handles Kotlin language aspects of state/annotations).

1,494 189
Explore
vitorpamplona/amethyst

find-missing-translations

Use when comparing Android strings.xml locale files to find untranslated string resources, missing translation keys, or preparing translation work for a specific language

1,494 189
Explore
vitorpamplona/amethyst

kotlin-multiplatform

Platform abstraction decision-making for Amethyst KMP project. Guides when to abstract vs keep platform-specific, source set placement (commonMain, jvmAndroid, platform-specific), expect/actual patterns. Covers primary targets (Android, JVM/Desktop, iOS) with web/wasm future considerations. Integrates with gradle-expert for dependency issues. Triggers on: abstraction decisions ("should I share this?"), source set placement questions, expect/actual creation, build.gradle.kts work, incorrect placement detection, KMP dependency suggestions.

1,494 189
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results