home / skills / bdambrosio / cognitive_workbench / 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 flattenReview the files below or copy the command above to add this skill to your agents.
---
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
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.
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.
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.