home / skills / bdambrosio / cognitive_workbench / is-empty

is-empty skill

/src/tools_out/is-empty

This skill checks if text is null, empty, or whitespace, enabling conditional logic and data validation.

npx playbooks add skill bdambrosio/cognitive_workbench --skill is-empty

Review the files below or copy the command above to add this skill to your agents.

Files (2)
Skill.md
1.3 KB
---
name: is-empty
description: Check if text is null, empty, or only whitespace
type: python
schema_hint:
  target: "$variable or Note ID"
  out: "$variable (optional)"
parameters: none
examples:
  - '{"type":"if","condition":{"type":"tool_condition","tool":"is-empty","target":"$text"},"then":[...]}'
---

# Is Empty

Check whether text contains meaningful content or is effectively empty.

## Purpose

- Validate note content exists
- Enable conditional logic in plans
- Filter out empty results
- Guard against null/missing data

## Input Format

Accepts:
- Plain text string
- Note content

## Parameters

None.

## Output Format

Returns boolean:
- `True` if text is null, empty string, or only whitespace
- `False` if text contains any non-whitespace content

## Usage Examples

**Basic validation:**
```json
{"type":"is-empty","target":"$result","out":"$is_empty"}
```

**Used in conditional:**
```json
{"type":"is-empty","target":"$search_results","out":"$no_results"}
```

## Guidelines

- Treats null, empty string, whitespace-only as empty
- Newlines, tabs, spaces count as whitespace
- Any visible character makes content non-empty

## Examples

**Empty cases:**
```
null → true
"" → true
"   " → true
"\n\t  \n" → true
```

**Non-empty cases:**
```
"Hello" → false
" x " → false
"0" → false
```

Overview

This skill checks whether a piece of text is null, empty, or contains only whitespace. It provides a simple boolean result that tells you if content is effectively absent. Use it to validate input, filter results, or drive conditional logic in workflows.

How this skill works

The skill accepts a plain text string or note content and inspects it for meaningful characters. It returns True when the input is null, an empty string, or contains only whitespace (spaces, tabs, newlines). It returns False when any visible character appears in the text.

When to use it

  • Validate user-submitted notes or form fields before saving
  • Detect and filter out empty search results or API responses
  • Drive conditional branches in automation or plan workflows
  • Guard downstream processing from null or whitespace-only inputs
  • Short-circuit operations that require meaningful text

Best practices

  • Treat null and missing values the same as empty strings
  • Trim or normalize input only when you intentionally want to ignore surrounding whitespace
  • Use this check early to avoid expensive processing of empty content
  • Combine with length checks when you need a minimum content size
  • Consider locale or normalization only if your definition of 'visible character' is language-dependent

Example use cases

  • Validate that a note body contains content before saving to a database
  • Return a friendly message when a search query yields only empty items
  • Skip text analysis pipelines if input is empty to save compute
  • Set a flag used by downstream steps to indicate absence of content
  • Filter a list of strings to remove entries that are null or whitespace-only

FAQ

Does the skill treat newlines and tabs as empty?

Yes. Newlines, tabs, and spaces are all considered whitespace and count as empty when no visible characters are present.

Is the check sensitive to characters like zero or punctuation?

No. Any visible character, including digits like '0' or punctuation, makes the content non-empty.