当前位置: 首页 > Skill >

Agentskill

Agentskill

Agentskill

让任何代理生成的代码与现有代码库无法区分。

1.4.0 2026.11.21 764
获取Skill文件查看使用说明
作 者:周知 许可证: 更新时间:2026.11.21
本文目录展开

SKILL.md — agentskill

Operational spec for agentskill. This file governs when to invoke, what to run, and in what order. For how to generate AGENTS.md, read SYSTEM.md — it is the behavioral bible. These two files are complementary. Neither is sufficient alone.

Purpose

Analyze one or more code repositories. Extract exact coding conventions. Synthesize a precise, forensic AGENTS.md that allows any agent to produce code indistinguishable from the existing codebase.

Generation Modes

agentskill supports two generation modes. The mode determines who authors the final document:

AI-led generation (skill mode — this file)

The model synthesizes the final AGENTS.md itself. CLI analyzer commands are used only for evidence gathering — to extract repository facts that the model cannot derive reliably from reading source files alone.

In skill mode, never call agentskill generate to produce the final AGENTS.md. The model is the author. Analyzer output is the raw material, not the finished product.

CLI static generation (operator mode)

The user runs agentskill generate directly. The packaged runtime emits markdown automatically. This is appropriate for deterministic direct generation without an LLM in the loop.

Use CLI generation only in non-LLM static/operator workflows where the user explicitly wants tool-generated markdown rather than AI-authored synthesis.

Rule: AI Authorship

The model authors the final document in skill mode.

  • Do not use agentskill generate or python scripts/generate.py to produce the final AGENTS.md when operating as a skill or in any AI-assisted workflow.
  • Use analyzer commands (analyze, scan, measure, config, git, graph, symbols, tests) to gather repository facts.
  • The final generated markdown must be synthesized by the AI from analyzer evidence, direct source file reads, and supporting documentation.
  • Treat analyzer outputs as evidence, not as the final authored document.

Trigger Phrases

Invoke this skill when the user says any of the following — or a close paraphrase:

  • "Generate an AGENTS.md"
  • "Extract my coding style"
  • "Analyze my repo for conventions"
  • "Create a style guide from my code"
  • "Update my AGENTS.md"
  • "My agent doesn't write code the way I do — fix it"

Do not invoke this skill for general code review, refactoring, or style advice not tied to generating AGENTS.md.

File Ecosystem

File Role
SKILL.md (this file) Operational spec: workflow, scripts, fallbacks, uncertainty handling
SYSTEM.md Behavioral spec: what to generate, section by section, and how to evaluate it
references/GOTCHAS.md Extraction errors to avoid; update this file whenever a new failure mode is discovered
examples/ Analyzer fixtures plus reference AGENTS.md examples; consult when handling an unfamiliar repo shape

Maintenance rule: If SYSTEM.md and SKILL.md ever contradict each other, SYSTEM.md wins. Fix SKILL.md to match.

Availability rule: If this skill was downloaded from ClawHub, or if examples/ is unavailable locally, do not consult examples/; skip it to avoid execution errors.

Workflow

Execute these steps in order. Do not skip steps. Do not reorder steps.

Step 1 — Collect

Ask the user for repo path(s). Accept one or more. Confirm before proceeding.

Provide the path(s) to your repository or repositories.
One path per repo. Multiple repos are supported.

If the user provides a monorepo, note this explicitly — steps 3 and 4 of SYSTEM.md apply.

Step 2 — Scan

Run the scan script to get the directory tree and source file inventory.

python scripts/scan.py <repo>

Outputs: annotated directory tree, source files grouped by language with line counts.

Use the output to decide what to read — largest files first, entry points and core modules before tests.

If the script fails: Manually walk the directory tree using available file tools. Note in your working context that the scan was manual — this affects reliability of the file inventory for large repos.

Step 3 — Measure

Run the measurement script to get exact formatting metrics.

python scripts/measure.py <repo>
python scripts/measure.py <repo> --lang python   # single language

Outputs: per-language indentation unit and size, line length percentiles (p95 and p99), blank line distributions between top-level definitions and between methods, trailing newline convention.

If the script fails: Proceed without exact measurements. Mark all formatting measurements in the generated AGENTS.md as [tentative] and note that manual inspection was used. Do not estimate percentiles — state the observable range instead.

Step 4 — Config

Run the config script to detect formatters, linters, and their exact settings.

python scripts/config.py <repo>

