Skip to main content

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

CommandWhat It Does
assignmentsLists all open Jira tickets assigned to the team
branches-cleanupRemoves all local Git branches that have been merged into main
checkoutChecks out a Jira ticket branch with intelligent branch management
commitCommits changes
contextLists all directories in the repository
contribLogs hours worked on tickets and posts to Jira (should be run daily)
killTerminates a process running on a specific port
prOpens your pull request(s) for a Jira ticket in GitHub
pullflagsCreates feature flag files for Jira labels beginning with FF_
pushPushes current branch to remote and optionally creates a pull request
readyUpdates PR to "Ready for Review" and collects testing information
release-reportGenerates a report of all tickets merged since last production release
resetResets the current Git branch to match the remote branch
testRuns the test suite for the repository
ticketOpens the Jira ticket for your current branch in browser
worklogReports 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.

OptionTypeRequiredDescription
statusStringNoFilter 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.

OptionTypeRequiredDescription
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.

Destructive Operation

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.

OptionTypeRequiredDescription
JiraTicketStringNoJira 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.

OptionTypeRequiredDescription
None--Interactive prompts guide the process

Usage:

schwab commit

Interactive Prompts:

  1. App Selection: Choose which apps to deploy changes to
  2. Version Control: Select version bump type (major/minor/patch) for each app
  3. Testing Strategy: Choose testing approach (integration ~15 mins, regression ~1 hour)
  4. Feature Flags: Optionally create feature flag files

context

Lists all directories in the repository.

OptionTypeRequiredDescription
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.

OptionTypeRequiredDescription
ticketStringNoSpecific Jira ticket number
hoursNumberNoNumber 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.

OptionTypeRequiredDescription
portNumberYesPort 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.

OptionTypeRequiredDescription
JiraTicketStringNoJira 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.

OptionTypeRequiredDescription
JiraTicketStringNoJira 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.

OptionTypeRequiredDescription
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.

OptionTypeRequiredDescription
JiraTicketStringNoJira ticket number (prompts if not provided)

Usage:

schwab ready
schwab ready CMS-12345

Interactive Prompts:

  1. Testing Scenarios: Step-by-step testing instructions
  2. Demo Links: URLs demonstrating the changes
  3. Additional Notes: Any extra context for QA
  4. 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.

OptionTypeRequiredDescription
appNameStringNoSpecific 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.

OptionTypeRequiredDescription
None--Interactive confirmation required

Usage:

schwab reset

Description: Hard resets your local branch to match the remote origin.

Destructive Operation

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.

OptionTypeRequiredDescription
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.

OptionTypeRequiredDescription
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.

OptionTypeRequiredDescription
startDateString (YYYY-MM-DD)NoStart date for the report
endDateString (YYYY-MM-DD)NoEnd 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