find-related-sessions
暂无简介
- License 许可
- MIT
- 最近更新
- 2026-10-19
- Stars
- ★ 3
- Forks
- 1
03 SKILL.md 正文
Find sessions related to a specific file
Why this skill exists
When the user mentions a specific file, prior work touching that file is the highest-signal context available. StackUnderflow's per-message tool index records which files each session read or wrote. One CLI call returns the recent sessions that touched the path — so you know what the last change was, why it was made, and whether the user's current request continues or contradicts it.
When this skill fires
Trigger when the user's request includes a concrete file path (with extension or recognizable file shape), AND the request is non-trivial (modify, fix, explain-in-context, refactor):
- "Fix the bug in
routes/cost.py" - "What was that change to
api.tsabout?" - "Why is
python-legacy: store/queries.pyso long?" - "Refactor
src/components/Dashboard.tsx" - "Can you look at
tests/test_aggregator.py?"
Do NOT fire for:
- Pure read requests with no follow-up ("show me
foo.py") - File paths in error messages or stack traces (use only when the user is explicitly directing attention there)
- Path-shaped strings that aren't real files (URLs, config keys)
Step 1: surface sessions touching the file
stackunderflow find-sessions-touching-file <path> --format json --limit 5 --mode any
The <path> argument can be relative to the user's cwd or absolute — both work. The CLI normalizes against the project's session index.
--mode filters by access type:
any(default) — sessions that read OR wrote the fileread— sessions that opened/grepped the filewrite— sessions that edited the file (highest signal for "what changed and why")
For most requests, --mode any is right. If the user says "what changed in this file", switch to --mode write to focus on edits.
JSON shape (one entry per session):
{
"sessions": [
{"session_id": "...", "project_slug": "...", "project_path": "/abs/path",
"provider": "claude", "first_ts": "...", "last_ts": "...",
"message_count": 42, "cost_usd": 0.85, "snippet": "first user message"}
]
}
Step 2: read the snippets, prioritize recency
Sessions come back newest-first. The snippet summarizes what each session was about. For a "what changed" question, the most recent session that wrote the file is usually the answer. For a "why is this shaped this way" question, scan the last several sessions for the design discussion.
Step 3: ground the work
- If a recent session refactored or rewrote the file: don't redo work the user already accepted. Mention what was done; ask if the new request supersedes or extends it.
- If the file was the subject of an unfinished change: pick up where that session left off.
- If no sessions touched the file in the indexed window: just proceed with the task. (
sessions: []is a valid result —find-sessions-touching-fileis cheap to run speculatively.)
Showing the user vs. consuming internally
Default --format json is for agent consumption. When the user asks "show me sessions that touched X" or "when was Y last edited", use the human-readable form:
stackunderflow find-sessions-touching-file <path> --mode write --limit 10
Text output is sorted newest-first with timestamps and one-line snippets — readable as a changelog of who-touched-what.
Alternate path: MCP
If the StackUnderflow MCP server is connected, the equivalent is the find_sessions_touching_file tool with the same arguments. The CLI is the fallback because it's universally available.
Cost
Local SQLite query — no network, no LLM call. <100 ms even on large stores. Run liberally.
04 同仓库更多 Skills
staxtrace-memory
Search local coding-agent session history before acting. Use BEFORE an Edit or Write to a file, BEFORE a non-trivial Bash command (a build, migration, or destructive/long-running command), and whenever the user references a past decision ("what did we decide about X", "why is this done this way", "didn't we agree to Y"), a specific file, or "what worked last time" — cases where a prior session on this machine may already hold the decision, the failure mode, or the exact working command. Queries the local `stax memory` CLI (staxtrace) across every past Claude Code / Codex / Cursor session so you do not re-derive an answer, contradict an earlier choice, or repeat a known failure. Local and read-only; nothing leaves the machine.
handwritten
暂无简介
auto-undated
no stamp
auto-recent-thing
A recently generated skill.
auto-old-thing
An auto-generated skill from a previous run.
auto-hand-written
mine