AgentSkillsCN

context-first

在开始任何工作之前,先加载所需上下文。根据请求类型,利用提示矩阵决定应加载的内容。此举可避免过早实施,防止上下文污染。

SKILL.md
--- frontmatter
name: context-first
description: Load required context before any work. Uses prompt matrix to determine what to load based on request type. Prevents premature implementation and context poisoning.

Context First

TRAP 1 & 2 Defense: Load context before implementation

Core Principle

Never implement before understanding. Context loading is mandatory before any code changes.

3-Step Validation Protocol

Before ANY implementation:

Step 1: Dry Reading

Read existing code to understand:

  • Current architecture patterns
  • Related components and dependencies
  • Existing conventions in similar files

Step 2: Context Gathering

Load artifacts based on request type:

Request CategoryContext to Load
New featureProduct requirements, UX specs
Feature extensionArchitecture, existing patterns
Bug fixSprint status, story context
RefactoringArchitecture, project truths
DocumentationArchitecture, existing docs
AmbiguousAGENTS.md, project truths

Step 3: Plan Validation

Confirm approach before coding:

  • Does it align with project architecture?
  • Is scope manageable (< 4 hours)?
  • Are dependencies identified?

Artifact Freshness

Documents have different lifespans:

Document TypeTypical LifespanRefresh Trigger
ArchitectureLong-livedMajor changes only
ADRsLong-livedSuperseded by new ADR
StoriesSprint-livedSprint completion
Tech specsStory-livedStory completion
PlansTask-livedTask completion

Check modification timestamps. Stale artifacts (> 2 hours for short-lived, > 24 hours for long-lived) may need refresh.

Document Tiering

Documents iterate on each other in tiers:

code
Tier 1: Governing (Architecture, PRD, AGENTS.md)
   ↓ informs
Tier 2: Planning (Epics, Stories, ADRs)
   ↓ informs  
Tier 3: Execution (Tech Specs, Tasks)
   ↓ informs
Tier 4: Ephemeral (Session notes, scratch files)

Always validate lower tiers against higher tiers. If Tier 3 conflicts with Tier 1, Tier 1 wins.

Integration

Use project context loader tools to load based on request classification:

  • Identify prompt type from request
  • Load recommended context files
  • Validate freshness before using

Failure Mode

If validation fails:

code
⛔ CONTEXT FIRST VIOLATION

Attempted: {action}
Missing: {missing_context}
Tier conflict: {if any}

ACTION: Complete 3-Step Validation before proceeding.