AGENT SKILL

chestertons-fence

Investigate historical context of existing code, patterns, or constraints before proposing changes. Automates git archaeology, PR/ADR search, and dependency analysis to prevent removing structures without understanding their purpose.

License 许可
MIT
所属仓库
loriensleafs/brain
最近更新
2026-03-11
Stars
★ 0
Forks
0

01 前言 Front Matter

name
chestertons-fence
model
claude-sonnet-4-6
agents
[ "analyst", "architect", "critic" ]
license
MIT
metadata
{ "version": "1.1.0", "timelessness": "9/10" }
description
Investigate historical context of existing code, patterns, or constraints before proposing changes. Automates git archaeology, PR/ADR search, and dependency analysis to prevent removing structures without understanding their purpose.

02 资源文件 6

03 SKILL.md 正文

Chesterton's Fence Investigation

Enforce epistemic humility before changing existing systems. Understand original purpose before proposing changes.

Quick Start

# Investigate why code exists before changing it
/chestertons-fence "path/to/file.py" "remove unused validation"

# Investigate an ADR before deprecating it
/chestertons-fence ".agents/architecture/ADR-005.md" "allow bash scripts"

Triggers

Phrase Context
why does this exist Investigating existing code or patterns
chestertons fence Explicit investigation request
before removing Planning deletion or replacement
investigate history Researching original rationale
prior art investigation ADR-required investigation

Quick Reference

Input Output Destination
File path or ADR number Investigation report analysis/ folder in Brain memory
Component description Historical context summary stdout (JSON)

When to Use

Use this skill BEFORE proposing changes to existing:

  • Code patterns or architectural decisions
  • ADRs, constraints, or protocol rules
  • Workflow configurations or CI pipelines
  • Skills, hooks, or agent prompts

Process

1. Identify Structure       What exists? Where is it defined?
       |
       v
2. Git Archaeology          git log, git blame to find origin commit
       |
       v
3. PR/ADR Search            Find the PR or ADR with original rationale
       |
       v
4. Dependency Analysis      What references or depends on this?
       |
       v
5. Generate Report          Fill the investigation template
       |
       v
6. Decision                 REMOVE | MODIFY | PRESERVE | REPLACE

Step Details

Step 1: Identify Structure. Locate the exact file, function, pattern, or constraint under investigation. Record its current form.

Step 2: Git Archaeology. Run git log --follow and git blame on the target. Identify the commit that introduced it, the author, and the date.

Step 3: PR/ADR Search. Search for the originating PR using gh pr list --search. Check .agents/architecture/ for related ADRs. Look for comments explaining intent.

Step 4: Dependency Analysis. Use grep or Grep tool to find all references. Map upstream and downstream dependencies. Identify what breaks if the structure is removed.

Step 5: Generate Report. Use the template at .agents/templates/chestertons-fence-investigation.md. Fill all sections with evidence from steps 1 through 4.

Step 6: Decision. Based on evidence, recommend one action:

Decision When to Use
PRESERVE Original rationale still applies
MODIFY Purpose valid but implementation needs updating
REPLACE Better approach exists, original concern addressed
REMOVE Original rationale no longer applies, with evidence

Usage

# Investigate a file or pattern
bun run ${CLAUDE_SKILL_DIR}/scripts/investigate.ts --target path/to/file.py --change "remove unused validation"

# Investigate an ADR
bun run ${CLAUDE_SKILL_DIR}/scripts/investigate.ts --target .agents/architecture/ADR-005.md --change "allow bash scripts"

# Output as JSON (for automation)
bun run ${CLAUDE_SKILL_DIR}/scripts/investigate.ts --target path/to/file.py --change "description" --format json

Integration with Agent Workflows

Agent How to Integrate
Analyst Run this skill first when investigating changes. The report is a prerequisite for any change proposal.
Architect ADRs that deprecate or replace existing patterns MUST include a "Prior Art Investigation" section. Use this skill to generate it.
Implementer Before implementing deletions or major refactoring, verify an investigation report exists. If missing, route to analyst.
Critic When validating plans that remove or replace existing systems, check for investigation evidence. Auto-reject proposals without historical context.

Anti-Patterns

Avoid Why Instead
Removing code you do not understand May break hidden invariants Investigate first, then decide
Assuming dead code is unused Hyrum's Law: someone depends on it Run dependency analysis
Skipping PR/ADR search Loses original design rationale Always check git history and PRs
Proposing replacement without evidence Cannot compare tradeoffs Document original constraints first

Template

Investigation reports use the template at .agents/templates/chestertons-fence-investigation.md.

04 同仓库更多 Skills

loriensleafs
loriensleafs/brain

validation-authority

Treat upstream validators as authoritative. Align local config to them. Use when validation fails unexpectedly, before modifying validator behavior, or when tempted to change upstream tool code.

★ 0
loriensleafs
loriensleafs/brain

using-brain-memory

Guidance for using Brain semantic memory effectively. Applies Zettelkasten atomic note principles with observations and relations. Use when deciding whether to query or create notes, structuring note content, or understanding the semantic knowledge graph.

★ 0
loriensleafs
loriensleafs/brain

threat-modeling

Structured security analysis using OWASP Four-Question Framework and STRIDE methodology. Generates threat matrices with risk ratings, mitigations, and prioritization. Use for attack surface analysis, security architecture review, or when asking what can go wrong.

★ 0
loriensleafs
loriensleafs/brain

taste-lints

Custom lints with agent-readable remediation instructions. Enforces taste invariants (file size, naming conventions, structured logging, complexity) and surfaces errors that agents can act on directly. Use when writing or reviewing code to catch style violations early.

Skill与智能体开发
★ 0
loriensleafs
loriensleafs/brain

style-enforcement

Validate code against style rules from .editorconfig, StyleCop.json, and Directory.Build.props. Detects line ending violations, naming convention issues, indentation problems, and charset mismatches across C#, Python, TypeScript, and JavaScript. Produces JSON reports for pre-commit hooks and CI pipelines.

★ 0
loriensleafs
loriensleafs/brain

steering-matcher

Match file paths against steering file glob patterns to determine applicable steering guidance. Use when orchestrator needs to inject context-aware guidance based on files being modified.

★ 0