- Session start step 0: read USER.md at workspace root if present - Read once at session start, not on re-anchors - ~30 token cost - USER.md.template added - README updated
6.8 KiB
SmallClawPlus — dev-project Skill
Trigger: Project has a brain/ directory, or user asks to start a new project.
Extends SmallClaw with: error capture, self-improving learnings, dependency tracking.
Project Tiers
Ask at init: "Roughly how many source files?"
| Tier | Files | Brain files |
|---|---|---|
| Nano | <5 | STATUS + CONTEXT + SESSIONS |
| Small | 5–20 | + PLAN + ARCH + GLOSSARY + CHANGELOG + DEPS |
| Large | 20+ | + full module protocol + .learnings/ |
Record tier in STATUS.md header. Nano skips ARCH, PLAN, DEPS, .learnings/ entirely.
Session Start Protocol
- Read
USER.md(~30 tokens) at workspace root if it exists. Sets name, tone, formatting. Read once — don't re-read on re-anchor. - Read
brain/STATUS.md(~50 tokens). Ground truth. Never skip. - Check git:
If STATUS.md SHA doesn't match git log → fix STATUS.md first.
git log --oneline -3 && git status --short && git branch --show-current - Read
brain/CONTEXT.md(~80 tokens). Your file scope. - Check pending errors (Small+ tier):
If >5 pending errors, scan for patterns before starting work.
wc -l brain/.learnings/ERRORS.md 2>/dev/null - Read only files listed in CONTEXT.md. Nothing else.
- State your plan in 2 sentences, then work.
During Work Rules
- Never edit a file you haven't read this session.
- Never invent an import or function. Read the file first. Verify it exists.
- Never commit to
main. Branch from STATUS.md current task. - If CONTEXT.md declares a module: only edit files under
Owns:. Call but don't modifyExposes:. - Commit every logical unit. Format:
type(scope): description [task: name]Types:feat,fix,refactor,docs,chore,test - Update STATUS.md checkboxes as sub-tasks complete.
- Log decisions in ARCH.md when choosing X over Y.
Mid-Session Re-anchor
After 15+ tool calls, or before editing any file not in CONTEXT.md: re-read STATUS.md and CONTEXT.md. Costs ~130 tokens, prevents drift.
Session End Protocol
- Update STATUS.md — mark task done, promote next, update module health + learnings backlog count.
- Update CONTEXT.md — set scope for the next task.
- Self-reflect: What went wrong? What took too long? What would I do differently?
- Append SESSIONS.md — max 10 bullets:
did / decided / blocked / learned. - Push. Open PR if mergeable.
CHANGELOG and version bump only when a milestone completes — not every session.
Learnings System (Small+ tier)
Capture
When something goes wrong or you discover a gotcha:
- Errors →
brain/.learnings/ERRORS.md— what broke, root cause, fix - Learnings →
brain/.learnings/LEARNINGS.md— patterns, gotchas, "always do X" - Feature requests →
brain/.learnings/FEATURE_REQUESTS.md— user asked for this
Tag each entry with [area: {module or topic}] for filtering.
Promotion
At session end, check if any learning has recurred 3+ times:
- Project-specific → promote to ARCH.md Decisions Log
- Workspace-wide pattern → suggest promoting to SOUL.md or AGENTS.md
Never put project-specific learnings in SOUL.md. Never put workspace patterns in ARCH.md.
Filtering
At session start, CONTEXT.md has a Relevant Learnings field. Only read learnings matching the current area tag. Budget: ~50 tokens.
Archives
When ERRORS.md or LEARNINGS.md exceed 20 entries, move resolved/promoted entries to ERRORS-ARCHIVE.md / LEARNINGS-ARCHIVE.md. Archives are write-only — escape hatch only.
Dependency Tracking (Small+ tier)
DEPS.md
Tracks module dependencies as structured markdown:
## Import Graph
| Source | Depends on | Interface |
|---|---|---|
## Breaking Changes
| Date | Module | Change | Affected |
|---|---|---|---|
Update DEPS.md when adding cross-module imports. Check DEPS.md Affected column before changing any interface.
When DEPS.md exceeds 50 rows, use it to auto-generate the Blast radius field in CONTEXT.md.
When Things Go Wrong
Lost or confused
- Re-read STATUS.md → right task?
- Re-read ARCH.md file index → does the file exist?
- Check
brain/.learnings/ERRORS.md→ seen this before? - Read last 3 SESSIONS.md entries → what happened recently?
- Re-read CONTEXT.md → in scope?
- Still stuck → stop and ask the user a specific question.
Wrong direction mid-task
Do not keep coding. Report immediately:
WRONG TURN
Expected: {what I was trying to do}
Actual: {what happened}
Changed files: {list}
Recovery: {git stash / revert / other}
Need from you: {one specific question}
Log the error in .learnings/ERRORS.md.
Init Protocol
-
Ask:
- "What is this project? (1-2 sentences)"
- "Roughly how many source files?" → determines tier
- "Tech stack?"
- "First 3 milestones?"
- "Which forge? (Gitea/Forgejo/GitHub — URL?)"
-
Create
brain/with tier-appropriate files from templates. -
Create repo on forge. (See
references/forge-api.mdfor curl commands.) -
Initial commit + push.
-
Create issues matching PLAN.md milestones.
Multi-Project Protocol
When PROJECTS.md exists at workspace root:
- Read PROJECTS.md first → active project.
- Navigate to that project's
brain/STATUS.md. - Never read another project's files unless ARCH.md lists them under Shared Dependencies.
- On project switch: quick session-end for current, then load new.
Module Protocol (Small+ tier)
When ARCH.md has ## Modules:
- CONTEXT.md must declare the active module.
- Edit only files under that module's
Owns:. - Cross-module calls only via
Exposes:— read first, don't modify. - Cross-cutting concerns (security, observability) need explicit grant in CONTEXT.md.
- Update DEPS.md when adding cross-module imports.
Token Budget
| File | ~Tokens | When |
|---|---|---|
| USER.md | 30 | Session start only (not re-anchor) |
| STATUS.md | 50 | Every session start + re-anchor |
| CONTEXT.md | 80 | Every session start + re-anchor |
| Pending errors count | 10 | Session start |
| Area-filtered learnings | 50 | Session start (when relevant) |
| ARCH.md | 120–500 | When needed |
| DEPS.md | 100–300 | Cross-module work |
| SESSIONS.md last 3 | 150 | When confused |
Mandatory: ~140 tokens (STATUS + CONTEXT). Learnings scan adds ~60, still under 200.
Size Limits
| File | Max | When exceeded |
|---|---|---|
| STATUS.md | 50 lines | Archive done tasks to SESSIONS.md |
| CONTEXT.md | 30 lines | Break task into sub-tasks |
| SESSIONS.md | 10 entries | Move older to SESSIONS-ARCHIVE.md |
| ERRORS.md | 20 entries | Move resolved to ERRORS-ARCHIVE.md |
| LEARNINGS.md | 20 entries | Promote or archive |
| DEPS.md | 50 rows per table | Query instead of scanning |
Archives are write-only. Never read during normal work — escape hatch step 4 only.