返回技能列表

du-dum

pjt222
更新于 2 days ago
6 次查看
17
2
17
在 GitHub 上查看
aiapidesigndata

关于

The du-dum skill implements a two-clock architecture to separate continuous, cheap observation from occasional, expensive decision-making in autonomous agents. It uses a fast clock to collect data into a digest and a slow clock that only triggers costly actions (like LLM calls) when pending work is found. This pattern is ideal for optimizing cost and performance in agent loops where most observation cycles require no action.

快速安装

Claude Code

推荐
主要方式
npx skills add pjt222/agent-almanac -a claude-code
插件命令备选方式
/plugin add https://github.com/pjt222/agent-almanac
Git 克隆备选方式
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/du-dum

在 Claude Code 中复制并粘贴此命令以安装该技能

技能文档

Du-Dum: Batch-Then-Act Pattern

Split observe/act → 2 clocks diff freq. Fast (analysis) = cheap → writes digest. Slow (action) = reads digest → acts if pending. Digest empty → exit immediate. Zero cost idle.

Name = heartbeat: du-dum. First beat (du) observes. Second (dum) acts. Mostly only first fires.

Use When

  • Autonomous agent budget → observe often, act rare
  • Heartbeat calls LLM every tick → waste
  • Observe cheap (API read, file parse, log scan), act expensive (LLM, write, notify)
  • Decoupled fail → observe fails → last digest still valid
  • Cron agent → analysis + action = separate jobs

In

  • Required: Data sources fast clock observes (APIs, files, logs, feeds)
  • Required: Action slow clock takes when pending
  • Optional: Fast interval (default: 4h)
  • Optional: Slow interval (default: 1/day)
  • Optional: Daily cost ceiling
  • Optional: Digest format (md, JSON, YAML)

Do

Step 1: Identify 2 Clocks

Split work → observe (cheap, freq) vs act (exp, rare).

  1. List every op
  2. Classify → observe (reads → summary) or act (LLM/write/msg)
  3. Verify split: observe ≈0 marginal, act = expensive
  4. Assign freq: fast catches events, slow meets response-time
ClockCostFreqExample
Fast (analysis)Cheap: API read, parse, no LLM4-6x/dayGitHub notifs, RSS, logs
Slow (action)Exp: LLM, write1x/dayCompose reply, dashboard, alert

→ Clean split. Every op on 1 clock. Fast = no LLM. Slow = no gather.

If err: op needs both → split. Fast collects raw → digest. Slow summarizes. Digest = boundary.

Step 2: Design Digest Format

Digest = low-bandwidth msg between clocks. Compact, human-readable, parseable.

  1. Define path + format (md recommended)
  2. Header: timestamp + source meta
  3. "Pending" section → items needing action
  4. "Status" section → current state
  5. Clear empty indicator (pending: none)

Example:

# Digest — 2026-03-22T06:30:00Z

## Pending

- PR #42 needs review response (opened 2h ago, author requested feedback)
- Issue #99 has new comment from maintainer (action: reply)

## Status

- Last analyzed: 2026-03-22T06:30:00Z
- Sources checked: github-notifications, rss-feed, error-log
- Items scanned: 14
- Items pending: 2

Empty:

# Digest — 2026-03-22T06:30:00Z

## Pending

(none)

## Status

- Last analyzed: 2026-03-22T06:30:00Z
- Sources checked: github-notifications, rss-feed, error-log
- Items scanned: 8
- Items pending: 0

→ Template w/ clear pending/empty. Slow clock decides by single check.

If err: digest >50 lines → too much raw. Move details to data file, digest = summary + pointers.

Step 3: Fast Clock (Analysis)

Observation scripts on fast schedule.

  1. 1 script per source (indep failures)
  2. Each reads, extracts, appends/rewrites digest
  3. File lock / atomic write → no partial digest
  4. Log run (ts, items, errs) → separate log
  5. Never LLM / write beyond digest
# Pseudocode: analyze-notifications.sh
fetch_notifications()
filter_actionable(notifications)
format_as_digest_entries(filtered)
atomic_write(digest_path, entries)
log("analyzed {count} notifications, {pending} actionable")

Cron:

# Fast clock: analyze every 4 hours
30 */4 * * *  /path/to/analyze-notifications.sh >> /var/log/analysis.log 2>&1
0  6   * * *  /path/to/analyze-pr-status.sh     >> /var/log/analysis.log 2>&1

→ Analysis scripts update digest. Indep → 1 fails, others continue.

If err: source down → log + keep prev entries. Never clear on source fail → stale > missing.

Step 4: Slow Clock (Action)

Reads digest, decides act.

  1. Read digest (Step 0)
  2. Pending empty/"none" → exit immediate w/ log
  3. Items pending → exp op (LLM, compose)
  4. After act → clear/archive processed entries
  5. Log run (items, cost, duration)
# Pseudocode: heartbeat.sh (the slow clock)
digest = read_file(digest_path)

if digest.pending is empty:
    log("heartbeat: nothing pending, exiting")
    exit(0)

# Only reaches here if work exists
response = call_llm(digest.pending, system_prompt)
execute_actions(response)
archive_digest(digest_path)
log("heartbeat: processed {count} items, cost: {tokens} tokens")