Outputs: per-language tool detection with relevant config excerpts — [tool.black], [tool.ruff], [tool.mypy], tsconfig.json, .prettierrc, .editorconfig, and equivalents.

If the script fails: Read config files directly from disk. Prioritize: pyproject.toml, package.json, .editorconfig, any .*rc files at the repo root. Do not guess what a formatter enforces — only document what you can read from config.

Step 5 — Read SYSTEM.md

Read SYSTEM.md fully before writing a single line of AGENTS.md.

Do not rely on memory of previous runs. Read it fresh every time.

Step 6 — Read Source Files

Read actual source files directly. Use the file inventory from Step 2 to choose what to read.

Minimum per language before drafting any section:

Priority What to read
1st Entry point and CLI files
2nd Core logic modules (largest non-test files)
3rd At least one test file
4th Package manifest (pyproject.toml, Cargo.toml, package.json, etc.)
5th At least one utility or helper module

Minimum count: 3–5 files per language. For monorepos, 3–5 files per service.

Do not begin drafting until this step is complete.

Step 7 — Check GOTCHAS.md

Read references/GOTCHAS.md before drafting.

This file contains extraction and synthesis errors discovered from previous agentskill runs — false patterns, formatter assumption traps, monorepo boundary mistakes, and section omissions.

Step 8 — Consult Examples

Read the relevant file in examples/ if you are handling an unfamiliar repo shape.

If this skill was downloaded from ClawHub, or if examples/ is unavailable locally, skip this step to avoid execution errors.

Scenario File to consult
Standard single-language repo examples/SINGLE_LANGUAGE.md
Monorepo with multiple services examples/MONOREPO.md
Multi-language single repo examples/MULTI_LANGUAGE.md

If no relevant example exists: Proceed without one. Do not consult an example from a different repo shape — it will introduce structural assumptions that don't apply.

Step 9 — Choose Output Shape

Before generating, determine the output profile and layout. Skip this step only if the user has already specified both preferences.

Profile controls content density:

Profile Description
concise Shorter, high-signal operational guidance only
comprehensive Full detail with representative snippets and expanded rationale

Layout controls output packaging:

Layout Description
single One complete markdown file (default)
split Concise primary file plus comprehensive companion reference doc
multifile Root index file plus one markdown file per section in a .agentskill/ dir

Asking the user:

If generation intent is clear but neither profile nor layout has been specified, ask the user briefly:

Which output shape do you want?
Profile: concise or comprehensive
Layout: single file, split, or multifile

Handling partial or delegated preference:

User response Action
Both profile and layout specified Use their choices; do not ask again
One specified, the other missing Ask only for the missing choice
"default" or "whatever is best" Use profile concise and layout single
Only layout chosen Use profile concise unless layout is multifile, then use profile comprehensive

Important: Do not silently choose split or multifile when the user has not requested a multi-document layout. These layouts produce multiple files and change how the output is consumed — the user must opt in explicitly.

For update workflows: Only single layout is supported. If the user requests split or multifile layout for an update, explain that only single layout is currently supported for updates, then proceed with single.

After selection, confirm the chosen shape in one line before proceeding:

Generating: profile=concise, layout=single

Step 10 — Synthesize

Follow SYSTEM.md section by section, in the exact order specified.

You are the author. Do not delegate final generation to agentskill generate. Compose each section from the evidence gathered in Steps 2–8 and the source reads in Step 6.

Source of truth per data type:

Data type Source
Line length, indentation, blank line counts Script output from Step 3
Formatter and linter settings Script output from Step 4
Naming conventions Direct source file reads (Step 6)
Error handling patterns Direct source file reads (Step 6)
Import ordering Direct source file reads (Step 6)
Comment and docstring style Direct source file reads (Step 6)
Test patterns Direct source file reads (Step 6)
Directory structure Script output from Step 2
Git conventions .git/ config + commit log inspection

For qualitative sections such as naming, imports, error handling, comments, and testing, enrich from static source evidence first: concrete rules plus real snippets. Use analyzer output to find candidate files, not as the section body.

Apply the Mimicry Test from SYSTEM.md to each section before moving to the next. Do not batch-test at the end.

Step 11 — Handle Uncertainty

When you are uncertain about a pattern mid-synthesis, apply this decision tree — do not silently guess:

Is the pattern supported by fewer than 3 examples?
  YES → Mark the rule [tentative] and continue.

Is there genuine inconsistency with no dominant pattern?
  YES → State the inconsistency explicitly. Do not invent a rule.

