caching-strategy-optimizer
Optimizes CI/CD pipeline speed by implementing effective caching for dependencies, Docker layers, build outputs, and test results. Provides before/after performance metrics and best practices. Use for "CI caching", "pipeline optimization", "build speed", or "cache strategy".
What this skill does
# Caching Strategy Optimizer
Dramatically speed up CI pipelines with intelligent caching.
## Cache Key Strategy
### Package Manager Caches
```yaml
# NPM - Hash package-lock.json
- uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
# pnpm - More aggressive caching
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/cache@v3
with:
path: |
~/.pnpm-store
node_modules
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
# Python pip
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
# Cargo/Rust
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
```
## Docker Layer Caching
### Using Buildx
```yaml
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build with cache
uses: docker/build-push-action@v5
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
```
### Registry-based Cache
```yaml
- name: Build with registry cache
uses: docker/build-push-action@v5
with:
context: .
cache-from: type=registry,ref=myapp:buildcache
cache-to: type=registry,ref=myapp:buildcache,mode=max
```
## Build Output Caching
```yaml
# Next.js cache
- uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
${{ runner.os }}-nextjs-
# Webpack cache
- uses: actions/cache@v3
with:
path: node_modules/.cache/webpack
key: ${{ runner.os }}-webpack-${{ hashFiles('webpack.config.js') }}-${{ hashFiles('src/**') }}
# TypeScript build cache
- uses: actions/cache@v3
with:
path: |
dist
tsconfig.tsbuildinfo
key: ${{ runner.os }}-tsc-${{ hashFiles('**/*.ts') }}
```
## Test Results Caching
```yaml
# Jest cache
- uses: actions/cache@v3
with:
path: /tmp/jest_rt
key: ${{ runner.os }}-jest-${{ hashFiles('**/*.test.ts') }}
# Pytest cache
- uses: actions/cache@v3
with:
path: .pytest_cache
key: ${{ runner.os }}-pytest-${{ hashFiles('**/*test*.py') }}
```
## Before/After Metrics
```markdown
## Before Optimization
- Total time: 12 minutes
- npm ci: 4 minutes
- Build: 5 minutes
- Tests: 3 minutes
## After Caching
- Total time: 3 minutes
- npm ci: 30 seconds (cache hit)
- Build: 1 minute (incremental)
- Tests: 1.5 minutes (cache hit)
**Improvement: 75% faster (12m → 3m)**
```
## Cache Hit Rate Monitoring
```yaml
- name: Check cache hit
id: cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-deps-${{ hashFiles('package-lock.json') }}
- name: Log cache status
run: |
if [ "${{ steps.cache.outputs.cache-hit }}" == "true" ]; then
echo "✅ Cache hit - saved $(date -u -d @$SECONDS +%M:%S)"
else
echo "❌ Cache miss - installing from scratch"
fi
```
## Best Practices
1. **Precise keys**: Include all dependencies in hash
2. **Restore keys**: Fallback to partial matches
3. **Multiple paths**: Cache related files together
4. **Size limits**: GitHub Actions limit is 10GB
5. **Expiration**: Caches expire after 7 days
6. **Mode=max**: Docker cache mode for better hits
7. **Monitor hits**: Track cache effectiveness
## Common Pitfalls
❌ **Too generic keys**: `key: deps` (always hits)
✅ **Specific keys**: `key: deps-${{ hashFiles('package-lock.json') }}`
❌ **Missing restore-keys**: Cache miss on minor changes
✅ **Restore keys**: Partial match fallback
❌ **Caching node_modules with wrong lock file**
✅ **Match lock file**: Hash the right lockfile
## Output Checklist
- [ ] Package manager cache configured
- [ ] Build output cache
- [ ] Docker layer cache (if applicable)
- [ ] Test cache configured
- [ ] Cache keys use file hashes
- [ ] Restore keys for fallback
- [ ] Before/after metrics documented
- [ ] Cache hit monitoring
Related in Cloud & DevOps
appbuilder-action-scaffolder
IncludedCreate, implement, deploy, and debug Adobe Runtime actions with consistent layout, validation, and error handling. Use this skill whenever the user needs to add actions to an App Builder project, understand action structure (params, response format, web/raw actions), configure actions in the manifest, use App Builder SDKs (State, Files, Events, database), deploy and invoke actions via CLI, debug action issues, or implement patterns such as webhook receivers, custom event providers, journaling consumers, large payload redirects, action sequence pipelines, and Asset Compute workers. Also trigger when users mention serverless functions in Adobe context, action logging, IMS authentication for actions, or cron-style scheduled actions.
orchestrating-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. Use this skill when the user needs a multi-step Data Cloud pipeline, cross-phase troubleshooting, or data space and data kit management. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase sf data360 workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching phase-specific skill), the task is STDM/session tracing/parquet telemetry (use observing-agentforce), standard CRM SOQL (use querying-soql), or Apex implementation (use generating-apex).
github-project-automation
IncludedAutomate GitHub repository setup with CI/CD workflows, issue templates, Dependabot, and CodeQL security scanning. Includes 12 production-tested workflows and prevents 18 errors: YAML syntax, action pinning, and configuration. Use when: setting up GitHub Actions CI/CD, creating issue/PR templates, enabling Dependabot or CodeQL scanning, deploying to Cloudflare Workers, implementing matrix testing, or troubleshooting YAML indentation, action version pinning, secrets syntax, runner versions, or CodeQL configuration. Keywords: github actions, github workflow, ci/cd, issue templates, pull request templates, dependabot, codeql, security scanning, yaml syntax, github automation, repository setup, workflow templates, github actions matrix, secrets management, branch protection, codeowners, github projects, continuous integration, continuous deployment, workflow syntax error, action version pinning, runner version, github context, yaml indentation error
sf-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase `sf data360` workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching sf-datacloud-* skill), the task is STDM/session tracing/parquet telemetry (use sf-ai-agentforce-observability), standard CRM SOQL (use sf-soql), or Apex implementation (use sf-apex).
fabric-cli
IncludedUse this skill for Fabric.so CLI workflows with the `fabric` terminal command: diagnose/install/login, search or browse a Fabric library, save notes/links/files, create folders, ask the Fabric AI assistant, manage tasks/workspaces, generate shell completion, check subscription usage, produce JSON output, and use Fabric as persistent agent memory. Do not use for Microsoft Fabric/Azure/Power BI `fab`, Daniel Miessler's Fabric framework, Python Fabric SSH, Fabric.js, or textile/fashion fabric.
lark
IncludedLark/Feishu CLI skills: lark-cli operations for docs, markdown, sheets, base, calendar, im, mail, task, okr, drive, wiki, slides, whiteboard, apps, approval, attendance, contact, vc, minutes, event. Use when the user needs to operate Lark/Feishu resources via lark-cli, send messages, manage documents, spreadsheets, calendars, tasks, OKRs, deploy web pages, or any Feishu/Lark workspace operations.