Schwab CLI
The Schwab CLI is a custom command-line interface tool designed to streamline development workflows by automating common tasks related to Git, Jira, and GitHub operations. The CLI is aliased as schwab in your bash environment.
Quick Reference
| Command | What It Does |
|---|---|
assignments | Lists all open Jira tickets assigned to the team |
branches-cleanup | Removes all local Git branches that have been merged into main |
checkout | Checks out a Jira ticket branch with intelligent branch management |
commit | Commits changes |
context | Lists all directories in the repository |
contrib | Logs hours worked on tickets and posts to Jira (should be run daily) |
kill | Terminates a process running on a specific port |
pr | Opens your pull request(s) for a Jira ticket in GitHub |
pullflags | Creates feature flag files for Jira labels beginning with FF_ |
push | Pushes current branch to remote and optionally creates a pull request |
ready | Updates PR to "Ready for Review" and collects testing information |
release-report | Generates a report of all tickets merged since last production release |
reset | Resets the current Git branch to match the remote branch |
test | Runs the test suite for the repository |
ticket | Opens the Jira ticket for your current branch in browser |
worklog | Reports hours worked for a specific date or date range |
File Structure
packages/cli/
├── src/
│ ├── schwab-cli.sh # Main CLI entry point
│ ├── --help.mjs # Help command
│ ├── assignments.mjs # Team assignments
│ ├── checkout.mjs # Branch checkout
│ ├── commit.mjs # Commits files
│ ├── contrib.mjs # Time logging
│ ├── context.mjs # Directory listing
│ ├── pr.mjs # PR operations
│ ├── pullflags.mjs # Feature flags
│ ├── push.sh # Push to remote
│ ├── ready.mjs # Ready for review
│ ├── release-report.mjs # Release reporting
│ ├── reset.mjs # Branch reset
│ ├── test.mjs # Test runner
│ ├── ticket.mjs # Open Jira ticket
│ ├── worklog.mjs # Worklog reporting
│ ├── branches-cleanup.sh # Branch cleanup
│ ├── kill.sh # Kill port
│ └── utilities/ # Shared utilities
└── package.json
Installation & Setup
The CLI is located at /home/nextjs-web/packages/cli and is aliased in /root/.bash_aliases:
alias schwab='/home/nextjs-web/packages/cli/src/schwab-cli.sh'
After installation, you can use the CLI by simply typing schwab followed by a command.
Getting Help
To see all available commands and their descriptions:
schwab --help
Commands Reference
assignments
Lists all open tickets that are assigned to the team.
| Option | Type | Required | Description |
|---|---|---|---|
status | String | No | Filter tickets by status (e.g., "In Progress", "Ready for Review") |
Usage:
schwab assignments
schwab assignments "In Progress"
Description: Retrieves and displays all Jira tickets assigned to your team, optionally filtered by status.
branches-cleanup
Removes all local Git branches that have been merged into the main branch.
| Option | Type | Required | Description |
|---|---|---|---|
| None | - | - | Interactive confirmation required |
Usage:
schwab branches-cleanup
Description: This command helps keep your local repository clean by removing branches that have already been merged. It will prompt for confirmation before deletion.
This will permanently delete local branches. Ensure you don't have any unmerged work before proceeding.
checkout
Checks out a Jira ticket branch with intelligent branch management.
| Option | Type | Required | Description |
|---|---|---|---|
JiraTicket | String | No | Jira ticket number (e.g., "CMS-12345" or just "12345") |
Usage:
schwab checkout CMS-12345
schwab checkout 12345
Features:
- Automatically formats branch names based on ticket type (feature/bugfix)
- Checks for existing local branches
- Searches for remote branches
- Offers to create new branches from main or current branch
- Prompts to create feature flags if labels begin with
FF_ - Updates Jira ticket status to "In Progress"
Branch Naming Convention: The CLI automatically creates branches following this pattern:
feature/{JIRA-PREFIX}-{TICKET-NUMBER}-{SANITIZED-SUMMARY}bugfix/{JIRA-PREFIX}-{TICKET-NUMBER}-{SANITIZED-SUMMARY}
commit
Commits changes.
| Option | Type | Required | Description |
|---|---|---|---|
| None | - | - | Interactive prompts guide the process |
Usage:
schwab commit
Interactive Prompts:
- App Selection: Choose which apps to deploy changes to
- Version Control: Select version bump type (major/minor/patch) for each app
- Testing Strategy: Choose testing approach (integration ~15 mins, regression ~1 hour)
- Feature Flags: Optionally create feature flag files
context
Lists all directories in the repository.
| Option | Type | Required | Description |
|---|---|---|---|
| None | - | - | No options available |
Usage:
schwab context
Description: Displays the directory structure of the monorepo, including all apps and packages.
contrib
Collects hours worked on tickets and posts to Jira.
| Option | Type | Required | Description |
|---|---|---|---|
ticket | String | No | Specific Jira ticket number |
hours | Number | No | Number of hours worked |
Usage:
schwab contrib
schwab contrib 4
schwab contrib CMS-12345 4
Description: Should be run daily to track time spent on tickets. If no parameters are provided, it will prompt interactively for the information.
kill
Terminates a process running on a specific port.
| Option | Type | Required | Description |
|---|---|---|---|
port | Number | Yes | Port number to kill (can specify multiple) |
Usage:
schwab kill 3000
schwab kill 3000 3001 3002
Description: Useful for freeing up ports when development servers don't shut down cleanly.
pr
Opens your pull request(s) for the current or specified Jira ticket in GitHub.
| Option | Type | Required | Description |
|---|---|---|---|
JiraTicket | String | No | Jira ticket number (prompts if not provided) |
Usage:
schwab pr
schwab pr CMS-12345
Features:
- Lists all PRs associated with the ticket
- Allows selection if multiple PRs exist
- Opens the selected PR in your default browser
pullflags
Creates feature flag files for labels that begin with FF_ in Jira.
| Option | Type | Required | Description |
|---|---|---|---|
JiraTicket | String | No | Jira ticket number (prompts if not provided) |
Usage:
schwab pullflags
schwab pullflags CMS-12345
Description:
Reads Jira labels starting with FF_ and generates corresponding feature flag files in the appropriate directories.
push
Pushes the current branch to the remote repository and optionally creates a pull request.
| Option | Type | Required | Description |
|---|---|---|---|
| None | - | - | Interactive prompts if PR doesn't exist |
Usage:
schwab push
Features:
- Pushes current branch to origin
- Prompts to create a PR if one doesn't exist
- Creates draft PR by default
ready
Updates the PR status to "Ready for Review" and collects testing information.
| Option | Type | Required | Description |
|---|---|---|---|
JiraTicket | String | No | Jira ticket number (prompts if not provided) |
Usage:
schwab ready
schwab ready CMS-12345
Interactive Prompts:
- Testing Scenarios: Step-by-step testing instructions
- Demo Links: URLs demonstrating the changes
- Additional Notes: Any extra context for QA
- Bug Fixes: Link related bugs this PR addresses
Actions Performed:
- Adds "Ready for Review" label to GitHub PR
- Posts testing scenarios to Jira ticket
- Updates Jira status to "Ready for Review"
- Links related bug tickets
release-report
Generates a report of all tickets merged to main since the last production release.
| Option | Type | Required | Description |
|---|---|---|---|
appName | String | No | Specific app to report on (prompts if not provided) |
Usage:
schwab release-report
schwab release-report www.schwab.com
Description: Compares the current production deployment with the main branch to identify all tickets that have been merged but not yet released.
Report Contents:
- List of merged tickets
- What changed (summaries)
- Why changes were made
- Feature flags involved
reset
Resets the current Git branch to match the remote branch.
| Option | Type | Required | Description |
|---|---|---|---|
| None | - | - | Interactive confirmation required |
Usage:
schwab reset
Description: Hard resets your local branch to match the remote origin.
This will permanently discard all uncommitted changes. Make sure you don't have any work you want to keep before running this command.
test
Runs tests for the repository.
| Option | Type | Required | Description |
|---|---|---|---|
| None | - | - | No options available |
Usage:
schwab test
Description: Executes the test suite for the monorepo. The specific tests run depend on the project configuration.
ticket
Opens the Jira ticket for your current branch in your default browser.
| Option | Type | Required | Description |
|---|---|---|---|
| None | - | - | Automatically detects ticket from branch name |
Usage:
schwab ticket
Description:
Extracts the Jira ticket number from your current Git branch name and opens the ticket in your browser at https://jira.schwab.com/browse/{TICKET}.
worklog
Reports hours worked for a specific date or date range.
| Option | Type | Required | Description |
|---|---|---|---|
startDate | String (YYYY-MM-DD) | No | Start date for the report |
endDate | String (YYYY-MM-DD) | No | End date for the report |
Usage:
schwab worklog
schwab worklog 2024-10-01
schwab worklog 2024-10-01 2024-10-07
Description: Generates a report showing all work logged by team members for the specified date range. Displays:
- Tickets worked on
- Time spent per ticket
- Total hours per developer
Technical Details
Implementation
The CLI is implemented using:
- Shell scripts (.sh) for Git operations and system commands
- Node.js modules (.mjs) for complex logic and API interactions
- Inquirer.js for interactive prompts
- simple-git for Git operations
- Chalk for colorized output