Skip to content

Mental model (Why / What / How)

Understanding jpd’s design philosophy helps you use the tool more effectively and predictably. jpd follows a clean Why/What/How mental model that makes the CLI intuitive and consistent.

jpd’s command structure follows this logical hierarchy:

The root command jpd represents the Why - your overall purpose or goal. In this case:

“I want a universal package manager interface that works across all JavaScript runtimes.”

When you type jpd, you’re saying “I want to work with JavaScript packages, but I don’t want to think about which specific package manager to use.”

Subcommands represent the What - the specific action or concept you want to work with:

SubcommandWhat it representsPurpose
installPackage installationAdd dependencies to your project
runScript executionExecute tasks defined in your project
execPackage executionRun packages without installing them
createProject creationInitialize new projects from templates
updatePackage updatesUpgrade dependencies to newer versions
uninstallPackage removalRemove dependencies from your project
clean-installClean installationInstall packages with frozen lockfiles (CI/CD)
agentPackage manager detectionShow which package manager jpd detected
completionShell completionGenerate tab completion scripts

Each subcommand is a verb (action) or noun (entity) that clearly describes what you’re trying to accomplish.

Flags and environment variables represent the How - they modify how your action is executed:

FlagPurposeMental Model
--agent / -aOverride package manager”Do this, but force a specific tool”
--cwd / -CChange working directory”Do this, but in a different location”
--debug / -dEnable debug logging”Do this, but show me exactly what’s happening”

Command-Specific Flags (How to modify specific actions)

Section titled “Command-Specific Flags (How to modify specific actions)”
CommandFlagPurpose
install--dev / -D”Install this, but as a development dependency”
install--global / -g”Install this, but globally”
install--search / -s”Install this, but let me search for packages first”
uninstall--interactive / -i”Uninstall this, but let me select what to remove”
run--if-present”Run this, but only if the script exists”
VariablePurpose
JPD_AGENTSet default package manager for the entire session

Let’s see how this mental model works in practice:

Terminal window
jpd install lodash
  • Why: “I want to use the universal package manager interface”
  • What: “To install a package”
  • How: “Using whatever package manager jpd detects”

Example 2: Development Dependency with Override

Section titled “Example 2: Development Dependency with Override”
Terminal window
jpd install --dev --agent yarn vitest
  • Why: “I want to use the universal package manager interface”
  • What: “To install a package”
  • How: “As a development dependency, using Yarn specifically”

Example 3: Running in a Subproject with Debug

Section titled “Example 3: Running in a Subproject with Debug”
Terminal window
jpd run --cwd ./packages/ui/ --debug build
  • Why: “I want to use the universal package manager interface”
  • What: “To run a script”
  • How: “In a specific directory, showing me debug information”

jpd’s mental model aligns with well-established CLI design principles:

Once you understand the Why/What/How pattern, you can predict how new commands will work:

  • New What commands will be verbs or nouns describing actions/entities
  • New How flags will modify behavior without changing the core action
  • The Why (universal package management) remains constant

Flags can be combined logically because they operate at the “How” level:

Terminal window
# Multiple "How" modifiers work together
jpd install --dev --global --agent pnpm --debug typescript

The structure helps you discover functionality:

  • jpd --help shows all the “What” you can do
  • jpd install --help shows all the “How” for installation
  • Tab completion guides you through valid combinations

jpd’s help system reinforces the mental model:

Terminal window
jpd --help

Shows the overall purpose and lists all available “What” actions.

Terminal window
jpd install --help

Shows what installation does and all the ways you can modify how it works.

Global flags like --agent, --cwd, and --debug work consistently across all commands because they modify “How” rather than “What”.

Understanding this structure provides several benefits:

New users can quickly understand the command structure without memorizing each command individually.

The logical hierarchy makes it easier to construct valid commands and avoid syntax errors.

Scripts and CI/CD pipelines become more maintainable when the underlying logic is clear.

When something goes wrong, you can systematically check:

  • Is the “Why” correct? (Are you using jpd appropriately?)
  • Is the “What” correct? (Is this the right action?)
  • Is the “How” correct? (Are the flags and environment set properly?)

Most package managers mix “What” and “How”:

Terminal window
# Traditional approach - mixes what and how
npm install --save-dev typescript
yarn add --dev typescript
pnpm add --save-dev typescript
# jpd approach - clear separation
jpd install --dev typescript

jpd’s approach keeps the “What” (install) consistent while only changing the “How” (—dev flag and auto-detected package manager).

Once you understand the mental model, advanced patterns become intuitive:

Terminal window
export JPD_AGENT=yarn
# All subsequent jpd commands use Yarn
jpd install
jpd run build
jpd update
Terminal window
# Monorepo workflow - consistent "What", different "How"
jpd install --cwd ./frontend/
jpd install --cwd ./backend/
jpd run --cwd ./frontend/ build
jpd run --cwd ./backend/ test
Terminal window
# Add --debug to any command to understand what's happening
jpd install --debug
jpd run --debug build
jpd exec --debug create-react-app my-app

Now that you understand jpd’s mental model: