Ad-Hoc Context Assembly
Build context on the fly without creating profile files. Perfect for one-off tasks, experimentation, and quick context changes.
The Basics
Instead of creating a profile YAML file, use command-line flags to assemble context dynamically:
# Using bundles
scm run -f go-development -f testing-patterns "help me write tests"
# Using tags
scm run -t golang -t testing "help me write tests"
# Combining both
scm run -f security -t best-practices "review this code"
Building Faux Profiles
Scenario: Quick Go Development Session
Instead of creating profiles/go-dev.yaml:
# Ad-hoc "profile" with multiple bundles
scm run \
-f go-development \
-f testing-patterns \
-f error-handling \
"implement the user service"
Scenario: Security Review
Instead of creating profiles/security-review.yaml:
# Ad-hoc security context
scm run \
-f security#fragments/owasp-top-10 \
-f security#fragments/auth-patterns \
-f security#fragments/input-validation \
-t security \
"review this authentication code"
Scenario: Multi-Language Project
# Frontend work
scm run -f typescript -f react -f css-patterns "build the dashboard component"
# Backend work
scm run -f go-development -f postgres -f api-design "implement the API endpoint"
# Full-stack context
scm run \
-f typescript \
-f go-development \
-f api-design \
"design the data flow between frontend and backend"
Fragment Reference Syntax
By Name (searches all bundles)
scm run -f error-handling "help with errors"
Fully Qualified
scm run -f go-development#fragments/error-handling "help with errors"
Multiple Fragments from Same Bundle
scm run \
-f go-development#fragments/testing \
-f go-development#fragments/error-handling \
-f go-development#fragments/concurrency \
"review this code"
Remote Fragments (without pulling)
scm run \
-f scm-main/security#fragments/owasp \
-f scm-main/testing#fragments/tdd \
"help me write secure tests"
Tag-Based Assembly
Tags let you pull in all fragments with matching tags:
# All fragments tagged "security"
scm run -t security "review for vulnerabilities"
# Multiple tags (OR logic - matches any)
scm run -t security -t authentication "review auth code"
# Combine with specific fragments
scm run -t testing -f go-development#fragments/mocking "write unit tests"
Combining with Profiles
Start with a profile, add more context:
# Base profile + extra fragments for this task
scm run -p developer -f security -f performance "optimize this endpoint"
# Profile + tags
scm run -p go-dev -t database -t caching "implement data layer"
Preview Before Running
Always preview complex ad-hoc assemblies:
# See what would be assembled
scm run \
-f go-development \
-f testing-patterns \
-f security \
--dry-run
# See the actual content
scm run \
-f go-development \
-f testing-patterns \
--dry-run --print
Real-World Examples
Code Review with Specific Focus
# Performance-focused review
scm run \
-f performance#fragments/profiling \
-f performance#fragments/optimization \
-f go-development#fragments/concurrency \
"review this code for performance issues"
# Security-focused review
scm run \
-f security#fragments/owasp-top-10 \
-f security#fragments/injection \
-f security#fragments/auth \
"security review this authentication handler"
Learning a New Topic
# Pull in comprehensive learning context
scm run \
-t kubernetes \
-t containers \
-f devops#fragments/k8s-patterns \
"explain how to set up a deployment"
Debugging Session
# Context for debugging
scm run \
-f go-development#fragments/debugging \
-f go-development#fragments/profiling \
-f logging-patterns \
"help me debug this memory leak"
Writing Documentation
# Documentation-focused context
scm run \
-f documentation#fragments/api-docs \
-f documentation#fragments/readme-patterns \
-t documentation \
"write API documentation for this service"
Database Work
# Database context
scm run \
-f postgres#fragments/queries \
-f postgres#fragments/optimization \
-f postgres#fragments/migrations \
"optimize this slow query"
Tips for Ad-Hoc Assembly
1. List Available Fragments First
# See what's available
scm fragment list
# Filter by bundle
scm fragment list --bundle go-development
# Search by name
scm fragment list | grep security
2. Check Fragment Content
# Preview a fragment before using
scm fragment show go-development#fragments/testing
3. Use Shell Aliases for Common Combinations
# In your .bashrc/.zshrc
alias scm-go='scm run -f go-development -f testing-patterns'
alias scm-security='scm run -f security -t security'
alias scm-review='scm run -f code-review -f best-practices'
# Then use:
scm-go "implement the handler"
scm-security "review this code"
4. Create Shell Functions for Complex Assemblies
# In your .bashrc/.zshrc
scm-fullstack() {
scm run \
-f typescript \
-f react \
-f go-development \
-f postgres \
-f api-design \
"$@"
}
# Use:
scm-fullstack "design the user registration flow"
5. Save Successful Combinations as Profiles
If you find yourself using the same ad-hoc combination repeatedly:
# This works well - save it!
scm run -f go-development -f testing -f security "..."
# Create a profile for future use
scm profile create go-secure \
-b go-development \
-b testing \
-b security \
-d "Go development with security focus"
When to Use Ad-Hoc vs Profiles
Use Ad-Hoc When:
- One-off tasks
- Experimenting with different context combinations
- Quick additions to your base profile
- Task requires unusual fragment combination
Use Profiles When:
- Same combination used repeatedly
- Team needs consistent context
- Complex inheritance chains
- Want to version control the configuration
MCP Tool Equivalent
The same ad-hoc assembly works via MCP:
{
"tool": "assemble_context",
"arguments": {
"bundles": ["go-development", "testing-patterns", "security"],
"tags": ["best-practices"]
}
}
This lets AI assistants dynamically assemble context based on the current task.