AGENT SKILL

agents-md

Generate AGENTS.md files for Go, Rust, TypeScript, and Java projects. Use this skill whenever the user asks to create, scaffold, bootstrap, update, or review an AGENTS.md (or agent-instructions, CLAUDE.md, repo guide for agents) file in a codebase. Also trigger when the user says "add AGENTS.md", "make this repo agent-friendly", "document build/test commands for Claude Code", or uploads a repo and asks Claude Code to learn its conventions. Produces a spec-loose, Claude-Code-optimized AGENTS.md with a shared core section plus short language-specific appendices for the stacks present in the repo.

License 许可
MIT
所属仓库
dimetron/pi-go
最近更新
2026-11-15
Stars
★ 224
Forks
34

01 前言 Front Matter

name
agents-md
description
Generate AGENTS.md files for Go, Rust, TypeScript, and Java projects. Use this skill whenever the user asks to create, scaffold, bootstrap, update, or review an AGENTS.md (or agent-instructions, CLAUDE.md, repo guide for agents) file in a codebase. Also trigger when the user says "add AGENTS.md", "make this repo agent-friendly", "document build/test commands for Claude Code", or uploads a repo and asks Claude Code to learn its conventions. Produces a spec-loose, Claude-Code-optimized AGENTS.md with a shared core section plus short language-specific appendices for the stacks present in the repo.

02 资源文件 3

03 SKILL.md 正文

AGENTS.md Generator

Purpose

AGENTS.md is a top-level Markdown file that tells coding agents (Claude Code, Cursor, etc.) how to work inside a repository: how to build, test, lint, where code lives, what conventions to follow, and what NOT to touch. A good AGENTS.md turns a cold-start agent into a productive one in a single read.

This skill generates such files. It is loosely inspired by the agents.md open standard but optimized for Claude Code workflows.

When to use

  • User asks to create / bootstrap / scaffold AGENTS.md (or CLAUDE.md, AGENT.md)
  • User hands Claude a repo and asks it to "learn the conventions" or "make it agent-friendly"
  • User wants to update an existing AGENTS.md after a stack change
  • User asks for a template they can fill in manually

Workflow

  1. Detect languages present. Look for these marker files:

    • Go → go.mod, go.sum
    • Rust → Cargo.toml, Cargo.lock
    • TypeScript → package.json + tsconfig.json (check for pnpm-lock.yaml / yarn.lock / package-lock.json / bun.lockb)
    • Java → pom.xml (Maven) or build.gradle[.kts] / settings.gradle[.kts] (Gradle)

    If multiple, it's a polyglot repo — include an appendix for each. If none detected, ask the user which stacks to target.

  2. Inspect before writing. Run the actual build/test tool to confirm commands work, read 1–2 representative source files to pick up naming style, check .golangci.yml, clippy.toml, eslint.config.*, checkstyle.xml for lint config. Never invent commands that weren't verified.

  3. Assemble from the template. Use the structure in template.md (same directory). Fill the Shared Core always, then append only the language sections that apply.

  4. Keep it short. Target ~150–300 lines total. AGENTS.md is read on every agent session — brevity matters more than completeness. Link out to deeper docs rather than inline them.

  5. Place at repo root as AGENTS.md. If the repo already has CLAUDE.md, ask whether to replace, merge, or keep both (CLAUDE.md can be a symlink or short pointer to AGENTS.md).

Structure (Shared Core — always include)

# AGENTS.md

> One-paragraph repo description: what it is, who uses it, what stage.

## Quick start
- Setup: <single command or 2-3 lines>
- Build: <command>
- Test: <command>
- Run locally: <command>

## Repository layout
<tree of top-level dirs with one-line purpose each>

## Conventions
- <code style, naming, formatting tool>
- <commit message format>
- <branch / PR rules>

## Do not touch
- <generated files, vendored deps, migrations, etc.>

## Testing policy
- <what must have tests, coverage expectations>
- <how to run a single test>

## Gotchas
- <known footguns, non-obvious env vars, flaky tests>

Language Appendices (include only the ones that apply)

Go appendix

## Go

- Toolchain: Go <version from go.mod>
- Module: <module path>
- Build: `go build ./...`
- Test: `go test ./...` — single test: `go test ./pkg/foo -run TestName -v`
- Race: `go test -race ./...`
- Lint: `golangci-lint run` (config: `.golangci.yml`)
- Format: `gofmt -s -w .` and `goimports -w .`
- Deps: `go mod tidy` after any import change
- Errors: wrap with `fmt.Errorf("...: %w", err)`; use `errors.Is/As`
- Logging: `log/slog` (structured, no `fmt.Println` in library code)
- Context: first arg is always `ctx context.Context`

Rust appendix

## Rust

- Toolchain: pinned in `rust-toolchain.toml` (<channel>)
- Build: `cargo build` — release: `cargo build --release`
- Test: `cargo test` — single: `cargo test <name> -- --nocapture`
- Lint: `cargo clippy --all-targets --all-features -- -D warnings`
- Format: `cargo fmt --all`
- Deps: `cargo update -p <crate>` for targeted bumps; avoid blanket `cargo update`
- Errors: `thiserror` for libraries, `anyhow` for binaries
- Unsafe: must be justified in a `// SAFETY:` comment
- MSRV: <version> — do not use features beyond this

