AgentSkillsCN

knowledge

用于项目知识查询、架构检索、常见陷阱排查以及知识维护。先进行查询(hot_cache、domain_index、gotchas),最后再进行更新。

SKILL.md
--- frontmatter
name: knowledge
description: Load for project knowledge querying, architecture lookup, gotcha checks, and knowledge maintenance. Query first (hot_cache, domain_index, gotchas), update at END.

Knowledge

Merged Skills

  • context-management: Project knowledge graph, entity lookup
  • caching: Hot cache, domain index, gotchas lookup
  • architecture-lookup: File paths, structure, "where is X"

⚠️ Critical Gotchas

CategoryPatternSolution
Multiple queriesRunning --query 5 timesRead first 100 lines ONCE at START
Repeated readsReading knowledge file multiple timesKeep in memory for entire session
Wrong lookupSearching when data is cachedCheck hot_cache before file reads
Stale knowledgeEntity refs outdatedRun knowledge.py --update after sessions
Missing gotchasNew issues not documentedAdd to workflow log, will be merged
Skip querySearching codebase directlyQuery knowledge FIRST (75% hit rate)

Rules

RulePattern
Query firstCheck knowledge before grep/find/list_dir
Load onceRead first 100 lines ONCE at session start
Memory-firstKeep loaded knowledge in context
Hot cache firstCheck hot_cache.entity_refs before file reads
Gotchas firstCheck gotchas.issues when debugging
Update at ENDRun knowledge.py --update in END phase

When to Use Knowledge Skill

NeedQuery
"Where is X file?"domain_index.backend/frontend
"What does Y do?"hot_cache.entity_refs
"Known issues with Z?"gotchas.issues
"How are A and B connected?"layer relations
Architecture questionsdomain_index + interconnections
File path lookupdomain_index
Debug patterngotchas first

Avoid

❌ Bad✅ Good
Run --query 5 timesRead first 100 lines once
grep knowledge.jsonCheck loaded gotchas in memory
list_dir for pathsCheck domain_index
Search for entityCheck hot_cache first

⛔ MANDATORY: Load Once at START

bash
head -100 project_knowledge.json  # Do this ONCE

This gives you (in memory for entire session):

LineContentUse For
1HOT_CACHETop 20 entities + file paths
2DOMAIN_INDEX81 backend, 71 frontend paths
3CHANGE_TRACKINGFile modification hashes
4GOTCHAS38 known issues + solutions
5INTERCONNECTIONSEntity chains
6SESSION_PATTERNSPreload hints
7-12Layer entitiesGraph structure
13-93Layer relationsLookup paths

Patterns

bash
# Pattern 1: Session start - load knowledge
head -100 project_knowledge.json

# Pattern 2: Query specific entity (rare, only if cache miss)
python .github/scripts/knowledge.py --query "entity_name"

# Pattern 3: Update knowledge after session
python .github/scripts/knowledge.py --update
python
# Pattern 4: Using knowledge programmatically
import json

with open('project_knowledge.json') as f:
    for i, line in enumerate(f):
        if i >= 100:
            break
        data = json.loads(line)
        if data.get('type') == 'hot_cache':
            entity_refs = data['entity_refs']
        elif data.get('type') == 'gotchas':
            issues = data['issues']

Query Order (Using In-Memory Knowledge)

StepCheckIf Miss
1hot_cache.top_entities→ Step 2
2gotchas.issues→ Step 3
3domain_index.backend/frontend→ Step 4
4layer relations→ Step 5
5Use --query CLI→ Step 6
6Read file directlyLast resort

File Structure

LinesContent
1-6Headers (ALL lookup data)
7-12Layer entities (KNOWLEDGE_GRAPH, HOT_CACHE, ...)
13-93Layer relations (caches → entity, indexes → file)
94+Code entities (sorted by weight)
300+Code relations (imports, calls)

Commands

TaskCommand
Load knowledgehead -100 project_knowledge.json
Query entitypython .github/scripts/knowledge.py --query "name"
Update knowledgepython .github/scripts/knowledge.py --update
Suggest updatespython .github/scripts/knowledge.py --suggest

Stats (v4.2)

  • First 100 lines: ~15KB (fits in context)
  • Contains: 100% of lookup data
  • File reads saved: 76.8%
  • Queries saved: 90%+ (vs multiple --query calls)