Usage
This tutorial will guide you through using the Packmind CLI to scan your codebase for best practice violations.
Getting Help
For complete command reference and options:
packmind-cli scan -h
Basic Usage
1. Scan Current Directory
packmind-cli scan
Scans all files in the current directory and subdirectories.
2. Scan Specific Files
packmind-cli scan src/main.js,src/utils.js
Scans only the specified files (comma-separated).
3. Scan Specific Directories
packmind-cli scan src,test
Scans all files in the src
and test
directories.
Glob Patterns π
Important: Always quote glob patterns to prevent shell expansion!
Basic Patterns
# Scan all TypeScript files
packmind-cli scan "**/*.ts"
# Scan all JavaScript and TypeScript files
packmind-cli scan "**/*.{js,ts}"
# Scan all test files
packmind-cli scan "**/*.{test,spec}.{js,ts}"
Directory-Based Patterns
# Scan all files in any "src" directory
packmind-cli scan "**/src/**"
# Scan all files in "components" directories
packmind-cli scan "**/components/**"
# Scan all files in nested utility directories
packmind-cli scan "**/utils/**"
File-Specific Patterns
# Find all package.json files
packmind-cli scan "**/package.json"
# Find all pom.xml files (Maven projects)
packmind-cli scan "**/pom.xml"
# Find all Docker files
packmind-cli scan "**/Dockerfile"
Combining Multiple Patterns
# Scan source code AND configuration files
packmind-cli scan "**/src/**,**/pom.xml"
# Scan multiple file types across the project
packmind-cli scan "**/*.{js,ts},**/*.{java,kt},**/pom.xml"
# Scan source and test directories
packmind-cli scan "**/src/**,**/test/**,**/*.spec.*"
Filtering Options
Exclude Patterns
# Exclude specific patterns (default exclusions apply automatically)
packmind-cli scan "**/src/**" --exclude "node_modules,.git,dist"
# Exclude test files from analysis
packmind-cli scan "**/*.js" --exclude "test,spec,.test.,.spec."
Output Formats
Console Output (Default)
# Group results by files (default)
packmind-cli scan "**/src/**"
# Group results by practices
packmind-cli scan "**/src/**" --grouped practices
Raw Output (For CI/CD Environments)
The raw
formatter provides plain text output without ANSI escape codes or clickable terminal links, perfect for CI/CD environments like GitHub Actions, GitLab CI, or other automated systems.
# Raw output grouped by files
packmind-cli scan "**/src/**" --formatters raw --grouped files
# Raw output grouped by practices
packmind-cli scan "**/src/**" --formatters raw --grouped practices
# Combine raw with other formatters
packmind-cli scan "**/src/**" \
--formatters raw,sonarqube \
--grouped files \
--output analysis-report.json
When to use raw output:
β GitHub Actions workflows
β GitLab CI/CD pipelines
β Jenkins builds
β Any automated environment where terminal formatting isn't supported
β When you need clean, parseable text output
Export Results
# Export to SonarQube format
packmind-cli scan "**/src/**" \
--formatters sonarqube \
--output sonarqube-report.json
# Export to SARIF format (for GitHub, etc.)
packmind-cli scan "**/src/**" \
--formatters sarif \
--output sarif-report.json
# Export to Xcode format (for iOS/macOS development)
packmind-cli scan "**/src/**" \
--formatters xcode
# Multiple formats
packmind-cli scan "**/src/**" \
--formatters console,sonarqube \
--output analysis-report.json
Available Formatters Summary
console
Interactive terminal use
Formatted output with colors and clickable links
raw
CI/CD environments
Plain text without formatting
sonarqube
SonarQube integration
JSON format for SonarQube
sarif
Security analysis
SARIF format for GitHub, VS Code, etc.
xcode
iOS/macOS development
Xcode-compatible format
Advanced Usage
Scanning Changed Files Only
# Scan only files changed in Git
packmind-cli scan --mode onlyChanged
# Scan only files in GitLab Merge Request
packmind-cli scan --gitlabMR true
Space Filtering
# Scan using practices from specific spaces only
packmind-cli scan "**/src/**" --spaces "JavaScript,React"
# Multiple spaces
packmind-cli scan "**/src/**" --spaces "Java,Spring Boot,Security"
CI/CD Integration Examples
GitHub Actions
- name: Run Packmind Analysis
run: |
packmind-cli scan "**/*.{js,ts}" \
--formatters raw \
--grouped practices \
--errorIfResults true
GitLab CI
packmind_scan:
script:
- packmind-cli scan "src/**"
--formatters raw,sarif
--output packmind-report.sarif
--errorIfResults true
artifacts:
reports:
sast: packmind-report.sarif
Debugging
# Enable debug logging
packmind-cli scan "**/src/**" --log debug
# See detailed information about pattern matching
packmind-cli scan "**/src/**" --log debug | grep "Expanding\|matched"
Last updated
Was this helpful?