In this lesson, you will learn how to supercharge your daily workflow by creating custom CLI shortcuts that eliminate repetitive terminal commands.
When working with Expo, you likely find yourself typing the same commands over and over: npx expo start, npx expo run:ios, or complex commands for clearing your cache. As you scale your project, these repetitive tasks become a bottleneck. We can streamline this by using two main patterns: package.json scripts and shell aliases.
1. Custom NPM Scripts
Your package.json file is the heart of your project's CLI interface. Instead of remembering specific build flags or clean-up sequences, add them to the scripts object.
"scripts": {
"start:clean": "watchman watch-del-all && rm -rf .expo && npx expo start -c",
"ios:dev": "npx expo run:ios",
"android:dev": "npx expo run:android"
}
Now, instead of typing a long string of commands, you can simply run npm run start:clean. This ensures you always start with a fresh environment, saving you from "why isn't my change showing up?" headaches.
2. Environment-Aware Shell Aliases
If you work across multiple projects, you can go a step further by creating aliases in your shell configuration file (like .zshrc or .bash_profile). Aliases allow you to execute commands globally without prefixing them with npm run or navigating to specific folders.
For example, add this to your ~/.zshrc:
# Shortcut for Expo start
alias es="npx expo start"
# Shortcut for running iOS build directly
alias eri="npx expo run:ios"
Once you source your config file (source ~/.zshrc), you can trigger your build process with just two keystrokes.
Why this matters
By treating your terminal as a programmable environment, you reduce "cognitive load"—the mental energy spent remembering syntax instead of writing code. When your tools work for you, you can focus entirely on the logic of your React Native components and the architecture of your app.
Key Takeaway: Automate your repetitive CLI commands using custom scripts in package.json and shell aliases to minimize friction in your daily development loop.