代理指令伪造
- 作者仓库星标 0
- 作者仓库 skills-registry
- 领域
- 数据
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @tomevault-io · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- Docker
- 运行环境要求
- Docker
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 网络行为
- 允许外网请求
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
在询问任何问题之前先阅读代码库。不要问什么代码已经回答了。
扫描:`AGENTS.md`、`CLAUDE.md`、`GEMINI.md`、`.cursorrules`、`.windsurfrules`、`.github/copilot-instructions.md`、`.github/instructions/*.instructions.md`、`.github/prompts/*.prompt.md`、`.context/`、`.ctx`、 `README.md`、`ARCHITECTURE.md`、`CONTRIBUTING.md`、ADR 目录、格式化程序/linter 配置、`tsconfig`/`pyproject.toml`、`Makefile`/`justfile`、CI/Docker 配置。对于每个文件:主题、陈旧程度、格式/语气。
地图:语言、框架、包管理器、目录结构(2-3 级)、入口点、测试结构、外部集成。
从修改最多的目录中抽取 3-5 个文件作为示例(`git log --stat` 或根据大小/复杂性推断)。检测:命名、错误处理、导入组织、日志记录、测试模式。
`git log` 用于恢复、迁移、约定执行、修补程序 — 每个都编码一条隐式规则。关键词:惯例、相反、恢复、破坏、弃用、不。 PR 访问 (`gh pr list --state merged --limit 30`):扫描审查更正(“nit:”、“使用 X 代替”)、描述中的架构原理、重复反馈。捕获:来源、候选规则、类别(C1-C9)、置信度。如果不可用:在第 2 阶段询问:“您在评论中反复纠正但未记录的模式?”
对于每个现有规则:七个属性得分 (0-7)。标志<=2。 P1 失败(特定/可证伪)= 噪音,无论其他分数如何。代码对齐:已确认 |陈旧|志向 |矛盾|无法验证的覆盖范围:C1 架构、C2 域/业务、C3 约定、C4 集成、C5 操作、C6 测试、C7 安全性、C8 性能、C9 历史决策冗余:由 lint/类型/CI 重复?与其他规则相矛盾?
Greenfield:目标系统、代码揭示的内容、历史记录中的顶级候选规则、最高价值的差距 增强:规则运行状况摘要、首要问题、历史记录中未记录的规则、覆盖范围差距 验证:是否有任何真正重要的“删除”规则? “确认”规则已经过时了吗?哪些历史规则是真正的惯例?哪些差距最重要?
每轮 2-4 个问题。不要转储 20. 在增强模式下,编织三个工作流:验证标记的规则:“此规则说 [X]。仍然准确吗?”填补覆盖范围空白:跳过覆盖良好的类别,专注于空的类别加强薄弱规则:“为什么?否则会出现什么问题?” /“最能体现这一点的文件?”
# Agent Instruction Forge
Exceptional agent instructions encode *specific implicit knowledge*, not generic advice. Generic rules ("write clean code") hurt performance (ETH Zurich 2024: LLM-generated context files reduce success ~3%). What works: non-obvious knowledge every team member carries but no file says.
**Modes** (detected in Phase 1):
- **Greenfield**: No instruction files. Read codebase, extract, synthesize.
- **Augment**: Files exist. Audit, validate against code, fill gaps, strengthen.
- **Interview-Only**: No codebase access. Skip Phase 1 Steps 2-4. Lean on Failure Round + Resource Ingestion. Flag: "Can't validate against code — file paths need manual verification."
---
## Seven Properties of a Great Rule
1. **Specific & falsifiable** — agent can verify compliance. Unfailable = not a rule.
`"Write clean code"` → `"Every external API call must return Result<T, AppError>, never throw."`
2. **Encodes WHY** — without rationale, agents optimize around rules.
`"Don't use console.log"` → `"Use src/lib/logger.ts — console.log bypasses Datadog correlation IDs."`
3. **Born from real failure** — past pain produces specificity.
`"Never add indexes to reservations table without DBA approval — Q2 2024 compound index locked table 47min."`
4. **Scoped correctly** — highest directory where universally true. Test: "Applies to ALL code agent sees in this directory?" If not, push deeper.
5. **Points to canonical example**.
`"New endpoints follow src/api/reservations/create.ts — handler → validation → service → response."`
6. **Includes anti-pattern** — overrides training priors when codebase deviates.
`"We do NOT use repository pattern. Services call Prisma directly."`
7. **Token-efficient**.
`"When writing tests, please make sure to use Vitest and not Jest."` → `"Tests: Vitest, never Jest."`
### Rules Should NOT Contain
- Things fixable in code (better type signature, clearer name, linter rule)
- Things linting already enforces
- Language documentation (agent knows the language)
- Obvious patterns derivable from reading the code
- Aspirational rules nobody follows (document reality unless explicitly marked aspirational)
---
## PHASE 1 — Codebase Discovery (Automated)
Read codebase before asking anything. Don't ask what code already answers.
### Step 1: Discover instruction infrastructure
Scan: `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `.cursorrules`, `.windsurfrules`, `.github/copilot-instructions.md`, `.github/instructions/*.instructions.md`, `.github/prompts/*.prompt.md`, `.context/`, `.ctx`, `README.md`, `ARCHITECTURE.md`, `CONTRIBUTING.md`, ADR dirs, formatter/linter configs, `tsconfig`/`pyproject.toml`, `Makefile`/`justfile`, CI/Docker configs.
For each file: topics, staleness, format/tone.
### Step 2: Codebase topology
Map: languages, frameworks, package managers, directory structure (2-3 levels), entry points, test structure, external integrations.
### Step 3: Pattern extraction
Sample 3-5 files from most-modified directories (`git log --stat` or inferred from size/complexity). Detect: naming, error handling, import organization, logging, test patterns.
### Step 3b: History mining (if git/PR available)
`git log` for reverts, migrations, convention enforcement, hotfixes — each encodes an implicit rule. Keywords: convention, instead, revert, breaking, deprecated, don't.
PR access (`gh pr list --state merged --limit 30`): scan review corrections ("nit:", "use X instead"), architectural rationale in descriptions, repeated feedback. Capture: source, candidate rule, category (C1-C9), confidence.
If unavailable: ask in Phase 2: "Patterns you correct repeatedly in reviews but aren't documented?"
### Step 4: Rule Audit (Augment Mode Only)
For each existing rule:
- **Seven Properties Score** (0-7). Flag <=2. P1 failure (specific/falsifiable) = noise regardless of other scores.
- **Code Alignment**: Confirmed | Stale | Aspirational | Contradicted | Unverifiable
- **Coverage**: C1 Architecture, C2 Domain/Business, C3 Conventions, C4 Integrations, C5 Operations, C6 Testing, C7 Security, C8 Performance, C9 Historical Decisions
- **Redundancy**: duplicated by lint/types/CI? Contradicts other rules?
- **Scope**: over-scoped (push down), under-scoped (pull up), wildcard abuse, missing intermediate levels
Output:
```
Rule | Score | Alignment | Scope | Verdict (Keep/Rewrite/Verify/Remove/Re-scope)
Summary: N total → keep[n] rewrite[n] verify[n] remove[n] re-scope[n]
Coverage: C1[●/◐/○] ... C9[●/◐/○]
Token budget: ~[current] / [limit] — headroom: [remaining]
Scope health: [N] correct, [N] over-scoped, [N] under-scoped
```
### Step 5: Discovery Brief
- **Greenfield**: target system, what code reveals, top candidate rules from history, highest-value gaps
- **Augment**: rule health summary, top issues, undocumented rules from history, coverage gaps
Verify: any "remove" rules actually important? "Confirmed" rules outdated? Which history-surfaced rules are real conventions? Which gaps matter most?
---
## PHASE 2 — Knowledge Extraction (Interactive)
2-4 questions per round. Don't dump 20.
**In Augment mode**, weave three workstreams:
1. **Verify** flagged rules: "This rule says [X]. Still accurate?"
2. **Fill** coverage gaps: skip well-covered categories, focus on empty ones
3. **Strengthen** weak rules: "Why? What goes wrong otherwise?" / "File that best exemplifies this?"
**Prioritize** areas where (a) agent writes code most often, (b) code is most ambiguous, (c) existing rules are weakest.
### Round 1 — Failures (Always Start Here)
Highest-signal source. Ask 2-4:
- "Last time a developer (human or AI) made a frustrating mistake — what happened, what should they have done?"
- "Landmines where the obvious approach leads to subtle bugs?"
- "Most common mistake from new team members?"
- "Recurring annoyances in agent-generated code you fix every time?"
Probe: "Point me to a file?" / "Correct version?" / "Why this way?"
### Round 2 — Conventions
Where codebase deviates from framework defaults — where agent training priors mislead.
- "Where does your codebase intentionally deviate from the framework's recommended approach?"
- "Patterns you enforce in code review that linting/CI doesn't catch?"
- "One rule that eliminates 50% of review nit-picks?"
### Round 3 — Architecture
Module boundaries, data flow, where new code goes.
- "How should an agent decide which module/directory new code goes in?"
- "Files that shouldn't be modified without extra caution?"
- "How does data flow for the most common operation?"
### Round 4 — Integrations (if external services detected)
API quirks, dependency approval process, wrapper conventions.
### Round 5 — Testing
Philosophy, patterns to follow/avoid, mock boundaries.
### Round 6 — Resource Ingestion (optional)
"Any existing resource I should read? (Wiki, ADR, Slack thread, postmortem)" — extract using Seven Properties.
**Adapt** by: codebase type (frontend→components, backend→endpoints), team size (solo→future-self, large→consistency), agent system (Copilot→completion-level, Claude Code→task-level), human energy (target 15-20 min).
---
## PHASE 3 — Synthesis
### Greenfield Mode
```markdown
# [Project] — Agent Instructions
## Philosophy — [2-3 sentences anchoring judgment]
## Critical Rules — [violations break things: what + why + anti-pattern]
## Conventions — [review friction: pattern + example file]
## Architecture — [boundaries, data flow, where new code goes]
## Testing — [philosophy + patterns + mock boundaries]
```
### Augment Mode
Do NOT rewrite from scratch. Produce a reviewable changeset:
1. **Remove** low-signal rules
2. **Rewrite** rules in place, preserving grouping/tone
3. **Add** rules for coverage gaps
4. **Re-scope** rules to appropriate directory
5. Show delta from Phase 1
Per edit: what changed, why. Include before/after example.
### Both Modes
- Scope: root=universal, package-level=local, `applyTo` globs only when truly file-type-specific
- Every rule specific and falsifiable (P1)
- Order by impact (critical first — long files may truncate)
- Match existing format/tone in augment mode
### Token Budgets
| System | Unit | Root limit | Notes |
|--------|------|-----------|-------|
| Copilot | chars | <1000 lines | Code review reads first 4000 chars/file |
| Claude Code | tokens | <4000 | Subdir: <1000 tokens |
| Cursor/Windsurf/AGENTS.md | tokens | ~4000 | Similar to Claude Code |
When WHY and brevity conflict, keep WHY. Main lever: scope rules down to reduce root file size.
---
## PHASE 3b — Adversarial Validation
Before showing rules, stress-test with three isolated subagents receiving ONLY the synthesized file. Read `references/adversarial-validation.md` for prompts.
Run in parallel:
1. **Newcomer** — finds gaps
2. **Prior Override** — checks rules beat common training priors
3. **Contradiction Finder** — finds conflicts and ambiguities
Update rules. Include summary of gaps, weak spots, resolved contradictions.
---
## PHASE 4 — Review & Delivery
Present rules. Iterate on feedback.
**Write to target:**
| System | Files |
|--------|-------|
| Copilot | `.github/copilot-instructions.md` (repo-wide) + `.github/instructions/NAME.instructions.md` (scoped) + `.github/prompts/NAME.prompt.md` |
| Claude Code | `CLAUDE.md` (root + subdirs) |
| Cursor | `.cursorrules` |
| Windsurf | `.windsurfrules` |
| Generic | `AGENTS.md` (root + subdirs) |
If target unclear, ask. If multiple, generate for primary. Copilot always uses three-layer structure.
After delivery: suggest running agent on a real task. Next mistake = next rule. Revisit monthly.
---
> Source: [AndurilCode/craftwork](https://github.com/AndurilCode/craftwork) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-05-23 -->
按说明文件中的顺序排列。
伟大规则的七个属性
规则不应包含
第 1 阶段 — 代码库发现(自动)
第 1 步:发现教学基础设施
步骤 2:代码库拓扑
文件/命令 -> "Write clean code" · "Every external API call must return Result<T, AppError>, never throw." · "Don't use console.log" · "Use src/lib/logger.ts — console.log bypasses Datadog correlation IDs." · "We do NOT use repository pattern. Services call Prisma directly." · "When writing tests, please make sure to use Vitest and not Jest." · "Tests: Vitest, never Jest." · AGENTS.md
内容校验值 -> 89073b8f48e0
当前原文的自动摘译,尚未人工审校。
伟大规则的七个属性
具体且可证伪——代理可以验证合规性。不失败=没有规则。
"Write clean code"→"Every external API call must return Result<T, AppError>, never throw."编码“为什么”——没有理由,智能体围绕规则进行优化。"Don't use console.log"→"Use src/lib/logger.ts — console.log bypasses Datadog correlation IDs."诞生于真正的失败——过去的痛苦产生了特异性。规则不应包含
代码中可修复的内容(更好的类型签名、更清晰的名称、linter 规则) linting 已经强制执行的内容 语言文档(代理了解语言) 可从阅读代码中得出明显的模式 没有人遵循的理想规则(除非明确标记为理想的,否则记录现实)
第 1 步:发现教学基础设施
扫描:
AGENTS.md、CLAUDE.md、GEMINI.md、.cursorrules、.windsurfrules、.github/copilot-instructions.md、.github/instructions/*.instructions.md、.github/prompts/*.prompt.md、.context/、.ctx、README.md、ARCHITECTURE.md、CONTRIBUTING.md、ADR 目录、格式化程序/linter 配置、tsconfig/pyproject.toml、Makefile/justfile、CI/Docker 配置。对于每个文件:主题、陈旧程度、格式/语气。