Codebase Recon 标志

Codebase Recon

社区
PriNova
codebase-recon

Structured reconstruction workflow for unfamiliar or undocumented codebases. Produces agent-first YAML artifacts only under a resolved structured docs root, with no prose Markdown fallback.

概览

发布者PriNova
代码仓库pi-agent-codebase-workflows
技能名称codebase-recon
星标数
82
复刻数
2
附带文件
仅含指令
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载的 SKILL.md 文件,因此只有在请求确实匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 指令自成一体

    模型所需的一切都包含在指令中,无需同步额外文件。

  • 开源

    由 PriNova 发布于 GitHub。请在安装前查看源内容。

安装

在 TypingMind 中安装 Codebase Recon AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/PriNova/pi-agent-codebase-workflows/tree/main/skills/codebase-recon
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/PriNova/pi-agent-codebase-workflows.git /tmp/pi-agent-codebase-workflows
mkdir -p .claude/skills
cp -r /tmp/pi-agent-codebase-workflows/skills/codebase-recon .claude/skills/codebase-recon
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Codebase Recon,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Codebase Recon。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Codebase Recon 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会获取指令,因此未使用的技能不会产生额外费用。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Codebase Reconstruction — Structured API Only

Goal: reconstruct durable project understanding into canonical YAML artifacts for coding-agent ingestion.

Structured Artifact API Contract

