MJ-skill/context-first-exploration/SKILL.md
Encourages Claude to build a context map before writing or modifying code. Counters the "read too little, act too fast" failure mode common in medium-to-large repos.
npx skillsauth add develata/deve-skills context-first-explorationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill describes a default working pattern, not enforced gates. Hardness lives in the harness UserPromptSubmit hook (rule 1, soft and reducible). Skill content guides; harness gates.
When Claude works directly (not delegating to Codex), it tends to:
Worst when: the repo is large, naming is non-obvious, the task spans modules, or experiment outputs vary across runs.
Default trigger: tasks that modify code or analyze results across more than one file, when Claude hasn't read the relevant module yet.
Skip without going through Phase 1 (no Phase 1 needed):
Not Skip — Phase 1 still applies, even if the user or I call it a "probe":
Rule of thumb: if the script reuses production helpers across modules and writes a new outputs tree, treat it as cross-file analysis, not a "daily probe".
Always reducible: when the user says quick / 直接做 / skip context, Phase 1 collapses to a one-sentence declaration.
Non-trivial tasks default to a two-phase split: Phase 1 (read-only context map) before Phase 2 (execute). This is the preferred working pattern, not an unconditional gate — when the task fits a Skip case above, Phase 1 collapses or is dropped, and the rest of this skill describes what Phase 1 looks like when it runs.
Steps:
docs/architecture-map.md (referenced by CLAUDE.md) if available.## Context Map
### Files read (with reason)
| # | File | Why relevant |
|---|------|-------------|
| 1 | path/to/entry.py | Entry point for the feature |
| 2 | path/to/core.py | Core logic called by entry |
| ... | ... | ... |
### Call chain
entry.py:main() → core.py:process() → utils.py:transform()
### Key invariants discovered
- [invariant 1 — from test or comment]
- [invariant 2]
### Not yet confirmed
- [ ] Whether X config affects this path
- [ ] Whether test Y covers the edge case
### Mandatory reads from CLAUDE.md (if applicable)
- [x] file_a.py (read)
- [x] file_b.py (read)
- [ ] file_c.py (not yet read — will read before Phase 2)
After Phase 1 is complete:
These are signals to slow down, not blocked gates. Skill text can't actually enforce — it can only orient. The harness hook (rule 1) is the actual escalation layer when these defaults are repeatedly skipped.
| Signal | Condition | Recommended response |
|---|---|---|
| Existing impl | Searched for existing implementations before creating new ones? | If no, search now; report any existing impl to user before duplicating. |
| File count | Phase 1 lists ≥3 files read for non-trivial tasks? | If <3, likely missing context — extend Phase 1 before continuing. |
| Call chain | At least one call chain traced? | If no, trace one before Phase 2. |
| Mandatory reads | All files from CLAUDE.md § Mandatory Reads checked? | If no, finish them before Phase 2. |
| Unconfirmed items | "Not yet confirmed" items that could change the approach? | Resolve those before committing to direction. |
| Edit scope | Every Phase 2 edit lands on a file already in the map? | If editing outside the map, read the file and update the map first. |
| Doc sync | Phase 2 created/deleted files, changed imports, or altered call chains? | Update docs/architecture-map.md in the same commit. |
Before each git commit, emit a one-line Doc sync verdict in the conversation — even when the gate doesn't trigger. Visibility lets the user audit and prevents silent skip.
"Doc sync: triggered — <reason>. Updating architecture-map.md." → update the map in the same commit."Doc sync: not triggered — <reason>." (e.g., "only docs/outputs changed, no src file count / import / call-chain changes.")In both phases:
dual-agent-original-request-review/SKILL.md.When Claude delegates to Codex after Phase 1:
Scope field in the Two-File handoff (see codex-orchestration/SKILL.md § 3).codex-orchestration/SKILL.md § 6) for Codex's discovery round.During Phase 1, if the actual codebase disagrees with docs/architecture-map.md:
Response:
Prevents the map from becoming a misleading artifact that causes Claude to skip real files or read phantom ones.
Long sessions degrade Claude's output quality. These defaults reduce context overflow and help key information survive compaction.
Suggest /compact at these phase boundaries (not mid-phase):
Avoid compacting in the middle of: an active debugging trace, a partially written function, or an unfinished code review.
/compact| Survives | Lost | |---|---| | CLAUDE.md instructions | Previously-read file contents | | TodoWrite task list | Intermediate reasoning and analysis | | On-disk files and git state | Tool call history | | Memory files | Context map from Phase 1 |
After /compact:
docs/architecture-map.md./tmp/context_map_<ID>.md so it can be re-read after compact instead of rebuilt.Read with specific line ranges over full-file reads to conserve tokens.When the user says quick / 直接做 / skip context:
tools
Collect and audit Codex token usage with a bundled Python CLI and optional Windows batch launchers. Use this skill when the user asks to check Codex token usage, generate daily token audit logs, calculate monthly CostUSD totals, review Codex spending, or run Codex token usage scripts on Windows, Bash, WSL, or Linux.
tools
Use when giving the user an INLINE reply that carries a trade-off, a decision, a verdict, or a non-trivial finding (decision brief / round verdict / failure root-cause). NOT for "done"/status confirmations, one-line answers, or pure data dumps. Forces a compact decision-brief shape and blocks internal tool-name / file-path bleed into user-facing text.
development
Use for cross-file or cross-chapter terminology audits and corpus-wide term unification in thesis/paper sources — extract candidate term drift, build a decision queue, classify each occurrence, apply accepted replacements safely, and verify counts/build. Trigger on "术语审计", "术语统一", "术语一致性", "逐词审", "这个词全文怎么用", "把 X 全文改成 Y", "terminology audit", or "unify term X". Do NOT use for ordinary prose drafting or a single known-location edit; use academic-writing for prose quality and claim-boundary judgment.
tools
Use for ANY codex CLI dispatch via dispatch wrapper (no time threshold; presence-of-risk triggers, not estimated wall — stdin-EOF stalls occur at <60s). Combines internal log-inactivity watchdog wrapper + external Claude-session cron probe + sentinel hook enforcement. Detects stalls in ≤60-270s vs hours-without-detection failure mode.