Cron:

# Slow clock: act once per day at 7am
0 7 * * *  /path/to/heartbeat.sh >> /var/log/heartbeat.log 2>&1

→ Script exits <1s idle. Active → processes + clears.

If err: LLM fails → no clear. Items retry next cycle. Consider retry counter → no infinite retry.

Step 5: Idle Detection

Savings = idle detect. Distinguish "nothing"/"something" min overhead.

  1. Idle check = single fast op (file read + str check)
  2. Verify idle path: 0 ext calls (no API/LLM/net)
  3. Measure duration <1s
  4. Log idle differently from active
# Minimal idle check
if grep -q "^(none)$" "$DIGEST_PATH" || grep -q "pending: 0" "$DIGEST_PATH"; then
    echo "$(date -u +%FT%TZ) heartbeat: idle" >> "$LOG_PATH"
    exit 0
fi

→ Idle = 1 file read + str match. No net, no spawn.

If err: unreliable check (false pos = missed work, false neg = waste LLM) → simplify digest. Single bool field (has_pending: true/false) most reliable.

Step 6: Validate Cost Model

Calculate → confirm savings.

  1. Fast runs/day: fast_runs = 24 / fast_interval_hours
  2. Slow runs/day: typ 1
  3. Observe cost: fast_runs * cost_per_analysis_run (~$0 no LLM)
  4. Act cost: active_days_fraction * cost_per_action_run
  5. Idle cost: (1 - active_days_fraction) * cost_per_idle_check (~$0)
  6. Compare w/ original
ArchitectureDaily (active)Daily (idle)Monthly (80% idle)
Single loop (LLM every 30min)$13.74/37h$13.74/37h~$400
Du-dum (6 analyses + 1 action)$0.30$0.00~$6

→ Model shows ≥10x cheaper on idle days.

If err: no savings → (a) fast too freq, (b) fast has hidden LLM, (c) rarely idle. Du-dum wants high idle ratio. Always active → simpler polling.

Check

  • Fast/slow split clean → no LLM in fast path
  • Digest has clear empty indicator
  • Idle detect <1s, 0 ext calls
  • Fast fail → no digest corrupt (stale preserved)
  • Slow fail → no clear pending (retry next)
  • Cost model ≥10x savings idle days
  • Both clocks log runs
  • Digest bounded (archive/clear after process)

Traps

  • Digest unbounded: Append no clear → growing log. Always clear/archive after act.
  • Fast too fast: Analysis every 5min, events daily → wastes API/IO. Match freq to event rate.
  • Slow too slow: Once/day but need same-hour → too slow. Increase freq or urgent shortcut.
  • LLM in fast: Breaks cost model. Audit fast scripts → 0 LLM. Defer summary to slow.
  • Coupled fast scripts: 1 depends on another → cascade fail. Keep indep → own source, own section.
  • Silent idle log: No log → can't distinguish "running idle" vs "crashed". Always log idle.
  • Clear digest on analysis fail: Source down → no empty write. Slow would skip actual pending. Preserve last good.

  • manage-token-budget — cost framework du-dum makes practical; du-dum = pattern, budget = accounting
  • circuit-breaker-pattern — failure case (tools breaking); du-dum = normal case (nothing to do). Together: du-dum idle, circuit-breaker fail
  • observe — methodology for fast clock; du-dum structures when observes become actionable via digest
  • forage-resources — strategic explore layer; du-dum = execution rhythm
  • coordinate-reasoning — stigmergic signaling; digest = stigmergy (indirect coord via env artifact)

GitHub 仓库

pjt222/agent-almanac
路径: i18n/caveman-ultra/skills/du-dum
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

相关推荐技能

content-collections

Content Collections 是一个 TypeScript 优先的构建工具,可将本地 Markdown/MDX 文件转换为类型安全的数据集合。它专为构建博客、文档站和内容密集型 Vite+React 应用而设计,提供基于 Zod 的自动模式验证。该工具涵盖从 Vite 插件配置、MDX 编译到生产环境部署的完整工作流。

查看技能

polymarket

这个Claude Skill为开发者提供完整的Polymarket预测市场开发支持,涵盖API调用、交易执行和市场数据分析。关键特性包括实时WebSocket数据流,可监控实时交易、订单和市场动态。开发者可用它构建预测市场应用、实施交易策略并集成实时市场预测功能。

查看技能

creating-opencode-plugins

该Skill帮助开发者创建OpenCode插件,用于接入命令、文件、LSP等25+种事件。它提供了插件结构、事件API规范和JavaScript/TypeScript实现模式,适合需要拦截操作、扩展功能或自定义事件处理的场景。开发者可通过它快速构建响应式模块来增强OpenCode AI助手的能力。

查看技能

sglang

SGLang是一个专为LLM设计的高性能推理框架,特别适用于需要结构化输出的场景。它通过RadixAttention前缀缓存技术,在处理JSON、正则表达式、工具调用等具有重复前缀的复杂工作流时,能实现极速生成。如果你正在构建智能体或多轮对话系统,并追求远超vLLM的推理性能,SGLang是理想选择。

查看技能