dg-piagent

dg-piagent is a skill for Claude Code, Codex from buchidonggua/dg-ai-notes. It costs 205 tokens per session (4,497 once invoked), scanned A, original, MIT.

A development guide for the pi-agent software kit, used to build and customize coding agents. It covers agents, tools, prompts, sessions, models, authentication, and connected files.

In plain words
What is it for?
Use it to create agents, add tools and extensions, change system instructions, manage sessions and models, handle authentication, load skills or context files, and draft model configuration for an internal API.
Why use it?
It helps developers use the kit's programming interface correctly and keep their setup aligned with a specific version. It also helps assess whether a private company language-model service can connect to it.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: mentions subagents; mentions AGENTS.md.

Good fit Use it to create agents, add tools and extensions, change system instructions, manage sessions and models, handle authentication, load skills or context files, and draft model configuration for an internal API.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/buchidonggua/dg-ai-notes/dg-piagent
About the project

dg-ai-notes is a tutorial and source-code study project about Pi-Agent, an SDK for building AI agents, with examples in TypeScript and Python. It helps developers understand agent loops, tools, messages, sessions, events, extensions, and the construction of deployable agents. Its catalogue skill provides an assistant for developing with the Pi-Agent SDK.

buchidonggua/dg-ai-notes · 2,707 stars · on GitHub · dg-ai-notes.pages.dev

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add buchidonggua/dg-ai-notes --skill dg-piagent
Clone the repo
git clone --depth 1 https://github.com/buchidonggua/dg-ai-notes

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for dg-piagent

README.md
[![agentmods](https://agentmods.dev/badge/skills/buchidonggua/dg-ai-notes/dg-piagent/github.svg)](https://agentmods.dev/skills/buchidonggua/dg-ai-notes/dg-piagent)
Your own site
<a href="https://agentmods.dev/skills/buchidonggua/dg-ai-notes/dg-piagent"><img src="https://agentmods.dev/badge/skills/buchidonggua/dg-ai-notes/dg-piagent/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for dg-piagent

Your own site · 80×15
<a href="https://agentmods.dev/skills/buchidonggua/dg-ai-notes/dg-piagent"><img src="https://agentmods.dev/badge/skills/buchidonggua/dg-ai-notes/dg-piagent.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 205 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,497 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00205 $0.04497
Opus 5 $0.00102 $0.02249
Sonnet 5 $0.00041 $0.00899
Haiku 4.5 $0.00020 $0.00450

Measured 10d ago against content hash 1f489cea7120, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

dg-piagent scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/dg-piagent/SKILL.md · 278 lines

How it starts

The opening of the file, as written. The whole thing — 278 lines — stays where its author put it; the contents beside it link to each section on GitHub.

pi-agent SDK 开发指南

⚠️ 版本基线: 本 skill 的 API 描述已对齐到 pi-coding-agent v0.83.0

遇 pi-ai import 失败时,先查 node_modules/@earendil-works/pi-ai/dist/compat.d.tsexport * 列表,确认符号归属哪个入口。

版本协议 ⭐

本 skill 核对到顶部基线版本(当前 v0.83.0)。涉及安装/升级 pi-agent 时遵循三步:

  1. 默认对齐:引导安装一律用基线版本 npm install @earendil-works/[email protected]不装 latest——skill 的 API 描述精确核对到基线版本,装 latest 会立即漂移。场景文档里的安装命令同样以基线版本为准。

  2. 升级前评估:当任务涉及安装/升级(或用户问版本)时,先跑 npm view @earendil-works/pi-coding-agent version 拿 latest 与基线对比。若不同,联网查该版本 CHANGELOG/release notes,从 SDK 二次开发角度评估(新功能 / 破坏性变更),给用户简短建议,由用户决定是否升级。日常开发(项目已装好)不触发。

  3. 升级即更新 skill:若用户同意升到 X.Y.Z,安装后按 skill-maintenance.md 流程,对照新版 dist/**/*.d.ts + CHANGELOG 审查 skill 差异,产出更新清单,报用户确认后再改,并同步更新顶部基线版本号。

变更查阅渠道(第 2/3 步执行依据):

渠道 路径/命令 适用阶段
① node_modules CHANGELOG <proj>/node_modules/@earendil-works/pi-coding-agent/CHANGELOG.md(标准 Keep-a-Changelog,按 ## [版本号] 分节,含 Breaking Changes) 升级后(第3步)
② GitHub github.com/earendil-works/pipackages/coding-agent/CHANGELOG.md 或 Releases 升级前(第2步,需联网)

时序关键:升级前 node_modules 仍是旧版,渠道①看不到新版内容,第 2 步必须用②(GitHub)。

Overview

pi-agent 是基于事件驱动的 Agent 开发框架(@earendil-works/pi-coding-agent)。核心心智模型:

createAgentSession()  ← 组装入口(Provider + 工具 + 资源)
       │
       ├── session.prompt(text)          ← 驱动 Agent 主循环
       │
       ├── session.subscribe(handler)    ← 外部订阅层
       │     多数事件与扩展层共有(turn_*/message_*/tool_execution_*/agent_start/agent_end/agent_settled)
       │     外部层独有: queue_update / compaction_* / session_info_changed 等 session 状态事件
       │
       └── 扩展(pi.on)                   ← 内部扩展层
             扩展独有(仅这 6 个 subscribe 收不到):
               context / tool_call / tool_result / before_agent_start / input / model_select

关键区分(最大集成坑): 有 6 个扩展独有事件——context / tool_call / tool_result / before_agent_start / input / model_select。 在 server 层用 session.subscribe 监听这 6 个会静默失败(handler 被调用但 type 分支永不命中,无报错)。 对策: 需要抓这 6 个事件的逻辑(日志/trace/拦截/抓这 6 个事件的数据落库)必须写成扩展走 pi.on。⚠️ 但注意——pi.on handler 被派发方 await,落库这类慢 I/O 必须 fire-and-forget(推队列后台写),否则阻塞 agent loop。若只需存 message_*/turn_*/tool_execution_* 等 subscribe 收得到的事件,落库优先走 session.subscribe(不 await listener,可直接 await 写库,零阻塞)。详见 04-events.md 关键细节。 详见 Common Mistakessdk_doc/04-events.md

Read the full file on GitHub · 278 lines

Files

What ships with it

60 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 278 lines · 205 tokens per session scan A 1f489cea7120

Subscribe to this mod's changes

dg-piagent is a skill published in the GitHub repository buchidonggua/dg-ai-notes (2,707 stars, last pushed 18d ago), licensed MIT. It adds 205 tokens to every session and 4,497 once invoked, about $0.0010 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.