← Back to Skills Marketplace
killerapp

Chain of Density

by Vaskin Kissoyan · GitHub ↗ · v1.1.0
cross-platform ✓ Security Clean
1564
Downloads
1
Stars
3
Active Installs
1
Versions
Install in OpenClaw
/install chain-of-density
Description
Iteratively densify text summaries using Chain-of-Density technique. Use when compressing verbose documentation, condensing requirements, or creating executive summaries while preserving information density.
README (SKILL.md)

Chain-of-Density Summarization

Compress text through iterative entity injection following the CoD paper methodology. Each pass identifies missing entities from the source and incorporates them while maintaining identical length.

The Method

Chain-of-Density works through multiple iterations:

  1. Iteration 1: Create sparse, verbose base summary (4-5 sentences at target_words)
  2. Subsequent iterations: Each iteration:
    • Identify 1-3 missing entities from SOURCE (not summary)
    • Rewrite summary to include them
    • Maintain IDENTICAL word count through compression

Key principle: Never drop entities - only add and compress.

Missing Entity Criteria

Each entity added must meet ALL 5 criteria:

Criterion Description
Relevant To the main story/topic
Specific Descriptive yet concise (≤5 words)
Novel Not in the previous summary
Faithful Present in the source (no hallucination)
Anywhere Can be from anywhere in the source

Quick Start

  1. User provides text to summarize
  2. Orchestrate 5 iterations via cod-iteration agent
  3. Each iteration reports entities added via Missing_Entities: line
  4. Return final summary + entity accumulation history

Orchestration Pattern

Iteration 1: Sparse base (target_words, verbose filler)
     ↓ Missing_Entities: (none - establishing base)
Iteration 2: +3 entities, compress filler
     ↓ Missing_Entities: "entity1"; "entity2"; "entity3"
Iteration 3: +3 entities, compress more
     ↓ Missing_Entities: "entity4"; "entity5"; "entity6"
Iteration 4: +2 entities, tighten
     ↓ Missing_Entities: "entity7"; "entity8"
Iteration 5: +1-2 entities, final density
     ↓ Missing_Entities: "entity9"
Final dense summary (same word count, 9+ entities)

How to Orchestrate

Iteration 1 - Pass source text only:

Task(subagent_type="cod-iteration", prompt="""
iteration: 1
target_words: 80
text: [SOURCE TEXT HERE]
""")

Iterations 2-5 - Pass BOTH previous summary AND source:

Task(subagent_type="cod-iteration", prompt="""
iteration: 2
target_words: 80
text: [PREVIOUS SUMMARY HERE]
source: [ORIGINAL SOURCE TEXT HERE]
""")

Critical:

  • Invoke serially, not parallel
  • Pass SOURCE text in every iteration for entity discovery
  • Parse Missing_Entities: line to track entity accumulation

Expected Agent Output Format

The cod-iteration agent returns:

Missing_Entities: "entity1"; "entity2"; "entity3"

Denser_Summary:
[The densified summary - identical word count to previous]

Parse both parts - track entities for history, pass summary to next iteration.

Measuring Density

Use scripts/text_metrics.py for deterministic word counts:

echo "your summary text" | uv run scripts/text_metrics.py words
# Returns: word count

uv run scripts/text_metrics.py metrics "your summary text"
# Returns: {"words": N, "chars": N, "bytes": N}

Parameters

Parameter Default Description
iterations 5 Number of density passes (paper uses 5)
target_words 80 Word count maintained across ALL iterations
return_history false Include intermediate summaries + entities

Note: target_words can be adjusted based on source length and desired output density.

Output Format

Minimal (default)

[Final dense summary text]

With History (return_history=true)

final_summary: |
  [Dense summary at target_words with accumulated entities]
iterations:
  - turn: 1
    missing_entities: "(none - establishing base)"
    words: 80
    summary: |
      [Sparse iteration 1]
  - turn: 2
    missing_entities: "entity1; entity2; entity3"
    words: 80
    summary: |
      [Denser iteration 2]
  # ... etc
total_entities: 9

When to Use

  • Verbose documentation exceeding 500 words
  • Requirements documents needing condensation
  • Creating executive summaries from detailed reports
  • Compressing skills that exceed recommended length