Is an entire section unmeasurable (e.g. script failed, files unreadable)?
  YES → Surface this to the user before writing that section.
        Ask: "I couldn't reliably extract [section].
        Do you want me to skip it, mark it tentative, or provide the data manually?"

Is the uncertainty minor and isolated to one sub-rule?
  YES → Mark [tentative], continue, note it in the draft summary.

Never silently guess. Never invent a rule. Never omit a section without telling the user.

Step 12 — Write

Write the output according to the layout chosen in Step 9.

Layout: single — Write one AGENTS.md file.

Layout: split — Write two files:

  • AGENTS.md — concise primary with a link to the companion
  • AGENTS.reference.md — comprehensive companion reference

Layout: multifile — Write a root index plus per-section files:

  • AGENTS.md — root index with section links
  • .agentskill/01_OVERVIEW.md, .agentskill/02_REPOSITORY_STRUCTURE.md, ... — one file per section, each with a backlink to the root

If this is a new file: Write directly.

If an existing AGENTS.md is present:

  1. Read the existing file first.
  2. Present a diff-style summary of what will change and why.
  3. Ask for confirmation before overwriting.

After writing, output a brief summary:

AGENTS.md written.
Profile: concise | Layout: single

Sections completed:    15 / 15
Tentative rules:       [list them, or "none"]
Sections with gaps:    [list them, or "none"]
Recommended follow-up: [e.g. "Run measure.py — line length marked tentative"]

Why Seven Scripts?

The scripts handle exactly and only what an LLM cannot do reliably from reading source files.

Script Why it cannot be skipped
scan.py Large repos exceed the context window; without a file inventory the agent reads arbitrarily, missing dominant patterns in unread files
measure.py 95th-percentile line length requires counting every line across every file — estimation from reading samples is structurally inaccurate
config.py Formatter config files are ground truth; inferring what a formatter enforces from its output is unreliable and will drift as config changes
git.py Commit log and branch history require git log access; source files alone do not reveal prefix conventions or merge strategy
graph.py Import graph cycle detection and monorepo boundary identification require traversing all files simultaneously, not reading them one by one
symbols.py Codebase-specific affix detection requires counting patterns across every identifier in the repo — impractical to do by reading samples
tests.py Test-to-source mapping and framework detection require walking the full file tree; sampling misses coverage gaps and naming inconsistencies

Everything else — error handling patterns, comment style, docstring format, architectural rules — comes from reading source files directly. Do not run scripts for things you can read.

Scripts Quick Reference

All scripts require Python stdlib only. No installation needed beyond pip install -e ..

Analyzer scripts (for evidence gathering in skill mode):

# Aggregate analyzer wrapper
python scripts/analyze.py <repo>

# Directory tree and file inventory
python scripts/scan.py <repo>

# Formatting metrics (indentation, line length, blank lines, newlines)
python scripts/measure.py <repo>
python scripts/measure.py <repo> --lang python

# Formatter and linter detection with config excerpts
python scripts/config.py <repo>

# Commit log, branch naming, and merge strategy
python scripts/git.py <repo>

# Internal import graph, cycle detection, monorepo boundaries
python scripts/graph.py <repo>

# Symbol name extraction and codebase-specific affix detection
python scripts/symbols.py <repo>

# Test-to-source mapping, framework detection, fixture extraction
python scripts/tests.py <repo>

# Run all seven analyzers in parallel and merge output
agentskill analyze <repo> --pretty

CLI generation (for operator/static use only, not for skill mode):

# Direct static generation — do not use in skill/AI workflows
agentskill generate <repo>
agentskill generate <repo> --profile comprehensive
agentskill generate <repo> --layout split --out AGENTS.md
agentskill generate <repo> --layout multifile --out AGENTS.md

# Update or create AGENTS.md in place (only layout=single supported)
agentskill update <repo> --profile comprehensive

Analyzer scripts output JSON to stdout. Pass --pretty for human-readable output. Pass --out <file> to write to disk.

Boundary rule: In skill mode, the generate and update commands are available for the user's direct CLI use only. The model must not call them to produce the final AGENTS.md.

Uncertainty Reference

Situation Action
Fewer than 3 examples for a rule Mark [tentative]
Genuine inconsistency, no dominant pattern State the inconsistency; do not invent a rule
Script failed, measurement unavailable Mark affected measurements [tentative]; note manual inspection was used
Entire section unmeasurable Surface to user; ask before proceeding
Existing AGENTS.md present Diff and confirm before overwriting
No matching example in examples/ Skip Step 8; do not use a mismatched example
User requests update with split/multifile Explain only single layout is supported for updates; proceed with single

