/sf-compound-engineering:sf-compound [mode:refresh|doc-format] [scope; defaults to recent work]from sf-compound-engineering
Captures durable Salesforce knowledge into docs/solutions/ as YAML-frontmatter documents. Use when lessons learned are not reflected in final code or tests.
Ships in sf-compound-engineering. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
First argument mode:<name> selects a mode; everything after it passes to that mode's guide. Load only the guide for the chosen mode.
| Mode | Use for | Guide |
|---|---|---|
(none) | Write a solution doc from recent work | this file |
refresh | Review stale docs/solutions entries against the codebase | references/refresh/guide.md |
doc-format | Reference: solution doc format and schema | references/doc-format/guide.md |
Principles enforced: 5 (taste and oversight), 7 (institutional memory). See
PRINCIPLES.md.
Persona dispatch. This skill dispatches personas as isolated subagents — see
../sf-work/references/dispatch/guide.mdfor the mechanics (isolated subagents, same-response parallelism, same-file-conflict check). Any reviewer/researcher it invokes (e.g.sf-learnings-researcher) is a research persona referenced from../sf-plan/references/personas/.
Capture learnings from completed Salesforce work into docs/solutions/ as YAML-frontmatter
solution documents validated against schema.yaml. Capture two kinds of learning explicitly:
(1) bug-fix learnings (symptom → root cause → resolution → prevention) and (2) aesthetic
or pattern learnings (the "works but gross" code we cleaned up, the abstraction we picked,
the convention we standardized on). Search existing solutions first — update existing
entries instead of duplicating. Update CLAUDE.md, agents, and skills only when the
learning generalizes beyond a single solution.
<feature_description> #$ARGUMENTS </feature_description>
When asking the user a question, use the host's blocking question tool already in the current tool list (match by capability, not by a host-specific name). Presence in that list is proof the tool exists; never call a user-facing question tool to discover whether it exists. If a matching tool is listed but unloaded, load its schema with the host's tool-discovery primitive, then call it. Fall back to numbered options in chat only when no blocking tool is listed or the call errors. Never silently skip the question.
Ask one question at a time. Prefer a concise single-select choice when natural options exist.
You are capturing learnings from completed work into the institutional knowledge system. Every solution documented makes the next iteration smarter.
Analyze recent work and capture learnings: $ARGUMENTS.scope
If no scope specified, analyze recent commits and changes.
Brainstorm (10%) → Plan (30%) → Work (20%) → Review (20%) → Compound (20%) → Repeat
│
└── YOU ARE HERE
Write a learning only when the work is solved and verified, and the reasoning is not recoverable from the final Apex, tests, comments, or an existing solution doc. If the document disappeared, would a later reader of the implementation repeat the mistake or redo the investigation? If not, write nothing and say why. Completion, effort, and diff size do not qualify. An explicit /sf-compound still applies this test. Update an existing learning that would now mislead instead of adding a second one.
Review what was built:
# Recent commits
git log --oneline -20
# Changed files
git diff HEAD~5 --name-only
# Recent solutions
ls docs/solutions/ -R
Before writing new entries, check what already exists:
Avoid duplicating existing documentation. Update existing entries if the new work adds context.
For each insight from the work, classify into a category:
| Category | Directory | Examples |
|---|---|---|
| Governor Limits | docs/solutions/governor-limit-issues/ | SOQL 101, DML 150, CPU timeout |
| Deployment | docs/solutions/deployment-issues/ | Deploy failures, metadata conflicts |
| Test Failures | docs/solutions/test-failures/ | Flaky tests, coverage gaps |
| Security | docs/solutions/security-issues/ | CRUD/FLS, injection, sharing |
| Integration | docs/solutions/integration-issues/ | Callout failures, auth issues |
| Flow | docs/solutions/flow-issues/ | Flow errors, recursion, limits |
| LWC | docs/solutions/lwc-issues/ | Rendering, wire, events |
| Data Model | docs/solutions/data-model-issues/ | Relationships, indexes, skew |
| Best Practice | docs/solutions/best-practices/ | Proven patterns, approaches |
| Pattern | docs/solutions/patterns/ | Reusable design patterns |
For each learning, create a solution document with YAML frontmatter:
---
title: "{Short descriptive title}"
date: {YYYY-MM-DD}
category: {category from schema.yaml}
severity: {critical|high|medium|low}
tags: ["{tag1}", "{tag2}", "{tag3}"]
retire_when: "{optional; outside change that retires this doc, and the check; omit otherwise}"
---
## Symptoms
{What went wrong or what was the challenge}
## Root Cause
{Why it happened — technical explanation}
## Resolution
{How it was fixed — specific code/config changes}
## Prevention
{How to avoid this in the future}
## Related Files
- {file_path}:{line_number}
Save to: docs/solutions/{category}/{YYYY-MM-DD}-{slug}.md
Validate frontmatter against schema.yaml.
Then run python3 skills/sf-compound/scripts/validate-doc-claims.py <doc> from the repo root. Adjudicate each FLAG: fix the citation, or annotate it as historical. A NOTE is an unresolved hex token with no commit cue around it (a session id or a content hash). It does not fail the run. An absolute path that falls inside the repo is a citation — the script rewrites it to repo-relative before checking. A flag is not a hard failure; a path the fix itself deleted can stay if the doc says so. Do not treat a clean script run as optional when the doc cites paths.
Route updates via index files:
Read ../sf-review/references/personas/ to identify the owning skill's persona files for new checks
Read skills/index.md to identify skill files for new patterns
Update only files relevant to the work classification
Avoid cross-contamination across domains
Agent files: Add new review checks discovered during the work
Skill files: Add new patterns or gotchas
CLAUDE.md: Update project context, conventions, tips
Save a report to docs/solutions/ summarizing all changes.
When a caller invoked this skill, this report ends the skill, not the turn. The caller continues in the same session.
Compound complete.
Knowledge updates:
- Solutions documented: {count} new entries in docs/solutions/
- Skills updated: {list of skills modified}
- Agents updated: {list of agents modified}
- CLAUDE.md: {entries added/updated}
Categories:
- {category}: {count} entries
The next iteration starts smarter.
Next: /sf-plan mode:brainstorm or /sf-plan for the next feature
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub divingsbysangam/salesforce-compound-engineering-plugin --plugin sf-compound-engineering10 skills in this plugin
/sf-debugDiagnose a Salesforce failure or explain code: tests, governor limits, deploys, LWC, sharing. Use for 'debug', 'why is this failing', or 'I didn't follow'. Use sf-work when the change is already known./sf-deployValidate, deploy, retrieve, and delete Salesforce metadata; manage orgs, manifests, test runs, and test data; set up the environment. Use for 'deploy', 'validate', 'retrieve', 'package.xml', 'scratch org', 'setup'./sf-generateGenerate Salesforce source: Apex, triggers, Flows, objects/fields/tabs/apps, permission sets, validation rules, FlexiPages, test data, prompt templates, MCP tools, Agentforce agents and tests.Other plugins' skills for the same job