// Guide for working with Scope, a developer environment management tool that automates environment checks, detects known errors, and provides automated fixes. Use when creating Scope configurations (ScopeKnownError, ScopeDoctorGroup, ScopeReportLocation), debugging environment issues, or writing rules for error detection and remediation.
| name | scope |
| description | Guide for working with Scope, a developer environment management tool that automates environment checks, detects known errors, and provides automated fixes. Use when creating Scope configurations (ScopeKnownError, ScopeDoctorGroup, ScopeReportLocation), debugging environment issues, or writing rules for error detection and remediation. |
Scope is a DevEx tool that helps maintain consistent development environments through automated checks, error detection, and fixes.
Run automated environment checks and fixes.
scope doctor run # Run all checks
scope doctor run --only group-name # Run specific group
scope doctor run --fix=false # Check only, no fixes
scope doctor run --no-cache # Disable caching
scope doctor list # List available checks
Detect known errors in logs or command output.
scope analyze logs file.log # Analyze log file
scope analyze command -- cmd args # Analyze command output
scope analyze --extra-config path file.log # Use additional configs
Generate bug reports with automatic secret redaction.
scope report ./script.sh # Run and report on script
scope report -- command args # Run and report on command
Monitor script execution in real-time (used as shebang).
#!/usr/bin/env scope-intercept bash
# Script content here
All Scope configurations use Kubernetes-inspired YAML format:
apiVersion: scope.github.com/v1alpha
kind: <ResourceType>
metadata:
name: unique-identifier
description: Human-readable description
spec:
# Resource-specific configuration
Define error patterns and provide automated help/fixes for common issues.
apiVersion: scope.github.com/v1alpha
kind: ScopeKnownError
metadata:
name: descriptive-error-name
description: Brief description of what this error means
spec:
pattern: 'regex pattern to match the error'
help: |
Clear explanation of the issue.
Steps to resolve:
1. First step
2. Second step
3. Where to get help if needed
fix:
prompt:
text: User-friendly prompt asking permission
commands:
- first-fix-command
- second-fix-command
Note: When a fix is defined, it only runs when the error pattern is detected. The fix is optional - if not provided, only the help text is shown.
Place files in categorized directories:
{config-root}/known-errors/{category}/{error-name}.yamldocker/, ruby/, git/, github/, mysql/, postgres/, dns/, aws/.txt file with example error for testingapiVersion: scope.github.com/v1alpha
kind: ScopeKnownError
metadata:
name: gem-missing-file
description: A gem source file is missing and fails to be loaded
spec:
pattern: "/lib/ruby/.* `require': cannot load such file --.*/lib/ruby/gems/.*(LoadError)"
help: |
A gem source file is missing. The solution is to reinstall the gems:
1. Run `bundle pristine`
fix:
commands:
- bundle pristine
helpText: |
Bundle pristine failed. Try these steps:
1. Check your bundle config: bundle config list
2. Reinstall bundler: gem install bundler
3. Contact #help-ruby if issues persist
helpUrl: https://bundler.io/man/bundle-pristine.1.html
prompt:
text: |-
This will reinstall all gems from your Gemfile.
Do you wish to continue?
extraContext: >-
bundle pristine reinstalls gems without changing versions,
which resolves missing file errors but preserves your lock file
Validate schema structure:
brew install sourcemeta/apps/jsonschema
jsonschema validate schema.json known-error.yaml
Test pattern matching:
scope analyze logs --extra-config config-dir/ test-error.txt
\\., \\[, \\([[:digit:]], [[:alpha:]]echo "error text" | rg "pattern"Define environment setup and maintenance checks with automated fixes.
apiVersion: scope.github.com/v1alpha
kind: ScopeDoctorGroup
metadata:
name: tool-name
description: Brief description of what this group does
spec:
include: when-required # or "by-default"
needs:
- dependency-1
- dependency-2
actions:
- name: action-name
description: What this action checks/fixes
required: true # default true; false for optional checks
check:
paths:
- 'file-to-watch.txt'
- '**/*.config'
commands:
- ./bin/check-script.sh
fix:
commands:
- ./bin/fix-script.sh
helpText: |
What to do if the fix fails.
Where to get help.
helpUrl: https://docs.example.com/help
scope doctor runList other groups that must run first in needs array. Creates execution graph.
Each action is an atomic check/fix operation that runs in order.
Determines if fix should run. Fix runs when:
{config-root}/application/{config-root}/environment/.scope/ in project rootapiVersion: scope.github.com/v1alpha
kind: ScopeDoctorGroup
metadata:
name: ruby-version
description: Set up Ruby with correct version
spec:
include: when-required
needs:
- ruby-manager
- homebrew
actions:
- name: install
description: Ensures correct version of ruby is installed
check:
paths:
- '{{ working_dir }}/.ruby-version'
commands:
- ./bin/ruby-version.sh verify
fix:
commands:
- ./bin/ruby-version.sh install
helpText: |
Ruby installation failed.
Contact: #help-channel
Create helper scripts following check/fix pattern:
#!/usr/bin/env bash
set -euo pipefail
ACTION="${1:-check}"
check() {
# Return 0 if check passes, non-zero if fix needed
if [[ condition ]]; then
echo "Check passed"
return 0
else
echo "Check failed" >&2
return 1
fi
}
fix() {
# Perform fix, return 0 on success
echo "Running fix..."
# Fix commands here
return 0
}
case "$ACTION" in
check) check ;;
fix) fix ;;
*)
echo "Usage: $0 [check|fix]" >&2
exit 1
;;
esac
Script best practices:
./ prefix (relative to YAML file)File-based checks use content hashing:
--no-cacheConfigure where and how bug reports are uploaded.
apiVersion: scope.github.com/v1alpha
kind: ScopeReportLocation
metadata:
name: github
spec:
destination:
githubIssue:
owner: org-name
repo: repo-name
additionalData:
nodeVersion: node -v
rubyPath: which ruby
Authentication via environment variables:
SCOPE_GH_APP_ID + SCOPE_GH_APP_KEYSCOPE_GH_TOKENapiVersion: scope.github.com/v1alpha
kind: ScopeReportLocation
metadata:
name: local
spec:
destination:
local:
directory: /tmp/scope-reports
additionalData:
pwd: pwd
username: id -un
scopeVersion: scope version
apiVersion: scope.github.com/v1alpha
kind: ScopeReportLocation
metadata:
name: rustypaste
spec:
destination:
rustyPaste:
url: http://localhost:8000
Capture environment context with arbitrary commands:
additionalData:
diskSpace: df -h
gitBranch: git branch --show-current
envVars: env | sort
Commands execute at report generation time. Scope automatically redacts secrets.
actions:
- name: minimum-version
description: Ensure minimum version installed
check:
commands:
- ./bin/check-version.sh check tool 1.2.3
fix:
helpText: |
You don't have the minimum version installed.
Check Managed Software Center for updates.
actions:
- name: config-file
description: Verify config file exists and is valid
check:
paths:
- .config-file
commands:
- test -s .config-file
fix:
commands:
- ./bin/setup-config.sh
actions:
- name: service-running
description: Ensure service is running
check:
commands:
- ./bin/check-service.sh
fix:
commands:
- ./bin/start-service.sh
helpText: |
Service failed to start.
Check logs: tail "$(brew --prefix)/var/log/service.log"
actions:
- name: install-packages
description: Install project dependencies
check:
paths:
- package.json
- yarn.lock
fix:
commands:
- yarn install
# Main group that just coordinates dependencies
spec:
needs:
- environment-setup
- database-setup
- language-runtime
actions: [] # No actions, just orchestration
Identify error pattern
Create files
mkdir -p {config-root}/known-errors/category
touch {config-root}/known-errors/category/error-name.yaml
touch {config-root}/known-errors/category/error-name.txt
Write YAML definition
Create test file
.txt fileTest pattern
scope analyze logs \
--extra-config {config-root} \
{config-root}/known-errors/category/error-name.txt
Validate schema
jsonschema validate schema.json error-name.yaml
Define problem domain
Create group file
# Application-level
touch {config-root}/application/tool.yaml
# Environment-level
touch {config-root}/environment/tool.yaml
# Project-specific
touch .scope/tool.yaml
Create helper scripts
mkdir -p .scope/bin
touch .scope/bin/tool.sh
chmod +x .scope/bin/tool.sh
Write group definition
needsTest the group
scope doctor list # Verify detected
scope doctor run --only tool # Test execution
scope doctor run --only tool --no-cache # Test without cache
Add to parent group
Update parent group's needs list if this is a new dependency
rg "pattern" test-file.txtscope analyze logs --extra-config with test filepaths globs match files--no-cache to rule out cachingscope doctor list to see execution orderneeds items exist--only to test individual groups./ prefix for relative paths (relative to YAML)Scope automatically redacts sensitive information:
This makes it safe to capture full environment in reports and share debug output publicly.
config-repository/
โโโ {config-root}/
โ โโโ application/ # App-level (ruby, node, postgres)
โ โโโ environment/ # System-level (homebrew, docker, github)
โ โโโ known-errors/ # Error definitions by category
โ โ โโโ docker/
โ โ โโโ ruby/
โ โ โโโ git/
โ โ โโโ ...
โ โโโ reports/ # Report locations
Real-world implementations include:
See references directory for:
quick-reference.md - Command cheat sheet and pattern examplesreal-world-examples.md - Production-tested configurationstesting-guide.md - Comprehensive validation workflows