Legacy prose artifacts are deprecated. Do not create, update, or rely on docs/agent/*.md, scoped prose docs, or generated human-readable Markdown views. Use structured YAML for canonical artifacts. Root AGENTS.md remains a harness interoperability file and may be generated/updated only by workflows that explicitly say so.

Resolved structured docs root:

Treat docs/agent/api as a logical layout rooted at a resolved structured docs root, not a fixed repo path.

Resolution rules:

  1. Resolve workspace_root with git rev-parse --show-toplevel 2>/dev/null or fallback to pwd.
  2. Canonicalize workspace_root before fingerprinting when possible (realpath, pwd -P, Path(...).resolve(), or equivalent).
  3. safe-start always creates and uses the initial repo-local root: <workspace_root>/docs/agent/api.
  4. codebase-recon uses repo-local only when <workspace_root>/docs/agent/api already exists.
  5. Otherwise use the global overlay root: ~/.pi/agent/workspaces/<workspace-fingerprint>/docs/agent/api.
  6. Compute <workspace-fingerprint> exactly from canonical workspace_root: strip one leading slash/backslash, replace every slash, backslash, and colon with -, then wrap with --. This keeps the same workspace stable.
  7. Example: /data/data/com.termux/files/home/CodeProjects/pi-mono -> --data-data-com.termux-files-home-CodeProjects-pi-mono--.
  8. Do not create new repo-local structured docs in unadopted repos unless the user explicitly asks for repo-local adoption there.

Logical structured layout under the resolved docs root:

text
repo/
  scopes.yaml
  repo-inventory.yaml
  project-intent.yaml
  architecture.yaml
  data-flow.yaml
  data-model.yaml
  invariants.yaml
  dependency-rules.yaml
  design-issues.yaml
  risk-register.yaml
  change-guide.yaml
  testing-strategy.yaml
  validation-baseline.yaml
  contracts.yaml
  adr.yaml
  agent-operating-guide.yaml
scopes/
  by-path/<repo-relative-path>/...
  by-domain/<slug>/...

Every structured artifact must conform to ../_shared/references/schemas/common.schema.json plus its artifact-specific schema. Do not inline, invent, or vary envelope fields.

Stable IDs required: scope:*, component:*, entity:*, invariant:*, risk:*, contract:*, flow:*, command:*, issue:*, adr:*, testplan:*.

Ownership rules:

  • scopes: scope routing, ownership, cross-scope discovery only.
  • repo-inventory: file tree, commands index, entry points, external boundaries, configs.
  • validation-baseline: command status, blockers, recommended validation order.
  • project-intent: product goal, users, journeys, must-have features, non-goals, constraints, assumptions, open questions, success metrics, prioritized quality attributes, operating constraints, risk areas.
  • architecture: components, architecture style, style rationale, alternatives/tradeoffs, side-effect boundaries, deployment/operating shape, reliability expectations, observability expectations, security assumptions, high-level flow refs.
  • data-flow: typed flow graph/steps, trust boundaries, sensitive-data handling steps, inputs, outputs, error states, degradation/recovery notes.
  • data-model: entities, IDs, schemas, relationships, lifecycles, serialized formats, retention/compliance notes.
  • invariants: rules, forbidden states, enforcement locations, invariant-test refs.
  • dependency-rules: layers, allowed/forbidden dependencies, violations, coupling hotspots.
  • design-issues: structural drift, deferred decisions, ambiguity, ownership gaps.
  • risk-register: failure modes, severity/confidence, affected refs, mitigations/recommended actions, suggested tests/fixes.
  • contracts: cross-scope APIs, schemas, events, generated clients, DB/file/deployment/env/auth/telemetry contracts.
  • testing-strategy: test topology, quality-attribute coverage, coverage gaps, risk-to-test priorities, operability checks.
  • change-guide: workflow routing and checklists; references owner artifacts, duplicates no facts.
  • adr: structured decision records with bounded prose fields, including alternatives and consequences for major design choices.
  • agent-operating-guide: structured source for agent operating rules. Root AGENTS.md may mirror this in compact harness-readable Markdown when produced by safe-start or codebase-recon Pass 6.

Redundancy rule: define each fact in its owner artifact exactly once. Other artifacts reference IDs. Current truth rule: canonical YAML artifacts represent current state, not audit history. Remove resolved or superseded records from canonical owner artifacts by default. Keep them only when another live record still references them or an active migration requires temporary continuity. Use Git history, PRs, issues, or ADRs for audit/history. Prose rule: bounded prose allowed only in summary, notes, rationale, context, decision, recommended_action, and similar scalar fields. Scope rule: if focus is path-like, write under <docs-root>/scopes/by-path/<focus>/; otherwise under <docs-root>/scopes/by-domain/<slug>/. Always update <docs-root>/repo/scopes.yaml.

Runtime Schema Loading

When a workflow creates, updates, migrates, or validates structured artifacts, read ../_shared/references/artifact-api.md first. Then read only the shared skill package schemas needed for the artifacts being written:

  • ../_shared/references/schemas/common.schema.json
  • ../_shared/references/schemas/<artifact-file-base>.schema.json

Do not read all schemas. Do not use templates. Schemas are runtime API contracts; project docs outside the shared runtime refs are maintainer aids unless the user asks about this package itself.

Structured Artifact Write/Update Protocol

Use this protocol whenever creating or updating YAML artifacts.

1. Scope and owner resolution

  1. Resolve scope first from task/focus and <docs-root>/repo/scopes.yaml when present.
  2. Path focus uses longest prefix match; domain focus requires explicit domain/contract/task evidence.
  3. Select the single owner artifact for each fact using the ownership rules above.
  4. Never duplicate owner facts in router/checklist artifacts; reference stable IDs instead.

2. Read-before-write

  1. Read the existing target YAML if it exists.
  2. Read directly referenced owner artifacts needed to preserve refs and avoid duplication.
  3. If target YAML is absent, create it with the common envelope and artifact-specific top-level keys.
  4. Preserve unknown fields unless they conflict with this protocol; do not silently drop agent/user-added structured data.

3. Stable ID generation

  1. Reuse existing IDs whenever the semantic object is the same, even if name/path changed.
  2. New record IDs use deterministic slugs from owner scope + semantic name: risk:<slug>, entity:<slug>, component:<slug>, etc.
  3. Envelope artifact_id values use repo:<artifact-slug> for repo-level artifacts and <scope.id>/<artifact-slug> for scoped artifacts, e.g. repo:architecture and scope:packages/ai/architecture.
  4. Never append an artifact slug to a scope ID with a second colon; scope:packages/ai:architecture is invalid.
  5. If two objects slug-collide, append shortest stable discriminator from path/component/contract, not a random suffix.
  6. Never renumber IDs because order changed.

4. Upsert semantics

For each discovered fact/object:

  1. Match existing record by ID first.
  2. If no ID match, match by stable source-of-truth fields: path+symbol, contract source path, command string+cwd, entity name+owner scope, rule owner+kind.
  3. If matched, update only changed fields, append/refresh evidence, and preserve unrelated fields.
  4. If unmatched, insert new record in deterministic order by ID or explicit order field.
  5. If an existing observed record is resolved, superseded, or no longer supported, delete it from the canonical owner artifact by default.
  6. Keep a record with status: stale or deprecated only when a live reference still depends on it or an active migration needs temporary continuity. Add evidence/unknown explaining why, and link replacement ID when known.
  7. Delete accidental duplicates, malformed records, and unreferenced resolved/superseded records, and mention deletion in final response.

5. Evidence and confidence

  1. Every observed record needs at least one evidence ref with file/symbol/command/doc/diff observation.
  2. Planned records may use evidence_mode: planned and confidence low or medium.
  3. Mixed records must separate observed fields from planned/assumed fields via evidence refs or unknowns.
  4. Do not upgrade status: current or confidence high without source or command evidence.

6. Reference integrity

Before writing final artifacts:

  1. Check every *_ref, *_refs, and depends_on ID points to a record in the same artifact set or is explicitly listed as external/unknown.
  2. Prefer adding missing owner records as compact stubs over leaving dangling refs.
  3. For cross-scope refs, ensure scopes.yaml and contracts.yaml identify owner/consumer relationship.
  4. If ownership is ambiguous, create/update design-issues.yaml with kind: ownership_gap and reference it.

7. Status transitions

Allowed transitions:

  • planned -> partial -> current
  • current -> stale -> current
  • current|stale|partial -> deprecated

Rules:

  • current requires sufficient observed evidence for the represented scope.
  • partial means useful but incomplete evidence.
  • stale means contradicted by newer source evidence or missing source path. Use it as a temporary migration/quarantine state, not a permanent archive state.
  • deprecated means superseded; include replacement_ref when known. Use it only when a live reference still needs continuity during migration; otherwise remove the record from the canonical artifact.

8. Deterministic formatting

  1. Use YAML with two-space indentation.
  2. Use stable top-level key order: envelope keys first, artifact-specific keys next.
  3. Sort unordered arrays by id; keep ordered flow/checklist arrays by order.
  4. Use null, [], or {} consistently rather than omitting required envelope fields.
  5. Keep prose scalar fields concise; no long narrative blocks.

9. Validation before completion

Perform best-effort validation after writing:

  1. Re-read changed YAML for parse/syntax sanity when practical.
  2. Validate against the shared schemas by inspection/re-read: envelope keys, artifact-specific top-level keys, required arrays/items, stable ID prefixes, and obvious dangling refs.
  3. Verify no legacy Markdown artifacts were created or updated by the workflow, except root AGENTS.md when explicitly produced for harness interoperability.
  4. Report changed YAML files, validation performed, unresolved unknowns, and any records intentionally retained or pruned as part of compaction.

Core Rules

  • Do not edit production code.
  • No Markdown artifacts except root AGENTS.md for harness interoperability in Pass 6.
  • Each pass writes/updates only its owner artifacts.
  • Later passes read prior YAML artifacts instead of re-reading whole repo.
  • Evidence is mandatory for observed claims.
  • Unknowns are explicit records, not vague prose.
  • When newer schemas require fields that are not inferable from the codebase, still create those fields with evidence-backed low-confidence placeholders, empty arrays, null-capable subfields, and explicit unknowns rather than omitting them.
  • Reconstruct decision-driving quality attributes, trust boundaries, reliability/observability/security expectations, and tradeoffs when the repo provides enough evidence; otherwise record the ambiguity explicitly.
  • Use stable IDs and cross-references to mirror codebase ownership and relationships.

Passes

Users may invoke this skill directly for any pass, or use the matching prompt template as a pass shortcut.

  1. Inventory (/recon-01-inventory): write repo-inventory.yaml, validation-baseline.yaml, and initial project-intent.yaml; update scopes.yaml for focus. Infer product goal, users, journeys, quality attributes, operating constraints, and risk areas from repo evidence when possible; otherwise record explicit unknowns.
  2. Architecture (/recon-02-architecture): write architecture.yaml with components, style, style rationale, alternatives/tradeoffs when inferable, boundaries, execution flow refs, and reliability/observability/security expectations.
  3. Data/invariants (/recon-03-data-invariants): write data-model.yaml and invariants.yaml; surface trust boundaries, sensitive data, retention/compliance implications, and correctness/safety rules.
  4. Dependencies/drift (/recon-04-dependency-rules): write dependency-rules.yaml and design-issues.yaml; record structural gaps where quality/security/operability evidence is weak.
  5. Risks (/recon-05-risk-register): write risk-register.yaml with affected refs, recommended actions, and quality/security/reliability risks.
  6. Agent operating guide (/recon-06-agents): write agent-operating-guide.yaml and root AGENTS.md.
  7. Change guide (/recon-07-change-guide): write change-guide.yaml.
  8. Consolidation (/recon-08-consolidate): reconcile YAML artifacts, resolve contradictions with evidence, preserve owner-only facts, and backfill required schema fields when older artifacts are incomplete.
  9. ADR (/recon-09-adr): write adr.yaml with structured ADR records, alternatives, and consequences where architectural decisions are inferable from history/docs/code.
  10. Risk-to-tests (/recon-10-risk-tests): write/update testing-strategy.yaml with quality-attribute coverage, risk-to-test priorities, and operability checks.

All-in-one shortcut: /recon-all runs the pass sequence until the requested focus is complete or the repo size requires stopping at a pass boundary.

Artifact Shape Source

For each pass, use the shared runtime schemas as the only shape contract: ../_shared/references/artifact-api.md, ../_shared/references/schemas/common.schema.json, and the matching artifact schema(s). Do not rely on prose key lists.

常见问题

Codebase Recon AI 技能有什么作用?

Structured reconstruction workflow for unfamiliar or undocumented codebases. Produces agent-first YAML artifacts only under a resolved structured docs root, with no prose Markdown fallback.

为什么在 TypingMind 中使用 Codebase Recon?

因为您只需安装一次,就能搭配任何模型使用。Codebase Recon 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型,甚至可以在聊天中途切换模型,而不会影响技能正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Codebase Recon?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/PriNova/pi-agent-codebase-workflows/tree/main/skills/codebase-recon。TypingMind 会读取其中的 SKILL.md,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Codebase Recon?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Codebase Recon 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以搭配 Codebase Recon 使用,包括 GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等,都可在 TypingMind 中使用您自己的 API 密钥接入。

Codebase Recon AI 技能免费吗?

是的。该技能源自 PriNova 在 GitHub 上以 MIT 许可证发布的项目。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