sm
This commit is contained in:
150
modules/_opencode/command/supermemory-init.md
Normal file
150
modules/_opencode/command/supermemory-init.md
Normal file
@@ -0,0 +1,150 @@
|
||||
---
|
||||
description: Initialize Supermemory with comprehensive codebase knowledge
|
||||
---
|
||||
|
||||
# Initializing Supermemory
|
||||
|
||||
You are initializing persistent memory for this codebase. This is not just data collection - you're building context that will make you significantly more effective across all future sessions.
|
||||
|
||||
## Understanding Context
|
||||
|
||||
You are a **stateful** coding agent. Users expect to work with you over extended periods - potentially the entire lifecycle of a project. Your memory is how you get better over time and maintain continuity.
|
||||
|
||||
## What to Remember
|
||||
|
||||
### 1. Procedures (Rules & Workflows)
|
||||
Explicit rules that should always be followed:
|
||||
- "Never commit directly to main - always use feature branches"
|
||||
- "Always run lint before tests"
|
||||
- "Use conventional commits format"
|
||||
|
||||
### 2. Preferences (Style & Conventions)
|
||||
Project and user coding style:
|
||||
- "Prefer functional components over class components"
|
||||
- "Use early returns instead of nested conditionals"
|
||||
- "Always add JSDoc to exported functions"
|
||||
|
||||
### 3. Architecture & Context
|
||||
How the codebase works and why:
|
||||
- "Auth system was refactored in v2.0 - old patterns deprecated"
|
||||
- "The monorepo used to have 3 modules before consolidation"
|
||||
- "This pagination bug was fixed before - similar to PR #234"
|
||||
|
||||
## Memory Scopes
|
||||
|
||||
**Project-scoped** (\`scope: "project"\`):
|
||||
- Build/test/lint commands
|
||||
- Architecture and key directories
|
||||
- Team conventions specific to this codebase
|
||||
- Technology stack and framework choices
|
||||
- Known issues and their solutions
|
||||
|
||||
**User-scoped** (\`scope: "user"\`):
|
||||
- Personal coding preferences across all projects
|
||||
- Communication style preferences
|
||||
- General workflow habits
|
||||
|
||||
## Research Approach
|
||||
|
||||
This is a **deep research** initialization. Take your time and be thorough (~50+ tool calls). The goal is to genuinely understand the project, not just collect surface-level facts.
|
||||
|
||||
**What to uncover:**
|
||||
- Tech stack and dependencies (explicit and implicit)
|
||||
- Project structure and architecture
|
||||
- Build/test/deploy commands and workflows
|
||||
- Contributors & team dynamics (who works on what?)
|
||||
- Commit conventions and branching strategy
|
||||
- Code evolution (major refactors, architecture changes)
|
||||
- Pain points (areas with lots of bug fixes)
|
||||
- Implicit conventions not documented anywhere
|
||||
|
||||
## Research Techniques
|
||||
|
||||
### File-based
|
||||
- README.md, CONTRIBUTING.md, AGENTS.md, CLAUDE.md
|
||||
- Package manifests (package.json, Cargo.toml, pyproject.toml, go.mod)
|
||||
- Config files (.eslintrc, tsconfig.json, .prettierrc)
|
||||
- CI/CD configs (.github/workflows/)
|
||||
|
||||
### Git-based
|
||||
- \`git log --oneline -20\` - Recent history
|
||||
- \`git branch -a\` - Branching strategy
|
||||
- \`git log --format="%s" -50\` - Commit conventions
|
||||
- \`git shortlog -sn --all | head -10\` - Main contributors
|
||||
|
||||
### Explore Agent
|
||||
Fire parallel explore queries for broad understanding:
|
||||
\`\`\`
|
||||
Task(explore, "What is the tech stack and key dependencies?")
|
||||
Task(explore, "What is the project structure? Key directories?")
|
||||
Task(explore, "How do you build, test, and run this project?")
|
||||
Task(explore, "What are the main architectural patterns?")
|
||||
Task(explore, "What conventions or patterns are used?")
|
||||
\`\`\`
|
||||
|
||||
## How to Do Thorough Research
|
||||
|
||||
**Don't just collect data - analyze and cross-reference.**
|
||||
|
||||
Bad (shallow):
|
||||
- Run commands, copy output
|
||||
- List facts without understanding
|
||||
|
||||
Good (thorough):
|
||||
- Cross-reference findings (if inconsistent, dig deeper)
|
||||
- Resolve ambiguities (don't leave questions unanswered)
|
||||
- Read actual file content, not just names
|
||||
- Look for patterns (what do commits tell you about workflow?)
|
||||
- Think like a new team member - what would you want to know?
|
||||
|
||||
## Saving Memories
|
||||
|
||||
Use the \`supermemory\` tool for each distinct insight:
|
||||
|
||||
\`\`\`
|
||||
supermemory(mode: "add", content: "...", type: "...", scope: "project")
|
||||
\`\`\`
|
||||
|
||||
**Types:**
|
||||
- \`project-config\` - tech stack, commands, tooling
|
||||
- \`architecture\` - codebase structure, key components, data flow
|
||||
- \`learned-pattern\` - conventions specific to this codebase
|
||||
- \`error-solution\` - known issues and their fixes
|
||||
- \`preference\` - coding style preferences (use with user scope)
|
||||
|
||||
**Guidelines:**
|
||||
- Save each distinct insight as a separate memory
|
||||
- Be concise but include enough context to be useful
|
||||
- Include the "why" not just the "what" when relevant
|
||||
- Update memories incrementally as you research (don't wait until the end)
|
||||
|
||||
**Good memories:**
|
||||
- "Uses Bun runtime and package manager. Commands: bun install, bun run dev, bun test"
|
||||
- "API routes in src/routes/, handlers in src/handlers/. Hono framework."
|
||||
- "Auth uses Redis sessions, not JWT. Implementation in src/lib/auth.ts"
|
||||
- "Never use \`any\` type - strict TypeScript. Use \`unknown\` and narrow."
|
||||
- "Database migrations must be backward compatible - we do rolling deploys"
|
||||
|
||||
## Upfront Questions
|
||||
|
||||
Before diving in, ask:
|
||||
1. "Any specific rules I should always follow?"
|
||||
2. "Preferences for how I communicate? (terse/detailed)"
|
||||
|
||||
## Reflection Phase
|
||||
|
||||
Before finishing, reflect:
|
||||
1. **Completeness**: Did you cover commands, architecture, conventions, gotchas?
|
||||
2. **Quality**: Are memories concise and searchable?
|
||||
3. **Scope**: Did you correctly separate project vs user knowledge?
|
||||
|
||||
Then ask: "I've initialized memory with X insights. Want me to continue refining, or is this good?"
|
||||
|
||||
## Your Task
|
||||
|
||||
1. Ask upfront questions (research depth, rules, preferences)
|
||||
2. Check existing memories: \`supermemory(mode: "list", scope: "project")\`
|
||||
3. Research based on chosen depth
|
||||
4. Save memories incrementally as you discover insights
|
||||
5. Reflect and verify completeness
|
||||
6. Summarize what was learned and ask if user wants refinement
|
||||
Reference in New Issue
Block a user