mobile-compaction
Skill66 starsChanged 6 months agoMITView on GitHub
Context compaction strategies for large Android codebases. Optimize token usage while preserving critical context.
In this repository51 other files it gives its agents.
- AGENTS.mdAGENTS.md
- rules/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- examples/CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/everything-mobile.mdcCursor rule
- accessibility-patternsSkill
- analytics-patternsSkill
- android-patternsSkill
- app-lifecycleSkill
- ci-cd-patternsSkill
- combine-frameworkSkill
- continuous-learningSkill
- continuous-learning-v2Skill
- core-dataSkill
- coroutines-patternsSkill
- deep-linkingSkill
- expect-actualSkill
- feature-builderSkill
- feature-flagsSkill
- gradle-patternsSkill
- image-loadingSkill
- ios-testingSkill
- jetpack-composeSkill
- kmp-diSkill
- kmp-navigationSkill
- kmp-networkingSkill
- kmp-repositoriesSkill
- koin-patternsSkill
- ktor-patternsSkill
- liquid-glassSkill
- localization-patternsSkill
- m3-expressiveSkill
- mobile-checkpointSkill
- mobile-instinct-v1Skill
- mobile-instinct-v2Skill
- mobile-memorySkill
- mobile-securitySkill
- mobile-testingSkill
- mobile-verificationSkill
- mvi-architectureSkill
- navigation-composeSkill
- offline-firstSkill
- pagination-patternsSkill
- push-notificationsSkill
- room-patternsSkill
- shared-coroutinesSkill
- shared-modelsSkill
- sqldelight-patternsSkill
- swift-patternsSkill
- swiftui-patternsSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 223
If compaction removed needed context:
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Mobile Compaction Skill
Strategic context compaction for large Android projects to optimize token usage while preserving critical information.
When to Compact
Compact context when:
- Token usage exceeds 100,000
- Working on large refactors spanning many files
- Switching between unrelated features
- Session becomes unfocused
- Context contains resolved discussions
Compaction Strategies
1. Module-Level Compaction
Focus on a single Android module:
/compact --module=feature:authWhat happens:
- Retain: All files in feature:auth module
- Summarize: Other modules to high-level description
- Drop: Resolved discussions about other modules
Use when: Deep work on a specific feature
2. Layer-Based Compaction
Focus on architecture layer:
/compact --layer=ui
/compact --layer=data
/compact --layer=domainWhat happens:
| Layer | Retain | Summarize |
| UI | Composables, ViewModels, navigation | Repository details, data models |
| Data | Repositories, data sources, models | Compose code, UI state |
| Domain | Use cases, domain models | Implementation details |
Use when: Working on cross-cutting concerns in a layer
3. Build Variant Focus
Narrow to specific build variant:
/compact --variant=debugWhat happens:
- Retain: Debug-specific configurations, test code
- Summarize: Release configurations, ProGuard rules
Use when: Debugging or test development
4. Test Isolation
Compact around failing tests:
/compact --test=AuthViewModelTest
/compact --test-failingWhat happens:
- Retain: Test file, related source files
- Summarize: Unrelated test discussions
- Drop: Resolved test fix discussions
Use when: Fixing specific test failures
5. Pattern-Based Compaction
Compact based on architectural patterns:
/compact --pattern=compose
/compact --pattern=mvi
/compact --pattern=koinWhat happens:
- Retain: Files matching the pattern
- Summarize: Non-matching files to pattern names only
Use when: Pattern-specific work (e.g., Compose optimization)
Compaction Levels
| Level | Retention | Token Savings | Use Case |
| Lite | Current task only | 70-80% | Deep focus work |
| Medium | Current + related | 50-60% | Feature development |
| Standard | Project summary | 30-40% | Default compaction |
| Minimal | Essential only | 80-90% | Context at limit |
What Gets Preserved
Always Preserve (Critical)
- Active task context (what we're doing now)
- Recent code changes (last 5-10 files)
- Current errors/failures
- Mobile memory context
- High-confidence instincts (>0.7)
- Unresolved questions
Usually Preserve (Important)
- Architecture decisions
- Recent discussions (last 50 messages)
- Related file contents
- Test states
Summarize (Compressible)
- Completed features
- Resolved bugs
- Working code explanations
- Background discussions
Drop (Disposable)
- Successful build outputs
- Trivial operations
- Duplicated information
- Off-topic discussions
Compaction Commands
Basic Compaction
/compact # Auto-select strategy
/compact --level=medium # Specify level
/compact --focus=compose # Focus on specific areaSmart Compaction
/compact --smart # AI chooses strategy
/compact --adaptive # Adjusts based on usageManual Compaction
/compact --keep=file1.kt,file2.kt # Keep specific files
/compact --drop=discussion-1 # Drop specific discussion
/compact --summarize=feature-x # Summarize specific topicCompaction Workflow
Before Compaction
1. /memory-save all # Save current state to memory
2. /mobile-checkpoint save pre-compact # Optional checkpoint
3. /compact --strategy=module --focus=feature:authAfter Compaction
1. /memory-summary # Verify memory preserved
2. /instinct-status # Verify instincts preserved
3. Continue work...Integration
With Checkpoints
# Pre-compact hook automatically saves checkpoint
# Restore to recover if compaction removes needed contextWith Memory
# Memory survives compaction
# Query memory to recover details:
/memory-query "What was the auth flow architecture?"With Instincts
# Instincts survive compaction
# High-confidence instincts always retained
# Low-confidence may be summarizedAnti-Patterns
Don't Compact When:
- In the middle of debugging
- Unresolved errors exist
- Active discussion ongoing
- Task almost complete
Do Compact When:
- Starting new task
- Switching context
- Token limit approaching
- Task completed, keeping summary
Recovery
If compaction removed needed context:
1. /memory-query <topic> # Query memory
2. /mobile-checkpoint list # Check for checkpoints
3. /mobile-checkpoint restore <name> # Restore if needed
4. Git history for file diffsExamples
Example 1: Feature Development
Context: Working on auth feature, context contains old home feature discussions
Action: /compact --module=feature:auth
Result: Retains auth files, summarizes home featureExample 2: Test Fixing
Context: Many files, focus on fixing LoginTest
Action: /compact --test=LoginTest
Result: Retains LoginTest, related auth files, summarizes restExample 3: Compose Optimization
Context: Large project, optimizing Compose performance
Action: /compact --pattern=compose --level=medium
Result: Retains Compose files, summaries of data/network layersRemember: Compaction is reversible via checkpoints and memory. When in doubt, checkpoint first.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