When NOT to Use

  • Legal/compliance text (precision required)
  • Tutorial content (beginners need explanation)
  • Already concise content (\x3C300 words)
  • Specifications (don't compress specs)

Example

Source (180 words, verbose skill excerpt):

The name field is a required field that must be present in every skill.
The name field identifies the skill and must follow a specific format.
For the name field, you should use lowercase letters and hyphens only.
The name field can be 1 to 64 characters long. The description field
is also required and tells agents when to use your skill...

Iteration 1 (Sparse, 80 words):

Missing_Entities: (none - establishing base)

Denser_Summary:
This document discusses the requirements for skill configuration fields in agent systems. It covers various aspects of how fields should be formatted and what values they can contain. The document also mentions validation rules that apply to these fields and provides guidance on best practices for developers. Additionally, it includes information about both optional and required elements that need to be considered when creating new skills for the system.

Iteration 3 (After 2 passes, same 80 words):

Missing_Entities: "1-64 characters"; "lowercase alphanumeric-hyphens"; "Use when phrase"

Denser_Summary:
Skills require `name` (1-64 chars, lowercase alphanumeric-hyphens) and `description` fields with validation rules. The name identifies skills; descriptions tell agents when to invoke using "Use when..." phrases. Both fields have format constraints and best practices. Optional metadata fields provide author, version, and compatibility information for cross-platform agent discovery.

Final Iteration 5 (Same 80 words, maximum density):

Missing_Entities: "Claude Code"; "Cursor"; "GitHub Copilot"

Denser_Summary:
Required: `name` (1-64 chars, ^[a-z0-9]+(-[a-z0-9]+)*$) and `description` (1-1024 chars) with validation. Description includes "Use when..." + discovery keywords for auto-invocation. Optional: license (SPDX), compatibility, metadata (author, version, tags). Cross-platform: Claude Code, Cursor, GitHub Copilot. Name matches directory. Progressive disclosure via references/, assets/, scripts/ subdirectories.

Architecture Note

This skill implements the CoD paper methodology:

  • Skill = orchestrator (this file)
  • Agent = stateless worker (cod-iteration)
  • Script = deterministic utility (text_metrics.py)

Sub-agents cannot call other sub-agents. Only skills orchestrate via Task tool.

References

Usage Guidance
This skill appears coherent and low-risk: it only bundles an orchestration guide and a tiny word-count script. Before installing, consider: (1) Source privacy — the method explicitly sends the full source text to successive subagent/LLM calls, so don't run it on confidential material unless your environment/model policy permits it. (2) Output tradeoffs — forcing identical word counts across iterations can produce dense but potentially opaque summaries (already noted by the author for legal/spec texts). (3) Verify runtime environment if you plan to execute the included script (Python 3.10+). The skill has no hidden network calls, secrets requests, or install downloads.
Capability Analysis
Type: OpenClaw Skill Name: chain-of-density Version: 1.1.0 The skill bundle is benign. The `SKILL.md` provides clear, task-specific instructions for an AI agent to perform Chain-of-Density summarization, without any prompt injection attempts to subvert the agent's behavior. The `scripts/text_metrics.py` is a simple Python script that calculates word, character, and byte counts of text, using only standard libraries and performing no file system access (beyond stdin/stdout), network calls, or system command execution. All components align with the stated purpose of text summarization and density measurement.
Capability Assessment
Purpose & Capability
Name/description (densify summaries) matches the contents: an orchestration SKILL.md describing iterative passes plus a small deterministic text_metrics.py used to enforce word counts. Nothing requested (no env, binaries, or installs) appears unrelated to the stated purpose.
Instruction Scope
Instructions are narrowly scoped to running 5 serial 'cod-iteration' passes, passing the source text each iteration, and parsing a 'Missing_Entities:' line. This is coherent with the method, but it does require sending the full source text to the subagent/LLM each iteration (privacy/data-exposure consideration). No instructions reference unrelated files, system paths, or external endpoints.
Install Mechanism
No install spec is present (instruction-only); the included Python script is small, deterministic, and can be run locally. No remote downloads or archive extraction are required.
Credentials
The skill declares no environment variables, credentials, or config paths. There are no unexpected credential requests in the SKILL.md or the script.
Persistence & Privilege
always is false and the skill does not request persistent system-wide changes or access to other skills' configs. The skill can be invoked normally by the agent without elevated privileges.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install chain-of-density
  3. After installation, invoke the skill by name or use /chain-of-density
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.1.0
Initial publish from Foundry - iterative text densification technique
Metadata
Slug chain-of-density
Version 1.1.0
License
All-time Installs 3
Active Installs 3
Total Versions 1
Frequently Asked Questions

What is Chain of Density?

Iteratively densify text summaries using Chain-of-Density technique. Use when compressing verbose documentation, condensing requirements, or creating executive summaries while preserving information density. It is an AI Agent Skill for Claude Code / OpenClaw, with 1564 downloads so far.

How do I install Chain of Density?

Run "/install chain-of-density" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Chain of Density free?

Yes, Chain of Density is completely free (open-source). You can download, install and use it at no cost.

Which platforms does Chain of Density support?

Chain of Density is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Chain of Density?

It is built and maintained by Vaskin Kissoyan (@killerapp); the current version is v1.1.0.

💬 Comments