home / skills / bdambrosio / cognitive_workbench / flatten

flatten skill

/src/primitives/flatten

This skill merges all items in a collection into a single note, preserving content while removing the collection structure.

npx playbooks add skill bdambrosio/cognitive_workbench --skill flatten

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

Files (1)
Skill.md
901 B
---
name: flatten
type: primitive
description: Flatten Collection to single Note
---

# Flatten

## INPUT CONTRACT

- `target`: Collection (variable or ID)
- `out`: Variable name

**REQUIREMENTS:**
- `target` MUST be Collection

**NOT SUPPORTED:**
- ❌ Note (use `split` to convert Note → Collection first)

## OUTPUT

Returns single Note containing merged content from all Collection items.

## FAILURE SEMANTICS

**Returns `failed` when:**
- Target is Note (not Collection)
- Missing parameters

**Empty Note ≠ error** — indicates empty Collection, not failure.

## REPRESENTATION INVARIANTS

- Collection ≠ Note containing array
- `flatten` performs inverse of `split` (Collection → Note)
- Use `split` to convert array → Collection

## ANTI-PATTERNS

❌ `flatten(target=$note)` → Must be Collection
❌ Expecting structured output → Returns merged content, structure may be lost

Overview

This skill merges all items of a Collection into a single Note. It takes a Collection as input and returns one Note whose content is the concatenation of the Collection items. It is designed as the inverse operation of a split workflow and preserves content by merging, not by preserving original collection structure.

How this skill works

You pass a Collection (by variable or ID) as the target and provide an output variable name. The skill iterates the collection items and concatenates their content into a single Note, then writes that Note to the specified output variable. If the target is not a Collection or required parameters are missing, the skill returns a failure status.

When to use it

  • You need a single note that consolidates several collection items for export or display.
  • Preparing a combined summary or report from multiple entries.
  • When reversing a previous split operation to restore a single-note form.
  • Merging fragmented content before running text-level processing or publishing.

Best practices

  • Ensure the input target is a Collection; pass Notes through split first if needed.
  • Choose a clear output variable name to avoid overwriting existing data.
  • Expect merged content to lose collection-level structure (no guaranteed fieldwise merging).
  • Validate the resulting Note if downstream processing requires specific structure.

Example use cases

  • Flatten a task collection into a single meeting agenda note for sharing.
  • Combine daily journal entries (stored as a Collection) into a single monthly summary Note.
  • Restore a Note that was previously split into multiple items for granular editing.
  • Merge multiple content blocks into one Note before generating a PDF or export.

FAQ

What happens if I pass a Note instead of a Collection?

The skill returns failed. You must convert a Note to a Collection with split before using flatten.

Does flatten preserve the original collection structure and fields?

No. Flatten concatenates item content into a single Note. Structured relationships or separate fields may be lost.