agent-teams-simplify-and-harden by pskoett/pskoett-ai-skills
npx skills add https://github.com/pskoett/pskoett-ai-skills --skill agent-teams-simplify-and-hardennpx skills add pskoett/pskoett-ai-skills/skills/agent-teams-simplify-and-harden
一个两阶段的团队循环,用于产出生产级质量的代码:实现,然后使用简化 + 加固审查进行审计,接着修复审计发现的问题,然后重新审计,重复此过程直到代码库稳固或达到循环上限。
此技能用一个基于团队的循环替换了标准流水线(执行、评审、学习)的第 2-4 阶段。它可以接在 plan-interview 之后运行,也可以独立运行 —— 所有上游产物都是可选的。
[plan-interview] → [agent-teams-simplify-and-harden] → [self-improvement]
├─ 意图框架(团队负责人)
├─ 实现(并行代理)
├─ 审计(并行代理)
├─ 偏离检查(团队负责人,在轮次之间)
└─ 学习循环输出 → self-improvement
当存在来自 plan-interview 的计划文件时,此技能会从中提取任务。当不存在计划时,团队负责人会运行一个简短的嵌入式规划阶段。上下文浏览作为团队负责人在循环轮次之间的轻量级偏离检查运行 —— 子代理是短生命周期的,不需要它。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
┌──────────────────────────────────────────────────────────┐
│ 团队负责人(你) │
│ │
│ 阶段 1: 实现(+ 在修复轮次中进行文档记录) │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ impl-1 │ │ impl-2 │ │ impl-3 │ ... │
│ │ (通用 │ │ (通用 │ │ (通用 │ │
│ │ 目的) │ │ 目的) │ │ 目的) │ │
│ └──────────┘ └──────────┘ └──────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌─────────────────────────────────────┐ │
│ │ 验证:编译 + 测试 │ │
│ └─────────────────────────────────────┘ │
│ │ │
│ 阶段 2: 简化与加固审计 │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ 简化 │ │ 加固 │ │ 规范 │ ... │
│ │ 审计员 │ │ 审计员 │ │ 审计员 │ │
│ │ (探索) │ │ (探索) │ │ (探索) │ │
│ └──────────┘ └──────────┘ └──────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ 退出条件满足? │
│ 是 → 生成摘要。交付。 │
│ 否 → 带着发现的问题作为任务返回阶段 1 │
│ (最多 3 轮审计) │
└──────────────────────────────────────────────────────────┘
当以下任何一项为真时,循环退出:
low —— 内联修复它们(由团队负责人或单个实现代理)并退出,无需重新审计预算指导:跟踪各轮累积的差异增长。如果修复轮次在原始实现差异之上增加了超过 30%,则收紧范围:跳过中/低严重性的简化发现,只关注加固补丁和规范缺陷。
如果存在计划文件(来自 plan-interview,位于 docs/plans/plan-NNN-<slug>.md 或用用户提供):读取它,提取实现清单,并将其用作步骤 2 的任务列表。
如果不存在计划,运行一个简短的嵌入式规划访谈:
将答案转化为具体的任务列表。这不是一个完整的 plan-interview —— 只需足以将工作分解为可并行化的单元。
意图框架:在创建团队之前,团队负责人发出:
## 意图框架 #1
**成果:** [团队会话将交付什么]
**方法:** [团队结构、代理数量、审计维度]
**约束:** [范围边界、循环上限、预算限制]
**成功标准:** [干净的审计或达到循环上限且所有关键/高严重性问题已解决]
**预估复杂度:** [小 / 中 / 大 —— 基于任务数量和文件数量]
在继续之前与用户确认。这锚定了所有后续的偏离检查。
TeamCreate:
team_name: "<project>-harden"
description: "实现并加固 <description>"
将工作分解为离散的、可并行化的任务。每个任务应足够独立,以便一个代理完成而无需等待其他代理。
TaskCreate for each unit of work:
subject: "实现 <具体事项>"
description: "详细需求、文件路径、验收标准"
activeForm: "正在实现 <事项>"
如果需要,设置依赖关系:
TaskUpdate: { taskId: "2", addBlockedBy: ["1"] }
生成 general-purpose 代理(它们可以读取、写入和编辑文件)。每个任务一个或每个逻辑组一个。并行运行它们。
Task tool (spawn teammate):
subagent_type: general-purpose
team_name: "<project>-harden"
name: "impl-<area>"
mode: bypassPermissions
prompt: |
你是 <project>-harden 团队的一名实现代理。
你的名字是 impl-<area>。
检查 TaskList 中分配给你的任务并完成它们。
完成每个任务后,将其标记为完成并检查是否有更多任务。
质量门控:
- 代码必须能干净编译(替换为你项目的编译命令,例如 bunx tsc --noEmit, cargo build, go build ./...)
- 测试必须通过(替换为你项目的测试命令,例如 bun test, pytest, go test ./...)
- 遵循现有的代码模式和约定
当你所有任务都完成后,通知团队负责人。
监控代理消息。当所有实现代理报告完成时:
在生成审计员之前,收集本次会话中修改的文件列表:
git diff --name-only <base-branch> # 或:git diff --name-only HEAD~N
你将把这个文件列表传递给每个审计员。
生成 Explore 代理(只读 —— 它们不能编辑文件,这可以防止它们静默地“修复”问题,从而违背审计的目的)。每个审计员使用简化与加固方法关注不同的方面。
推荐的审计维度:
| 审计员 | 关注点 | 心态 |
|---|---|---|
| simplify-auditor | 代码清晰度和不必要的复杂性 | "是否有更简单的方式来表达这个?" |
| harden-auditor | 安全性和健壮性缺陷 | "如果恶意人员看到这个,他们会尝试什么?" |
| spec-auditor | 实现与规范/计划的完整性 | "代码是否符合要求?" |
每个审计员的完整提示模板在 references/auditor-prompts.md 中。每个提示都强制执行:只读范围、全新视角开始、结构化的发现格式以及明确的零发现报告。
作为 Explore 代理生成。检查:死代码、命名、控制流、API 表面、过度抽象、整合。将发现分类为外观或重构(重构门槛:"明显错误,而不仅仅是缺陷")。报告文件、行号、类别、修复建议、严重性。
作为 Explore 代理生成。检查:输入验证、错误处理、注入向量、认证/授权、密钥、数据暴露、依赖风险、竞态条件。将发现分类为补丁或安全重构。报告文件、行号、类别、严重性、攻击向量、修复建议。
作为 Explore 代理生成。检查:缺失的功能、不正确的行为、不完整的实现、违反约定、测试覆盖率、验收标准缺陷。将发现分类为缺失、不正确、不完整或未测试。报告文件、行号、类别、规范引用、严重性。
收集所有审计员的发现。对于每个发现:
重构门槛:对于分类为重构或安全重构的发现,在创建任务之前评估重构是否真正必要。门槛是:"高级工程师是否会说当前状态明显错误,而不仅仅是缺陷?" 拒绝那些属于风格偏好或边际改进的重构提议。
退出检查:如果本轮所有发现的严重性均为 low,则内联修复它们并跳过重新审计(参见循环限制)。
创建修复任务时,将文档记录捆绑到每个实现代理的工作中:
修复了你分配的问题后,在你接触过的文件中,对非显而易见的决策添加最多 5 条单行注释:
- 需要超过 5 秒思考"为什么这个存在?"的逻辑
- 变通方法或临时方案,附带上下文和移除条件的 TODO
- 性能选择以及为什么选择当前方法
不要对审计修复本身进行注释 —— 只对原始实现中缺乏解释的决策进行注释。
这使文档记录保持轻量级和范围明确。后续轮次的审计员不应将这些注释标记为发现。
如果有需要修复的发现:
当退出条件满足时:
// TODO 或 // FIXME 注释为本次会话生成最终摘要:
## 加固摘要
**完成的审计轮次:** 2 / 3(最大)
**退出原因:** 干净的审计(所有审计员报告零发现)
### 各轮发现
第 1 轮:
- simplify-auditor: 4 个外观问题,1 个重构提议(已拒绝 —— 风格偏好)
- harden-auditor: 2 个补丁,1 个安全重构(已批准)
- spec-auditor: 1 个缺失功能
第 2 轮:
- simplify-auditor: 0 个发现
- harden-auditor: 0 个发现
- spec-auditor: 0 个发现
### 采取的行动
- 已修复:6 个发现(4 个外观问题,2 个补丁,1 个安全重构,1 个缺失功能 —— 已拒绝的重构除外)
- 已跳过:1 个重构提议(原因:风格偏好,不是缺陷)
- 文档记录:在 2 个文件中添加了 3 条注释
### 未解决的问题
- 无
### 超出范围的观察
- <任何审计员标记的超出范围的项目,供将来参考>
### 学习循环
learning_loop:
target_skill: "self-improvement"
candidates:
- pattern_key: "harden.input_validation"
auditor: "harden-auditor"
rounds_to_resolve: 1
severity: "high"
suggested_rule: "在使用前验证和边界检查外部输入。"
- pattern_key: "simplify.dead_code"
auditor: "simplify-auditor"
rounds_to_resolve: 1
severity: "low"
suggested_rule: "在最终确定前移除死代码和未使用的导入。"
将跨轮次重复出现的审计发现规范化为 pattern_key 条目,使用与 simplify-and-harden 相同的格式。这可以输入到 self-improvement 中,用于跨任务模式跟踪和推广。
根据你的上下文调整格式。目标是清晰地记录发现了什么、修复了什么、跳过了什么及其原因,以及剩余了什么。
向所有代理发送关闭请求,然后删除团队:
SendMessage type: shutdown_request to each agent
TeamDelete
| 代码库 / 任务规模 | 实现代理 | 审计代理 |
|---|---|---|
| 小型(< 10 个文件) | 1-2 | 2(简化 + 加固) |
| 中型(10-30 个文件) | 2-3 | 2-3 |
| 大型(30+ 个文件) | 3-5 | 3(简化 + 加固 + 规范) |
代理越多 = 并行性越高,但协调开销也越大。对于大多数任务,2-3 个实现代理和 2-3 个审计员是最佳选择。
general-purpose —— 它们需要写权限Explore —— 只读可以防止它们静默地"修复"问题,这违背了审计的目的owner,以便代理立即知道要做什么0. 规划:阅读规范(或运行嵌入式访谈),分解为 8 个任务
0b. 发出意图框架 #1,与用户确认
1. TeamCreate: "feature-harden"
2. TaskCreate x8(每个功能一个)
3. 生成 3 个实现代理,每个分配约 3 个任务
4. 等待 → 全部完成 → 编译干净 → 测试通过
5. 收集修改的文件列表(git diff --name-only)
6. 生成 3 个审计员:simplify-auditor, harden-auditor, spec-auditor
7. Simplify-auditor 发现 4 个外观问题 + 1 个重构提议
8. Harden-auditor 发现 2 个补丁 + 1 个安全重构
9. Spec-auditor 发现 1 个缺失功能
10. 团队负责人评估重构(批准安全重构,拒绝简化重构),创建修复 + 文档任务
11. 生成 2 个实现代理进行修复
12. 等待 → 编译干净 → 测试通过
13. 偏离检查:重新阅读意图框架,范围看起来良好
14. 第 2 轮:生成 3 个新的审计员
15. 审计员发现 0 个问题 → 退出条件满足
16. 生成加固摘要 + 学习循环输出
17. 关闭代理,TeamDelete
这些必须在循环退出前通过:
// TODO 或 // FIXME 注释docs/plans/plan-NNN-<slug>.md)。当可用时,从实现清单中提取任务。当不存在时,团队负责人运行嵌入式规划阶段。simplify-and-harden 相同的 pattern_key 格式。此技能用一个基于团队的循环替换了标准流水线的第 2-4 阶段:
plan-interview(可选 —— 或在阶段 0 中进行嵌入式规划)agent-teams-simplify-and-harden(团队负责人 + 意图框架 + 实现 + 审计 + 偏离检查 + 学习循环)self-improvement(消耗学习循环输出以进行跨任务模式跟踪)团队负责人运行自己的意图框架(不从 intent-framed-agent 消耗)和在轮次之间的轻量级上下文浏览偏离检查(不是完整的退出/移交协议)。子代理是短生命周期的,不运行流水线技能。
每周安装次数
329
仓库
GitHub 星标数
75
首次出现
2026 年 2 月 21 日
安全审计
安装于
codex328
gemini-cli327
github-copilot327
cursor327
opencode327
kimi-cli326
npx skills add pskoett/pskoett-ai-skills/skills/agent-teams-simplify-and-harden
A two-phase team loop that produces production-quality code: implement , then audit using simplify + harden passes , then fix audit findings , then re-audit , repeating until the codebase is solid or the loop cap is reached.
This skill replaces stages 2–4 of the standard pipeline (execution, review, learning) with a team-based loop. It can follow plan-interview or run standalone — every upstream artifact is optional.
[plan-interview] → [agent-teams-simplify-and-harden] → [self-improvement]
├─ intent frame (team lead)
├─ implement (parallel agents)
├─ audit (parallel agents)
├─ drift check (team lead, between rounds)
└─ learning loop output → self-improvement
When a plan file from plan-interview exists, the skill extracts tasks from it. When no plan exists, the team lead runs a brief inline planning phase. Context-surfing runs as a lightweight drift check for the team lead between loop rounds — sub-agents are short-lived and don't need it.
┌──────────────────────────────────────────────────────────┐
│ TEAM LEAD (you) │
│ │
│ Phase 1: IMPLEMENT (+ document pass on fix rounds) │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ impl-1 │ │ impl-2 │ │ impl-3 │ ... │
│ │ (general │ │ (general │ │ (general │ │
│ │ purpose) │ │ purpose) │ │ purpose) │ │
│ └──────────┘ └──────────┘ └──────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌─────────────────────────────────────┐ │
│ │ Verify: compile + tests │ │
│ └─────────────────────────────────────┘ │
│ │ │
│ Phase 2: SIMPLIFY & HARDEN AUDIT │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ simplify │ │ harden │ │ spec │ ... │
│ │ auditor │ │ auditor │ │ auditor │ │
│ │ (Explore)│ │ (Explore)│ │ (Explore)│ │
│ └──────────┘ └──────────┘ └──────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ Exit conditions met? │
│ YES → Produce summary. Ship it. │
│ NO → back to Phase 1 with findings as tasks │
│ (max 3 audit rounds) │
└──────────────────────────────────────────────────────────┘
The loop exits when ANY of these are true:
low -- fix them inline (team lead or a single impl agent) and exit without re-auditingBudget guidance: Track the cumulative diff growth across rounds. If fix rounds have added more than 30% on top of the original implementation diff, tighten the scope: skip medium/low simplify findings and focus only on harden patches and spec gaps.
If a plan file exists (from plan-interview at docs/plans/plan-NNN-<slug>.md or user-provided): read it, extract the implementation checklist, and use those as the task list for step 2.
If no plan exists , run a brief inline planning interview:
Turn the answers into a concrete task list. This is not a full plan-interview — just enough to break the work into parallelizable units.
Intent frame: Before creating the team, the team lead emits:
## Intent Frame #1
**Outcome:** [What the team session will deliver]
**Approach:** [Team structure, number of agents, audit dimensions]
**Constraints:** [Scope boundaries, loop cap, budget limits]
**Success criteria:** [Clean audit or loop cap with all critical/high resolved]
**Estimated complexity:** [Small / Medium / Large — based on task count and file count]
Confirm with the user before proceeding. This anchors all subsequent drift checks.
TeamCreate:
team_name: "<project>-harden"
description: "Implement and harden <description>"
Break the work into discrete, parallelizable tasks. Each task should be independent enough for one agent to complete without blocking on others.
TaskCreate for each unit of work:
subject: "Implement <specific thing>"
description: "Detailed requirements, file paths, acceptance criteria"
activeForm: "Implementing <thing>"
Set up dependencies if needed:
TaskUpdate: { taskId: "2", addBlockedBy: ["1"] }
Spawn general-purpose agents (they can read, write, and edit files). One per task or one per logical group. Run them in parallel.
Task tool (spawn teammate):
subagent_type: general-purpose
team_name: "<project>-harden"
name: "impl-<area>"
mode: bypassPermissions
prompt: |
You are an implementation agent on the <project>-harden team.
Your name is impl-<area>.
Check TaskList for your assigned tasks and complete them.
After completing each task, mark it completed and check for more.
Quality gates:
- Code must compile cleanly (substitute your project's compile
command, e.g. bunx tsc --noEmit, cargo build, go build ./...)
- Tests must pass (substitute your project's test command,
e.g. bun test, pytest, go test ./...)
- Follow existing code patterns and conventions
When all your tasks are done, notify the team lead.
Monitor agent messages. When all implementation agents report done:
Before spawning auditors, collect the list of files modified in this session:
git diff --name-only <base-branch> # or: git diff --name-only HEAD~N
You will pass this file list to each auditor.
Spawn Explore agents (read-only -- they cannot edit files, which prevents them from "fixing" issues silently). Each auditor covers a different concern using the Simplify & Harden methodology.
Recommended audit dimensions:
| Auditor | Focus | Mindset |
|---|---|---|
| simplify-auditor | Code clarity and unnecessary complexity | "Is there a simpler way to express this?" |
| harden-auditor | Security and resilience gaps | "If someone malicious saw this, what would they try?" |
| spec-auditor | Implementation vs spec/plan completeness | "Does the code match what was asked for?" |
Full prompt templates for each auditor are in references/auditor-prompts.md. Each prompt enforces: read-only scope, fresh-eyes start, structured finding format, and explicit zero-findings reporting.
Spawned as Explore agent. Checks: dead code, naming, control flow, API surface, over-abstraction, consolidation. Categorizes findings as cosmetic or refactor (refactor bar: "clearly wrong, not just imperfect"). Reports file, line, category, fix, severity.
Spawned as Explore agent. Checks: input validation, error handling, injection vectors, auth/authz, secrets, data exposure, dependency risk, race conditions. Categorizes findings as patch or security refactor. Reports file, line, category, severity, attack vector, fix.
Spawned as Explore agent. Checks: missing features, incorrect behavior, incomplete implementation, contract violations, test coverage, acceptance criteria gaps. Categorizes findings as missing , incorrect , incomplete , or untested. Reports file, line, category, spec reference, severity.
Collect findings from all auditors. For each finding:
Refactor gate: For findings categorized as refactor or security refactor , evaluate whether the refactor is genuinely necessary before creating a task. The bar: "Would a senior engineer say the current state is clearly wrong, not just imperfect?" Reject refactor proposals that are style preferences or marginal improvements.
Exit check: If all findings in this round are severity low, fix them inline and skip re-auditing (see Loop Limits).
When creating fix tasks, bundle a document pass into each implementation agent's work:
After fixing your assigned issues, add up to 5 single-line comments across the files you touched on non-obvious decisions:
- Logic that needs more than 5 seconds of "why does this exist?" thought
- Workarounds or hacks, with context and a TODO for removal conditions
- Performance choices and why the current approach was picked
Do NOT comment on the audit fixes themselves -- only on decisions from the original implementation that lack explanation.
This keeps the document pass lightweight and scoped. Auditors in subsequent rounds should not flag these comments as findings.
If there are findings to fix:
When exit conditions are met:
// TODO or // FIXME comments introduced without corresponding tasksProduce a final summary for the session:
## Hardening Summary
**Audit rounds completed:** 2 of 3 max
**Exit reason:** Clean audit (all auditors reported zero findings)
### Findings by round
Round 1:
- simplify-auditor: 4 cosmetic, 1 refactor (rejected -- style preference)
- harden-auditor: 2 patches, 1 security refactor (approved)
- spec-auditor: 1 missing feature
Round 2:
- simplify-auditor: 0 findings
- harden-auditor: 0 findings
- spec-auditor: 0 findings
### Actions taken
- Fixed: 6 findings (4 cosmetic, 2 patches, 1 security refactor, 1 missing feature -- rejected refactor excluded)
- Skipped: 1 refactor proposal (reason: style preference, not a defect)
- Document pass: 3 comments added across 2 files
### Unresolved
- None
### Out-of-scope observations
- <any out-of-scope items auditors flagged, for future reference>
### Learning loop
learning_loop:
target_skill: "self-improvement"
candidates:
- pattern_key: "harden.input_validation"
auditor: "harden-auditor"
rounds_to_resolve: 1
severity: "high"
suggested_rule: "Validate and bound-check external inputs before use."
- pattern_key: "simplify.dead_code"
auditor: "simplify-auditor"
rounds_to_resolve: 1
severity: "low"
suggested_rule: "Remove dead code and unused imports before finalizing."
Normalize recurring audit findings across rounds into pattern_key entries using the same format as simplify-and-harden. This feeds into self-improvement for cross-task pattern tracking and promotion.
Adapt the format to your context. The goal is a clear record of what was found, what was fixed, what was skipped and why, and what remains.
Send shutdown requests to all agents, then delete the team:
SendMessage type: shutdown_request to each agent
TeamDelete
| Codebase / Task Size | Impl Agents | Audit Agents |
|---|---|---|
| Small (< 10 files) | 1-2 | 2 (simplify + harden) |
| Medium (10-30 files) | 2-3 | 2-3 |
| Large (30+ files) | 3-5 | 3 (simplify + harden + spec) |
More agents = more parallelism but more coordination overhead. For most tasks, 2-3 implementation agents and 2-3 auditors is the sweet spot.
general-purpose -- they need write accessExplore -- read-only prevents them from silently "fixing" things, which defeats the purpose of auditingowner on tasks via TaskUpdate so agents know what to work on immediately0. Plan: Read spec (or run inline interview), break into 8 tasks
0b. Emit Intent Frame #1, confirm with user
1. TeamCreate: "feature-harden"
2. TaskCreate x8 (one per feature)
3. Spawn 3 impl agents, assign ~3 tasks each
4. Wait → all done → compile clean → tests pass
5. Collect modified file list (git diff --name-only)
6. Spawn 3 auditors: simplify-auditor, harden-auditor, spec-auditor
7. Simplify-auditor finds 4 cosmetic + 1 refactor proposal
8. Harden-auditor finds 2 patches + 1 security refactor
9. Spec-auditor finds 1 missing feature
10. Team lead evaluates refactors (approve security refactor,
reject simplify refactor), creates fix + document tasks
11. Spawn 2 impl agents for fixes
12. Wait → compile clean → tests pass
13. Drift check: re-read intent frame, scope looks good
14. Round 2: Spawn 3 fresh auditors
15. Auditors find 0 issues → exit condition met
16. Produce hardening summary + learning loop output
17. Shutdown agents, TeamDelete
These must pass before the loop can exit:
// TODO or // FIXME comments introduced without corresponding tasksdocs/plans/plan-NNN-<slug>.md). When available, tasks are extracted from the implementation checklist. When absent, the team lead runs an inline planning phase.pattern_key format as simplify-and-harden.This skill replaces stages 2–4 of the standard pipeline with a team-based loop:
plan-interview (optional — or inline planning in Phase 0)agent-teams-simplify-and-harden (team lead + intent frame + implement + audit + drift checks + learning loop)self-improvement (consumes learning loop output for cross-task pattern tracking)The team lead runs its own intent frame (not consumed from intent-framed-agent) and lightweight context-surfing drift checks between rounds (not the full exit/handoff protocol). Sub-agents are short-lived and do not run pipeline skills.
Weekly Installs
329
Repository
GitHub Stars
75
First Seen
Feb 21, 2026
Security Audits
Gen Agent Trust HubFailSocketWarnSnykWarn
Installed on
codex328
gemini-cli327
github-copilot327
cursor327
opencode327
kimi-cli326
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
138,300 周安装