skills/syncing-docs-and-memory/SKILL.md
Sync docs and memory
npx skillsauth add laststance/skills syncing-docs-and-memoryInstall 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.
When running this skill in Codex, translate Claude Code-only primitives before acting: AskUserQuestion -> chat/request_user_input, TodoWrite -> update_plan, Task/TaskCreate/TeamCreate/SendMessage -> spawn_agent/send_input/wait_agent when available and allowed, and EnterPlanMode/ExitPlanMode -> a concise chat plan plus explicit approval.
Resolve Read/Write/Edit/Bash/WebSearch/WebFetch to Codex file/shell/web tools, and map ~/.claude/... paths to ~/.agents/... or ~/.codex/... unless the task explicitly targets Claude Code.
When running this skill in Cursor Agent, translate Claude Code-only primitives before acting: AskUserQuestion -> AskQuestion; TodoWrite -> Cursor TodoWrite or an equivalent checklist; Task/TaskCreate/TeamCreate/SendMessage/multi-agent flows -> Cursor Task (subagents), parallel Tasks, or run_in_background when allowed (TeamCreate/SendMessage may have no exact match); EnterPlanMode/ExitPlanMode -> Plan mode (SwitchMode / CreatePlan) plus explicit user approval.
Resolve Read/Write/Edit/StrReplace/Bash/web/search/MCP via Cursor Composer or Agent equivalents. MCP names written as mcp__server__tool typically map to call_mcp_tool with configured server identifiers. Map ~/.claude/... to ~/.cursor/skills/, .cursor/skills/, and .cursor/rules/ unless the task explicitly targets Claude Code.
Ceremony-free, bidirectional sync between project docs and memory systems.
*.md.context/ only when the user opts in via speech ("Notion も同期して" etc.)/document-release for thoseThis is a manual-only skill. Do not auto-trigger.
Get current branch and detect the repo's base branch (don't hardcode main):
CUR=$(git branch --show-current)
BASE=$(gh repo view --json defaultBranchRef --jq .defaultBranchRef.name 2>/dev/null \
|| git remote show origin 2>/dev/null | awk '/HEAD branch/ {print $NF}' \
|| echo "main")
[ "$CUR" = "$BASE" ] && echo "ABORT: on base branch ($BASE) — run from a feature branch" && exit 1
Capture project slug as a memory write-back hint (gstack optional):
if [ -x ~/.claude/skills/gstack/bin/gstack-slug ]; then
source <(~/.claude/skills/gstack/bin/gstack-slug 2>/dev/null) || true
fi
SLUG="${SLUG:-$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null)}"
git diff "$BASE"...HEAD --stat
git log "$BASE"..HEAD --oneline
git diff "$BASE"...HEAD --name-only
Classify changes into: New features / Changed behavior / Removed functionality / Infrastructure.
Pick execution mode based on repo size and diff scope:
CHANGED_FILES=$(git diff "$BASE"...HEAD --name-only | wc -l | tr -d ' ')
DOC_FILES=$(find . -maxdepth 4 -name "*.md" -not -path "./.git/*" -not -path "./node_modules/*" | wc -l | tr -d ' ')
DIFF_LINES=$(git diff "$BASE"...HEAD --stat | tail -1 | grep -oE '[0-9]+ insertion' | grep -oE '^[0-9]+' || echo 0)
WORKSPACES=$(find . -maxdepth 3 \( -name "package.json" -o -name "Cargo.toml" -o -name "pyproject.toml" \) -not -path "./node_modules/*" | wc -l | tr -d ' ')
| Tier | Condition | Strategy |
|------|-----------|----------|
| Small | DOC_FILES < 10 AND CHANGED_FILES < 30 | Inline (single agent) |
| Medium | DOC_FILES 10–40 OR CHANGED_FILES 30–100 | Parallel Read (multiple in one message) |
| Large | DOC_FILES > 40 OR WORKSPACES > 3 OR DIFF_LINES > 5000 | Spawn up to 3 Explore subagents in parallel, one per workspace |
Large-mode subagent prompt template (each agent owns one workspace, returns ≤500 words):
"audit
<workspace>/README/CLAUDE.md/SPEC.md against the diff. Report stale facts and narrative drift asRecommendation: <action> because <reason>. Do not Edit/Write — report only."
Always audit (well-known): README.md, AGENTS.md, CLAUDE.md, SPEC.md, CONTRIBUTING.md, ARCHITECTURE.md, TODOS.md (if present).
Discover any other markdown:
find . -maxdepth 3 -name "*.md" \
-not -path "./.git/*" -not -path "./node_modules/*" \
-not -path "./.gstack/*" -not -path "./.context/*" \
-not -path "./dist/*" -not -path "./build/*" | sort
Add discovered files to the audit list (deduped against well-known).
Always (cost-free, already loaded by /load):
mcp__serena__list_memories() — list keys$SLUG or repo namemcp__serena__read_memory() only on relevant keys (don't read all)If Serena MCP is unavailable, silently skip.
Opt-in only when the user's invocation explicitly mentions a source. Speech keyword → source mapping:
| Phrase | Source |
|--------|--------|
| "Notion も" / "Notion に" | Notion MCP |
| "Obsidian も" / "vault に" | Obsidian MCP |
| "Inkdrop も" | Inkdrop MCP |
| "gbrain も" / "brain にも" | gbrain CLI |
| "learnings に" / "gstack-learnings に" | gstack-learnings CLI |
| "Codex memory も" | Codex (~/.codex/) |
| "ローカル .context/ に" | project-local dir |
For full read/write APIs and probes, see references/memory-sources.md.
Never write to Claude auto-memory (~/.claude/projects/.../memory/) — that's global user memory, out of scope.
Apply the heuristics in references/doc-audit-heuristics.md to each doc. In Large mode, aggregate the Step 1.5 subagent outputs instead of re-reading files.
Cross-check against any memory sources discovered in Step 3: flag docs whose narrative contradicts a recent learning or Serena snapshot.
Classify each candidate change:
For the stale-detection logic (which doc is affected by which diff path), see references/change-detection.md.
Use Edit tool. Emit one summary line per file (e.g. README.md: skill count 134 → 135).
Never auto-update: README intro / project positioning, ARCHITECTURE.md philosophy / design rationale, security-model wording, full section deletions.
For each ask-user candidate, ask one question with:
RECOMMENDATION: Choose [X] because [reason]C) Skip — leave as-isApply approved edits via Edit.
For every observed truth from Step 4 that has reuse value, write it back to the sources active in Step 3 (Serena always; others only if opted in).
| Observation type | Preferred destination | |------------------|----------------------| | Project-state snapshot (branch, scope, conventions) | Serena memory (always) | | Pattern / pitfall / architecture decision | gstack-learnings (opt-in) + Serena (always) | | Long-form page-scale knowledge | gbrain / Notion / Obsidian (opt-in) | | Trivial current state | Skip (avoid memory bloat) |
Gate every write with AskUserQuestion (memory noise is permanent):
RECOMMENDATION: Append to Serena as "project-state-2026-05-02" because <reason>
A) Yes, write
B) Modify before write
C) Skip this entry
D) Skip & don't ask again this session
If neither Serena nor any opt-in source is available, skip the whole step and note "memory write-back: no destinations — docs sync only" in the output.
CHANGELOG.md (any change)VERSION fileIf the diff suggests these need updates, end the run with: "Run /document-release for CHANGELOG/VERSION."
## syncing-docs-and-memory complete
**Mode**: Small | Medium | Large (N Explore agents)
**Memory sources active**: Serena (auto) [+ <opt-in sources>]
**Docs updated**:
- <file>: <one-line summary>
- (skipped: <file> — reason)
**Memory write-back**:
- Serena: N entries
- <opt-in source>: N entries
- (or: no destinations — skipped)
**Untouched** (use /document-release if needed): CHANGELOG, VERSION
**Out of scope**: Claude auto-memory (global)
references/doc-audit-heuristics.md — per-file audit checklists, auto-vs-ask splitreferences/memory-sources.md — read/write APIs, probes, speech-keyword tablereferences/change-detection.md — diff → stale-doc reverse lookuptesting
Cited research briefs
development
Daily coding habit prompts JP
development
React core deep-dive JP
data-ai
Copy last agent reply