Spotify Integration Setup
Connect your Spotify account to automatically add your currently playing song to commit messages. This guide will walk you through the complete setup process.
Prerequisites
- A Spotify account (free or premium)
- Node.js installed (commit-vibes requires Node.js 16+)
- Basic familiarity with terminal/command line
Step 1: Create a Spotify App
First, you need to create a Spotify application in the Spotify Developer Dashboard to get API credentials.
- Go to Spotify Developer Dashboard
- Log in with your Spotify account
- Click "Create app" or "Create an app"
-
Fill in the app details:
- App name: Choose any name (e.g., "commit-vibes")
- App description: Optional description
- Redirect URI:
http://127.0.0.1:3000(important: use IP address, not localhost) - Website: Optional, can leave blank or use your GitHub repo URL
- Check the "I understand and agree to Spotify's Developer Terms of Service" checkbox
- Click "Save"
Important: Spotify requires using http://127.0.0.1:3000 instead of http://localhost:3000 for redirect URIs. Make sure you use the IP address format.
Step 2: Get Your Credentials
After creating your app, you'll need to get your Client ID and Client Secret.
- In your app's dashboard, you'll see your Client ID displayed
- Click "Show client secret" to reveal your Client Secret
- Copy both values - you'll need them in the next step
Security Note: Never share your Client Secret publicly. Keep it secure and don't commit it to version control.
Step 3: Configure commit-vibes
Now you'll add your Spotify credentials to commit-vibes. You can use either environment variables (recommended) or a config file.
Option A: Environment Variables (Recommended)
This is the recommended approach as it keeps credentials out of your codebase.
-
In your project root (or home directory for global config), create a
.envfile:
SPOTIFY_CLIENT_ID=your_client_id_here
SPOTIFY_CLIENT_SECRET=your_client_secret_here
SPOTIFY_REDIRECT_URI=http://127.0.0.1:3000 -
Replace
your_client_id_hereandyour_client_secret_herewith your actual credentials from Step 2 -
Make sure
.envis in your.gitignorefile (it should be by default)
Option B: Config File
Alternatively, you can create a config file in the commit-vibes source directory.
-
Navigate to the commit-vibes installation directory (usually in
node_modules/commit-vibes/src/config/) -
Copy the template file:
cp spotify.template.js spotify.js -
Edit
spotify.jsand replace the placeholder values:export const SPOTIFY_CONFIG = { clientId: "your_actual_client_id", clientSecret: "your_actual_client_secret", redirectUri: "http://127.0.0.1:3000", scopes: ["user-read-currently-playing", "user-read-recently-played"], };
Note: If you installed commit-vibes globally via npm, the config file approach may be overwritten on updates. Environment variables are more persistent.
Step 4: Set App to Development Mode
For local development, your Spotify app needs to be in Development Mode.
- In the Spotify Developer Dashboard, go to your app's Settings
- Find the "App status" or "Application type" section
- Make sure it's set to "Development Mode" (not Production)
- If in Development Mode, go to "Users and Access" and add your Spotify account email to the allowed users list
- Click "Save"
Why Development Mode? Development Mode allows you to use http:// (non-HTTPS) redirect URIs for localhost, which is required for local development. Production Mode requires HTTPS.
Step 5: Connect Your Account
Now you're ready to connect your Spotify account to commit-vibes.
-
Run the connect command:
commit-vibes --spotify - Your default browser (or Chrome if configured) will open to Spotify's authorization page
- Log in to Spotify if prompted
-
Review the permissions commit-vibes is requesting:
- Read your currently playing content - To show what song you're listening to
- Read your recently played tracks - To show recent songs if nothing is currently playing
- Click "Agree" or "Authorize"
- You'll see a success page - you can close the browser tab
- Return to your terminal - you should see a success message
Step 6: Verify Connection
Test that everything is working correctly.
-
Check your connection status:
commit-vibes --status -
You should see:
- ✨ Spotify is connected!
- Your currently playing track (if music is playing)
- Or your most recent track (if nothing is playing)
Troubleshooting
Error: "INVALID_CLIENT: Insecure redirect URI"
This means your redirect URI doesn't match between your code and Spotify dashboard.
- Make sure you're using
http://127.0.0.1:3000(notlocalhost) - Verify it's exactly the same in both your
.envfile and Spotify dashboard - Check for any trailing spaces or characters
- Make sure your app is in Development Mode
Error: "Spotify token has expired"
Your access token has expired. Simply reconnect:
commit-vibes --spotify Error: "Spotify is not configured"
commit-vibes can't find your credentials. Check:
- Your
.envfile exists and is in the correct location - The environment variables are named correctly:
SPOTIFY_CLIENT_ID,SPOTIFY_CLIENT_SECRET - There are no typos in the variable names
- If using a config file, make sure it's in the correct location
Browser Opens Safari Instead of Chrome
By default, commit-vibes tries to open Chrome. If it's not available, it falls back to your default browser. To ensure Chrome opens:
- Make sure Chrome is installed
- The code will automatically try Chrome first, then fall back to default
Connection Works But No Music Shows
If your connection is successful but no music appears:
- Make sure Spotify is actually playing music (not paused)
- Try the
--statuscommand to see what commit-vibes detects - Check that your Spotify app has the correct scopes enabled
Disconnecting Spotify
To disconnect your Spotify account:
commit-vibes --disconnect
This will remove your stored tokens. You can reconnect anytime using --spotify.
Security Best Practices
- Never commit your
.envfile orspotify.jsconfig file to version control - Keep your Client Secret private - treat it like a password
- If you suspect your credentials are compromised, regenerate them in the Spotify Dashboard
- Use environment variables instead of config files when possible
Next Steps
Once Spotify is connected, you can:
- Use
commit-vibesto create commits with your current song - Use
commit-vibes --previewto test without creating commits - Your music will automatically be included in commit messages when available