AgentSkillsCN

dive

通过层层深入的探究(文档 → 代码 → 分析),深入挖掘项目中的各类问题,以文件:行号的形式提供有据可依的答案。适用于询问“X 是如何工作的”、“Y 是什么”、“Z 在哪里”,或探究功能、API、配置、代码库结构,以及技术决策时使用。

SKILL.md
--- frontmatter
name: dive
description: Dives deep into project questions using layered investigation (docs → code → analysis) to provide evidence-based answers with file:line citations. Use when asking "how does X work", "what is Y", "where is Z", or investigating features, APIs, configuration, codebase structure, or technical decisions.

Dive

Dives deep into your project to investigate any question, from business logic to technical implementation. Uses layered search strategy to find evidence-based answers backed by documentation and code.

Philosophy

Why Dive?

Dive exists because assumptions are dangerous.

The core question isn't "how do I find the answer?" but "how do I know my answer is true?"

code
The Fundamental Problem:
├── Memory is unreliable (yours and the codebase's docs)
├── Code evolves faster than documentation
├── "I think it works like..." is not evidence
└── Only the current codebase tells the current truth

Evidence Over Intuition

code
Intuition: "This probably uses X pattern"
Dive:      "render.ts:273 shows reconcileKeyedChildren() implementation"

Intuition is a starting point, not an answer. Dive converts intuition into verified knowledge through evidence gathering.

Layered Search: Why This Order?

code
Layer 1: Documentation  → What the project CLAIMS to do
Layer 2: Code           → What the project ACTUALLY does
Layer 3: Deep Analysis  → HOW it all connects

Why documentation first?

  • It's faster to read
  • It gives you vocabulary for code search
  • Discrepancies between docs and code are themselves findings

Why code second?

  • Code is ground truth—it can't lie about what it does
  • Tests show expected behavior in executable form
  • Types reveal contracts and constraints

Why deep analysis last?

  • It's expensive (time, context)
  • Only needed when layers 1-2 don't converge
  • Cross-component questions need tracing

Cross-Referencing Reveals Truth

When documentation says X but code does Y:

  • The code is always correct about behavior
  • The documentation reveals intent or outdated understanding
  • The discrepancy itself is valuable information

This is not a failure of search. It's a success—you found something real.

Core Concepts

Evidence Has Hierarchy

Not all evidence is equal:

SourceReliabilityWhat it proves
Running codeHighestCurrent behavior
TestsHighExpected behavior
ImplementationHighHow it works
Type definitionsMedium-HighContracts
CommentsMediumDeveloper intent
DocumentationMediumClaimed behavior
Commit messagesLow-MediumHistorical intent

Multiple sources agreeing = high confidence. Single source = verify with another layer.

The Question Shapes the Search

Different questions need different approaches:

"How does X work?" → Start with code, verify with tests "Why is X designed this way?" → Start with docs/ADRs, check history "What calls X?" → Start with grep, trace references "When did X change?" → Start with git log, find the commit

Don't apply the same search pattern to every question. Let the question guide you.

Uncertainty is Information

When you can't find clear evidence:

  • State what you searched
  • State what you found (even partial)
  • State what's missing
  • Offer hypotheses, clearly labeled as such

"I couldn't find X" is a valid finding. It tells the next investigator where not to look.

The Dive Loop

code
1. Understand: What exactly is being asked?
      ↓
2. Search: Layer 1 → Layer 2 → Layer 3 (as needed)
      ↓
3. Collect: Gather evidence with file:line citations
      ↓
4. Synthesize: What do the sources tell us together?
      ↓
5. Respond: Direct answer + evidence + uncertainty

This isn't a checklist to follow blindly. It's a mental model for thorough investigation.

When Layers Conflict

Documentation says one thing, code does another. This is common. Here's how to think about it:

SituationWhat to trustWhat to report
Docs outdatedCodeNote the discrepancy
Feature removedCodeFlag potential doc cleanup
Docs wrongCodeRecommend doc fix
Code buggyNeitherFlag as potential bug

The key: always report both, let context determine action.

Reference

Load these as needed, not upfront:

Understanding, Not Rules

Instead of memorizing anti-patterns, understand the underlying tensions:

TensionResolution
Speed vs ThoroughnessMatch depth to stakes. Quick question? Layer 1 may suffice. Critical decision? Go deep.
Confidence vs EvidenceNever state confidence without evidence. "I'm 90% sure" means nothing without sources.
Intuition vs VerificationUse intuition to guide search, not to answer. Then verify.
Completeness vs RelevanceAnswer the question asked. Note related findings briefly, don't digress.

The goal isn't to follow a procedure. It's to know when you know something is true.