skills/strategic-compact/SKILL.md
Use when managing context during long Salesforce Apex development sessions. Suggests manual compaction at logical intervals to preserve deploy and org context across phases.
npx skillsauth add jiten-singh-shahi/salesforce-claude-code strategic-compactInstall 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.
Suggests manual /compact at strategic points in your workflow rather than relying on arbitrary auto-compaction.
Auto-compaction triggers at arbitrary points:
Strategic compaction at logical boundaries:
The suggest-compact.js script runs on PreToolUse (Edit/Write) and:
| Phase Transition | Compact? | Why | |-----------------|----------|-----| | Org exploration -> Planning | Yes | Org metadata is bulky; plan is the distilled output | | Planning -> Apex implementation | Yes | Plan is saved to a file; free up context for code | | Apex implementation -> LWC work | Yes | Clear Apex context for unrelated frontend work | | Apex implementation -> Apex testing | Maybe | Keep if tests reference recent code; compact if switching focus | | Debugging -> Next feature | Yes | Debug traces pollute context for unrelated work | | Mid-implementation | No | Losing class names, field APIs, and partial state is costly | | After a failed deployment | Yes | Clear the dead-end reasoning before trying a new approach | | Trigger work -> Flow work | Yes | Different domains with different context needs |
Understanding what persists helps you compact with confidence:
| Persists | Lost | |----------|------| | CLAUDE.md instructions | Intermediate reasoning and analysis | | Task list (if saved to a file) | File contents you previously read | | Project-level settings and rules | Multi-step conversation context | | Git state (commits, branches) | Tool call history and counts | | Files on disk | Nuanced user preferences stated verbally | | Org metadata on disk | SOQL query results from exploration |
/compact with a summary — Add a custom message: /compact Focus on implementing trigger handler nextNote: This is an aspirational optimization pattern -- SCC currently loads skills based on frontmatter triggers, not a runtime lazy-loading table.
Instead of loading full skill content at session start, use a trigger table that maps keywords to skill paths. Skills load only when triggered, reducing baseline context by 50%+:
| Trigger Keywords | Skill | Load When | |---------|-------|-----------| | "test", "tdd", "coverage" | sf-apex-testing | User mentions testing | | "security", "sharing", "crud" | sf-security | Security-related work | | "deploy", "scratch org", "ci" | sf-deployment | Deployment context | | "soql", "query", "selectivity" | sf-soql-optimization | Query optimization | | "trigger", "handler", "fflib" | sf-trigger-frameworks | Trigger development |
Monitor what consumes your context window:
Common sources of duplicate context in SCC projects:
sf-security and sf-governor-limits skills)Before compacting, write critical context to files so it survives:
# Save field list for target object
sf sobject describe --sobject Account --json > .claude/org-context/account-fields.json
# Save record type IDs
sf data query --query "SELECT Id, Name, DeveloperName FROM RecordType WHERE SobjectType = 'Account'" --json > .claude/org-context/record-types.json
<!-- .claude/session-notes.md — write before compacting -->
## Governor Limit Findings (2026-03-24)
- AccountTriggerHandler.cls line 45: SOQL in loop (CRITICAL)
- OrderService.cls: 3 DML statements could be combined (MEDIUM)
- Coverage: AccountService 82%, OrderService 61% (needs work)
## Deployment Blockers
- Missing field: Account.Risk_Category__c not in target org
- Flow "Auto Case Assignment" references deleted queue
<!-- .claude/test-results.md -->
## Last Test Run
- 142/145 passing
- Failed: OrderServiceTest.shouldHandleBulkUpdate (NPE at line 89)
- Failed: CaseTriggerTest.shouldEscalateHighPriority (assertion at line 34)
- Failed: IntegrationTest.shouldCallExternalAPI (callout not mocked)
- Coverage: 78% org-wide
For work spanning multiple sessions, use compact + session commands:
Session 1: Plan feature
+-- /save-session -> saves plan, org context, findings
+-- /compact -> clean slate
Session 2: Implement Apex
+-- /resume-session -> restores plan context
+-- [implement Apex classes]
+-- /save-session -> saves implementation state
+-- /compact
Session 3: Implement LWC + Deploy
+-- /resume-session -> restores implementation context
+-- [build LWC, deploy, verify]
For projects with 100K+ lines of code:
deep-researcher agent creates navigable index without loading full files| Content Type | Approximate Tokens | Notes |
|-------------|-------------------|-------|
| CLAUDE.md | 2-5K | Always loaded |
| Each rule file | 500-2K | All active rules loaded |
| Each loaded skill | 1-5K | Loaded on demand |
| Apex class (500 lines) | 3-5K | When Read tool is used |
| LWC component (3 files) | 2-4K | HTML + JS + CSS |
| SOQL query result (100 rows) | 2-8K | Depends on field count |
| Test output (full suite) | 5-15K | Use --result-format human to reduce |
| Debug log (1000 lines) | 8-15K | Filter with --log-level WARN |
suggest-compact.js hook — Automatic compaction suggestions/save-session and /resume-session — State that survives compactionsf-debugging skill — Debug context preservationlearning-engine agent — Extracts patterns before session endsdevelopment
Update Salesforce platform reference docs with latest release features and deprecation announcements. Use when SessionStart hook warns docs are outdated or a new Salesforce release has shipped. Do NOT use for Apex or LWC development.
development
Use when syncing documentation after Salesforce Apex code changes. Update README, API docs, and deploy metadata references to match the current org codebase.
tools
Visualforce development — pages, controllers, extensions, ViewState, JS Remoting, LWC migration. Use when maintaining VF pages, building PDFs, or planning VF-to-LWC migration. Do NOT use for LWC, Aura, or Flow.
development
Salesforce Apex trigger framework patterns — TriggerHandler, FFLIB Domain, TDTM, bypass and recursion control. Use when adopting or refactoring triggers.