TypeScript appendix

## TypeScript

- Package manager: <pnpm|npm|yarn|bun> — do not mix
- Node: <version from .nvmrc or package.json engines>
- Install: `<pm> install`
- Build: `<pm> run build`
- Test: `<pm> test` — single: `<pm> test -- <pattern>` (vitest/jest)
- Lint: `<pm> run lint` (eslint + <config>)
- Typecheck: `<pm> run typecheck` or `tsc --noEmit`
- Format: `<pm> run format` (prettier)
- Strict mode: `tsconfig.json` has `"strict": true` — do not disable per-file
- Imports: use path aliases from `tsconfig.json`, not deep relative paths

Java appendix

## Java

- JDK: <version> (use SDKMAN or Temurin)
- Build tool: <Maven | Gradle>
- Build: `./mvnw clean install` or `./gradlew build`
- Test: `./mvnw test` or `./gradlew test` — single: `-Dtest=ClassName#method` / `--tests "ClassName.method"`
- Lint: `./gradlew check` (checkstyle + spotbugs) or `mvn verify`
- Format: `./gradlew spotlessApply` or `mvn spotless:apply`
- Style: Google Java Format, 4-space indent, no wildcard imports
- Null-safety: annotate with `@Nullable` / `@NonNull` (JSpecify)
- Logging: SLF4J — never `System.out.println` in production code

Writing rules

  • Verify, don't guess. Every command in the file must have been run successfully (or read from an existing script). Hallucinated make test targets are the #1 failure mode.
  • Imperative voice. "Run go test ./..." not "You can run tests with...".
  • Links over prose. For anything longer than 3 lines, link to docs/ instead of inlining.
  • No marketing. Skip the "welcome to our amazing project" opener. Start with what the agent needs.
  • Stable commands only. If a script is in flux, note it: # unstable — check Makefile.
  • Secrets & env. List required env vars by name; never include values. Point to .env.example.

Example output

See example-AGENTS.md in this skill directory for a filled-in polyglot (Go + TypeScript) example.

Updating an existing AGENTS.md

  1. Read the current file end-to-end.
  2. Diff against what's actually true now (run the commands, check the tree).
  3. Propose a patch, don't rewrite wholesale — preserve the user's voice and project-specific gotchas.

04 同仓库更多 Skills

dimetron
dimetron/pi-go

verify-session-flow

Formally verify the interactive session flow before or after changing it. Use when editing internal/tui/tui.go's handleKey, handleInterruptKey, handleInputSubmit, ctrlCCount or quitting, internal/tui/agent_loop.go's enqueuePrompt, submit, steerPrompt, cancelAgent or handleAgentDone, or the deferred-init splash — or when a user reports that Ctrl+C quit on the first press, that Esc did not stop a turn or a goal loop, that a queued prompt was lost when they canceled, or that the TUI hung on a spinner nothing could clear.

★ 224
dimetron
dimetron/pi-go

verify-run-pipeline

Formally verify the /run phase machine before or after changing it. Use when editing internal/tui/run.go's phase transitions (handleRunAgentDone, runGates result handling, verifyRunComplete, retryRun, reportGateHang, merge), internal/sop/verdict.go's Passed, or the checklist refresh — or when a run merged work it should not have, retried a hung gate, lost a cycle at the retry budget, or merged on a stale PASS.

★ 224
dimetron
dimetron/pi-go

verify-history-rewrite

Formally verify the session-history rewrite path before or after changing it. Use when editing internal/session/autocompact.go, internal/session/compaction*.go, internal/session/store.go's Compact/ClearEvents/rewriteEvents, internal/agent/agent.go's Run/RunStreaming/runPreTurn, or internal/tui/commands.go's clearConversation/clearSessionContext and the context gauge — or when a turn is canceled mid-flight, a tool call and its result get separated, a session's history disappears while the agent is still working, or the model is sent a tool result whose call was compacted away.

★ 224
dimetron
dimetron/pi-go

verify-goal-loop

Formally verify the /goal automatic loop before or after changing it. Use when editing internal/tui/goal.go, internal/tui/agent_loop.go's handleAgentDone/cancelAgent/steerPrompt, or internal/tools/goal.go's GoalController — or when a goal loop will not stop, stops one cycle early, closes a goal that is not met, or restarts a goal you finished.

★ 224
dimetron
dimetron/pi-go

verify-agent-lifecycle

Formally verify the subagent lifecycle before or after changing it. Use when editing internal/subagent/orchestrator.go's Spawn, trackAgent, forwardAgentEvents, terminalStatus, Cancel, ShutdownWithTimeout or evictCompletedAgentsLocked, or internal/subagent/pool.go — or when a canceled agent is reported as failed, an agent vanishes from the list with no verdict, the orchestrator panics on a pool release, or an agent can be canceled twice.

★ 224
dimetron
dimetron/pi-go

test-new-skill

暂无简介

★ 224