{
  "schemaVersion": "1.0",
  "item": {
    "slug": "chain-of-density",
    "name": "Chain of Density",
    "source": "tencent",
    "type": "skill",
    "category": "AI 智能",
    "sourceUrl": "https://clawhub.ai/killerapp/chain-of-density",
    "canonicalUrl": "https://clawhub.ai/killerapp/chain-of-density",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/chain-of-density",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=chain-of-density",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "SKILL.md",
      "scripts/text_metrics.py"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "Download the package from Yavira.",
        "Extract it into a folder your agent can access.",
        "Paste one of the prompts below and point your agent at the extracted folder."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
        },
        {
          "label": "Upgrade existing",
          "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-23T16:43:11.935Z",
      "expiresAt": "2026-04-30T16:43:11.935Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=4claw-imageboard",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=4claw-imageboard",
        "contentDisposition": "attachment; filename=\"4claw-imageboard-1.0.1.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/chain-of-density"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/chain-of-density",
    "agentPageUrl": "https://openagent3.xyz/skills/chain-of-density/agent",
    "manifestUrl": "https://openagent3.xyz/skills/chain-of-density/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/chain-of-density/agent.md"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "Download the package from Yavira.",
      "Extract it into a folder your agent can access.",
      "Paste one of the prompts below and point your agent at the extracted folder."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
      },
      {
        "label": "Upgrade existing",
        "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "Chain-of-Density Summarization",
        "body": "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."
      },
      {
        "title": "The Method",
        "body": "Chain-of-Density works through multiple iterations:\n\nIteration 1: Create sparse, verbose base summary (4-5 sentences at target_words)\nSubsequent iterations: Each iteration:\n\nIdentify 1-3 missing entities from SOURCE (not summary)\nRewrite summary to include them\nMaintain IDENTICAL word count through compression\n\nKey principle: Never drop entities - only add and compress."
      },
      {
        "title": "Missing Entity Criteria",
        "body": "Each entity added must meet ALL 5 criteria:\n\nCriterionDescriptionRelevantTo the main story/topicSpecificDescriptive yet concise (≤5 words)NovelNot in the previous summaryFaithfulPresent in the source (no hallucination)AnywhereCan be from anywhere in the source"
      },
      {
        "title": "Quick Start",
        "body": "User provides text to summarize\nOrchestrate 5 iterations via cod-iteration agent\nEach iteration reports entities added via Missing_Entities: line\nReturn final summary + entity accumulation history"
      },
      {
        "title": "Orchestration Pattern",
        "body": "Iteration 1: Sparse base (target_words, verbose filler)\n     ↓ Missing_Entities: (none - establishing base)\nIteration 2: +3 entities, compress filler\n     ↓ Missing_Entities: \"entity1\"; \"entity2\"; \"entity3\"\nIteration 3: +3 entities, compress more\n     ↓ Missing_Entities: \"entity4\"; \"entity5\"; \"entity6\"\nIteration 4: +2 entities, tighten\n     ↓ Missing_Entities: \"entity7\"; \"entity8\"\nIteration 5: +1-2 entities, final density\n     ↓ Missing_Entities: \"entity9\"\nFinal dense summary (same word count, 9+ entities)"
      },
      {
        "title": "How to Orchestrate",
        "body": "Iteration 1 - Pass source text only:\n\nTask(subagent_type=\"cod-iteration\", prompt=\"\"\"\niteration: 1\ntarget_words: 80\ntext: [SOURCE TEXT HERE]\n\"\"\")\n\nIterations 2-5 - Pass BOTH previous summary AND source:\n\nTask(subagent_type=\"cod-iteration\", prompt=\"\"\"\niteration: 2\ntarget_words: 80\ntext: [PREVIOUS SUMMARY HERE]\nsource: [ORIGINAL SOURCE TEXT HERE]\n\"\"\")\n\nCritical:\n\nInvoke serially, not parallel\nPass SOURCE text in every iteration for entity discovery\nParse Missing_Entities: line to track entity accumulation"
      },
      {
        "title": "Expected Agent Output Format",
        "body": "The cod-iteration agent returns:\n\nMissing_Entities: \"entity1\"; \"entity2\"; \"entity3\"\n\nDenser_Summary:\n[The densified summary - identical word count to previous]\n\nParse both parts - track entities for history, pass summary to next iteration."
      },
      {
        "title": "Measuring Density",
        "body": "Use scripts/text_metrics.py for deterministic word counts:\n\necho \"your summary text\" | uv run scripts/text_metrics.py words\n# Returns: word count\n\nuv run scripts/text_metrics.py metrics \"your summary text\"\n# Returns: {\"words\": N, \"chars\": N, \"bytes\": N}"
      },
      {
        "title": "Parameters",
        "body": "ParameterDefaultDescriptioniterations5Number of density passes (paper uses 5)target_words80Word count maintained across ALL iterationsreturn_historyfalseInclude intermediate summaries + entities\n\nNote: target_words can be adjusted based on source length and desired output density."
      },
      {
        "title": "Minimal (default)",
        "body": "[Final dense summary text]"
      },
      {
        "title": "With History (return_history=true)",
        "body": "final_summary: |\n  [Dense summary at target_words with accumulated entities]\niterations:\n  - turn: 1\n    missing_entities: \"(none - establishing base)\"\n    words: 80\n    summary: |\n      [Sparse iteration 1]\n  - turn: 2\n    missing_entities: \"entity1; entity2; entity3\"\n    words: 80\n    summary: |\n      [Denser iteration 2]\n  # ... etc\ntotal_entities: 9"
      },
      {
        "title": "When to Use",
        "body": "Verbose documentation exceeding 500 words\nRequirements documents needing condensation\nCreating executive summaries from detailed reports\nCompressing skills that exceed recommended length"
      },
      {
        "title": "When NOT to Use",
        "body": "Legal/compliance text (precision required)\nTutorial content (beginners need explanation)\nAlready concise content (<300 words)\nSpecifications (don't compress specs)"
      },
      {
        "title": "Example",
        "body": "Source (180 words, verbose skill excerpt):\n\nThe name field is a required field that must be present in every skill.\nThe name field identifies the skill and must follow a specific format.\nFor the name field, you should use lowercase letters and hyphens only.\nThe name field can be 1 to 64 characters long. The description field\nis also required and tells agents when to use your skill...\n\nIteration 1 (Sparse, 80 words):\n\nMissing_Entities: (none - establishing base)\n\nDenser_Summary:\nThis 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.\n\nIteration 3 (After 2 passes, same 80 words):\n\nMissing_Entities: \"1-64 characters\"; \"lowercase alphanumeric-hyphens\"; \"Use when phrase\"\n\nDenser_Summary:\nSkills 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.\n\nFinal Iteration 5 (Same 80 words, maximum density):\n\nMissing_Entities: \"Claude Code\"; \"Cursor\"; \"GitHub Copilot\"\n\nDenser_Summary:\nRequired: `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."
      },
      {
        "title": "Architecture Note",
        "body": "This skill implements the CoD paper methodology:\n\nSkill = orchestrator (this file)\nAgent = stateless worker (cod-iteration)\nScript = deterministic utility (text_metrics.py)\n\nSub-agents cannot call other sub-agents. Only skills orchestrate via Task tool."
      },
      {
        "title": "References",
        "body": "Paper: From Sparse to Dense: GPT-4 Summarization with Chain of Density Prompting\nDataset: HuggingFace griffin/chain_of_density"
      }
    ],
    "body": "Chain-of-Density Summarization\n\nCompress 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.\n\nThe Method\n\nChain-of-Density works through multiple iterations:\n\nIteration 1: Create sparse, verbose base summary (4-5 sentences at target_words)\nSubsequent iterations: Each iteration:\nIdentify 1-3 missing entities from SOURCE (not summary)\nRewrite summary to include them\nMaintain IDENTICAL word count through compression\n\nKey principle: Never drop entities - only add and compress.\n\nMissing Entity Criteria\n\nEach entity added must meet ALL 5 criteria:\n\nCriterion\tDescription\nRelevant\tTo the main story/topic\nSpecific\tDescriptive yet concise (≤5 words)\nNovel\tNot in the previous summary\nFaithful\tPresent in the source (no hallucination)\nAnywhere\tCan be from anywhere in the source\nQuick Start\nUser provides text to summarize\nOrchestrate 5 iterations via cod-iteration agent\nEach iteration reports entities added via Missing_Entities: line\nReturn final summary + entity accumulation history\nOrchestration Pattern\nIteration 1: Sparse base (target_words, verbose filler)\n     ↓ Missing_Entities: (none - establishing base)\nIteration 2: +3 entities, compress filler\n     ↓ Missing_Entities: \"entity1\"; \"entity2\"; \"entity3\"\nIteration 3: +3 entities, compress more\n     ↓ Missing_Entities: \"entity4\"; \"entity5\"; \"entity6\"\nIteration 4: +2 entities, tighten\n     ↓ Missing_Entities: \"entity7\"; \"entity8\"\nIteration 5: +1-2 entities, final density\n     ↓ Missing_Entities: \"entity9\"\nFinal dense summary (same word count, 9+ entities)\n\nHow to Orchestrate\n\nIteration 1 - Pass source text only:\n\nTask(subagent_type=\"cod-iteration\", prompt=\"\"\"\niteration: 1\ntarget_words: 80\ntext: [SOURCE TEXT HERE]\n\"\"\")\n\n\nIterations 2-5 - Pass BOTH previous summary AND source:\n\nTask(subagent_type=\"cod-iteration\", prompt=\"\"\"\niteration: 2\ntarget_words: 80\ntext: [PREVIOUS SUMMARY HERE]\nsource: [ORIGINAL SOURCE TEXT HERE]\n\"\"\")\n\n\nCritical:\n\nInvoke serially, not parallel\nPass SOURCE text in every iteration for entity discovery\nParse Missing_Entities: line to track entity accumulation\nExpected Agent Output Format\n\nThe cod-iteration agent returns:\n\nMissing_Entities: \"entity1\"; \"entity2\"; \"entity3\"\n\nDenser_Summary:\n[The densified summary - identical word count to previous]\n\n\nParse both parts - track entities for history, pass summary to next iteration.\n\nMeasuring Density\n\nUse scripts/text_metrics.py for deterministic word counts:\n\necho \"your summary text\" | uv run scripts/text_metrics.py words\n# Returns: word count\n\nuv run scripts/text_metrics.py metrics \"your summary text\"\n# Returns: {\"words\": N, \"chars\": N, \"bytes\": N}\n\nParameters\nParameter\tDefault\tDescription\niterations\t5\tNumber of density passes (paper uses 5)\ntarget_words\t80\tWord count maintained across ALL iterations\nreturn_history\tfalse\tInclude intermediate summaries + entities\n\nNote: target_words can be adjusted based on source length and desired output density.\n\nOutput Format\nMinimal (default)\n[Final dense summary text]\n\nWith History (return_history=true)\nfinal_summary: |\n  [Dense summary at target_words with accumulated entities]\niterations:\n  - turn: 1\n    missing_entities: \"(none - establishing base)\"\n    words: 80\n    summary: |\n      [Sparse iteration 1]\n  - turn: 2\n    missing_entities: \"entity1; entity2; entity3\"\n    words: 80\n    summary: |\n      [Denser iteration 2]\n  # ... etc\ntotal_entities: 9\n\nWhen to Use\nVerbose documentation exceeding 500 words\nRequirements documents needing condensation\nCreating executive summaries from detailed reports\nCompressing skills that exceed recommended length\nWhen NOT to Use\nLegal/compliance text (precision required)\nTutorial content (beginners need explanation)\nAlready concise content (<300 words)\nSpecifications (don't compress specs)\nExample\n\nSource (180 words, verbose skill excerpt):\n\nThe name field is a required field that must be present in every skill.\nThe name field identifies the skill and must follow a specific format.\nFor the name field, you should use lowercase letters and hyphens only.\nThe name field can be 1 to 64 characters long. The description field\nis also required and tells agents when to use your skill...\n\n\nIteration 1 (Sparse, 80 words):\n\nMissing_Entities: (none - establishing base)\n\nDenser_Summary:\nThis 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.\n\n\nIteration 3 (After 2 passes, same 80 words):\n\nMissing_Entities: \"1-64 characters\"; \"lowercase alphanumeric-hyphens\"; \"Use when phrase\"\n\nDenser_Summary:\nSkills 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.\n\n\nFinal Iteration 5 (Same 80 words, maximum density):\n\nMissing_Entities: \"Claude Code\"; \"Cursor\"; \"GitHub Copilot\"\n\nDenser_Summary:\nRequired: `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.\n\nArchitecture Note\n\nThis skill implements the CoD paper methodology:\n\nSkill = orchestrator (this file)\nAgent = stateless worker (cod-iteration)\nScript = deterministic utility (text_metrics.py)\n\nSub-agents cannot call other sub-agents. Only skills orchestrate via Task tool.\n\nReferences\nPaper: From Sparse to Dense: GPT-4 Summarization with Chain of Density Prompting\nDataset: HuggingFace griffin/chain_of_density"
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/killerapp/chain-of-density",
    "publisherUrl": "https://clawhub.ai/killerapp/chain-of-density",
    "owner": "killerapp",
    "version": "1.1.0",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/chain-of-density",
    "downloadUrl": "https://openagent3.xyz/downloads/chain-of-density",
    "agentUrl": "https://openagent3.xyz/skills/chain-of-density/agent",
    "manifestUrl": "https://openagent3.xyz/skills/chain-of-density/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/chain-of-density/agent.md"
  }
}