CtrlK
BlogDocsLog inGet started
Tessl Logo
SkillPublic

lodash-es-runtime-guards

Runtime guard refactoring guidance for lodash-es predicates, import style and verification. Use when explicitly refactoring runtime type or empty-string guards.

Quality

88%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Passed

No findings from the security scan

SKILL.md
Quality
Evals
Security

lodash-es-runtime-guards

Replace runtime typeof checks and ad-hoc empty-string checks with lodash-es predicates.

When to Use

  • You see runtime checks like typeof value === 'string'.
  • You see object guards like value && typeof value === 'object'.
  • You see emptiness checks like value.trim() !== '' or value.trim() === ''.
  • You want consistent guard style across app, server, IPC, and tests.

Do Not Replace

  • Type-level typeof (TypeScript only), for example:
    • ReturnType<typeof fn>
    • keyof typeof CONST_MAP
    • z.infer<typeof Schema>

These are compile-time types and must remain as-is.

Guard Mapping

  • typeof x === 'string' -> isString(x)
  • typeof x !== 'string' -> !isString(x)
  • typeof x === 'number' -> isNumber(x)
  • typeof x === 'boolean' -> isBoolean(x)
  • typeof x === 'function' -> isFunction(x)
  • typeof x === 'undefined' -> isUndefined(x)
  • x && typeof x === 'object' -> isObjectLike(x)
  • typeof x === 'object' && x !== null -> isObjectLike(x)
  • typeof x === 'object' && !Array.isArray(x) -> isObjectLike(x) && !isArray(x)

String Emptiness Pattern

  • Prefer:
    • isEmpty(value.trim())
  • Instead of:
    • value.trim() === ''
    • value.trim() !== ''
    • value.trim().length === 0

Import Style

  • Use named imports from lodash-es:
import { isString, isNumber, isObjectLike, isEmpty } from 'lodash-es';
  • Do not use full-package imports.
  • Reuse existing imports in file; avoid duplicate imports.

Refactor Checklist

  1. Replace runtime checks first, preserving behavior.
  2. Keep array/object branching semantics unchanged.
  3. Re-scan:
rg -n "typeof\s+[^\n]+(?:===|!==)\s*'" src
  1. Confirm only type-level typeof remains:
rg -n "\btypeof\b" src
  1. Run verification:
pnpm run type-check
Repository

Draculabo/AntigravityManager

Path

.agents/skills/lodash-es-runtime-guards/SKILL.md

Last updated
First committed

Is this your skill?

If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.