使用密度链技术迭代地致密文本摘要。在压缩冗长的文档、压缩需求或在保留信息密度的同时创建执行摘要时使用。
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install chain-of-density或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install chain-of-density⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/chain-of-density/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: 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." license: Apache-2.0 compatibility: "Python 3.10+ (for text_metrics.py script via uv run)" metadata: author: agentic-insights version: "1.2" paper: "From Sparse to Dense: GPT-4 Summarization with Chain of Density Prompting" arxiv: "https://arxiv.org/abs/2309.04269" ---
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.
Chain-of-Density works through multiple iterations:
target_words)- 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.
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 |
cod-iteration agentMissing_Entities: lineIteration 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)
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:
Missing_Entities: line to track entity accumulationThe 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.
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}
| 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.
[Final dense summary text]
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
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.
This skill implements the CoD paper methodology:
cod-iteration)text_metrics.py)Sub-agents cannot call other sub-agents. Only skills orchestrate via Task tool.
安装 密度链 后,可以对 AI 说这些话来触发它
Help me get started with Chain of Density
Explains what Chain of Density does, walks through the setup, and runs a quick demo based on your current project
Use Chain of Density to iteratively densify text summaries using Chain-of-Density technique
Invokes Chain of Density with the right parameters and returns the result directly in the conversation
What can I do with Chain of Density in my product manager workflow?
Lists the top use cases for Chain of Density, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/chain-of-density/ 目录(个人级,所有项目可用),或 .claude/skills/chain-of-density/(项目级)。重启 AI 客户端后,用 /chain-of-density 主动调用,或让 AI 根据上下文自动发现并使用。
密度链 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
密度链 可免费安装使用。请查阅仓库了解许可证信息。
使用密度链技术迭代地致密文本摘要。在压缩冗长的文档、压缩需求或在保留信息密度的同时创建执行摘要时使用。
密度链 属于「Product Manager」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my product manager tasks using Chain of Density
Identifies repetitive steps in your workflow and sets up Chain of Density to handle them automatically