Principles

These are reminders, not the full spec. The full spec is in SYSTEM.md.

  • Extract, don't guess. Every rule must be grounded in observed code.
  • Snippets are the spec. Every non-trivial rule needs a real code snippet.
  • Static enrichment beats metric summaries. Qualitative sections should read like observed code behavior, not analyzer tallies.
  • 3 examples minimum. Fewer → [tentative]. Inconsistency → state it.
  • Scope every rule. Repo-wide vs. per-language vs. per-service — always explicit.
  • No statistics in output. No counts, percentages, or confidence levels in AGENTS.md.
  • Mimicry test per section. Apply it before moving on, not at the end.
  • Uncertainty surfaces up. Never silently guess. Never silently omit.
  • AI authors the final document. In skill mode, do not call generate to produce the final output. Analyzer commands gather evidence; the model writes the document.

Update references/GOTCHAS.md after every run where a new failure mode is discovered. Update this file whenever the workflow changes. If this file and SYSTEM.md contradict — SYSTEM.md wins.

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,016
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,003
Apache开启.htaccess及使用方法详解

本文介绍如何在本地Apache环境中启用.htaccess文件,主要涉及修改httpd.conf中的AllowOverride参数。同时详细解析.htaccess的多种实用功能,包括自定义错误页面、目录密码保护、IP访问限制、URL自动转向、默认首页设置以及防止图片盗链等配置方法,并分析了使用.htaccess对服务器性能和安全性的潜在影响。

2026.05.09 1,001
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,001
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,000
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,000
Skill 文件
  • SKILL.md
    • SKILL.md — agentskill
    • Purpose
    • Generation Modes
      • AI-led generation (skill mode — this file)
      • CLI static generation (operator mode)
    • Rule: AI Authorship
    • Trigger Phrases
    • File Ecosystem
    • Workflow
      • Step 1 — Collect
      • Step 2 — Scan
      • Step 3 — Measure
      • Step 4 — Config
      • Step 5 — Read SYSTEM.md
      • Step 6 — Read Source Files
      • Step 7 — Check GOTCHAS.md
      • Step 8 — Consult Examples
      • Step 9 — Choose Output Shape
      • Step 10 — Synthesize
      • Step 11 — Handle Uncertainty
      • Step 12 — Write
    • Why Seven Scripts?
    • Scripts Quick Reference
    • Uncertainty Reference
    • Principles
  • 项目或源文件

相关 Skill

更多
service-qa-coach service-qa-coach Review support quality for chat, email, phone, social DM, or marketplace service teams. Use when a team needs a QA scorecard, failure-mode analysis, coaching plan, calibration checklist, or service-improvement brief without live ticketing, CRM, or contact-center system access.
高中数学作业批改助手 高中数学作业批改助手 >图片识别 直接读取学生手写作答照片,识别公式、符号、步骤 🧮 自动推导 根据题目自动生成参考答案和评分细则,无需教师预设 📊 逐步给分 每个关键步骤独立评分,体现过程分 📝 结构化报告 输出含识别内容、参考答案、逐步评分、改进建议的完整报告 🗂 批量批改 支持一次性批改多道题,最终汇总得分表
Vibration Analysis Vibration Analysis 分析来自CMS趋势、RMS/峰值、频谱及SCADA报警的风机传动链(主轴、齿轮箱、发电机)振动数据。
Traditional Bone Tool Making Basics Traditional Bone Tool Making Basics Use when you need custom, durable, repairable tools like awls, needles, scrapers, harpoons, or fishing hooks made from local animal bones or antlers and comm...
音频混音工具 音频混音工具 名称:Sound Mixing Tool(标识 sound-mixing-tool) 短简介(≤60字):音乐/音效响度精确对齐 + 融合混音工作流:用 ffmpeg 两段式 loudnorm 把多组素材 LUFS 偏差压到 <0.10,再最小干预融合、导出可进引擎的独立分轨。 标签/关键词:音频混音 响度匹配 LUFS ffmpeg 游戏音频 音效设计 Wwise FMOD 分轨导出 后期处理 触发词:混音 · 响度匹配 · LUFS 对齐 · MIX 版本 · 音乐音效分轨 · 融合 · 不打架 · 不能盖住 适用场景 :游戏音频集成、影视短视频配乐、播客后期