Login with Device-Code Flow
Thelogin command initiates an OAuth device-code flow:
How Device-Code Flow Works
- Request authorization code - CLI requests a device code from the server
- Open browser - CLI automatically opens your browser to the verification URL
- Authorize in browser - You confirm the login in your browser
- Poll for token - CLI polls the server for an access token
- Save session - Token is saved to local config directory
Manual Browser Opening
If the browser doesn’t open automatically:- Copy the verification URL from the terminal
- Open it in your browser manually
- Enter the code if prompted
- The CLI will detect the authorization and continue
Polling Behavior
The CLI polls the server every 1-5 seconds (based on server response). Status updates include:- authorization_pending - Still waiting for browser confirmation
- slow_down - Server requested slower polling (interval increases by 5s)
- access_denied - Login was denied in the browser
- expired_token - Login code expired (run
loginagain)
Logout
Thelogout command signs you out and clears your local session:
- Sends a sign-out request to the server (if reachable)
- Deletes the local session file
- Works even if the server is unreachable
Check Current Session
Thewhoami command displays your current session info:
whoami to verify your session before running other commands.
Session Storage
Sessions are stored as JSON in:XDG_CONFIG_HOME is set:
Session Format
The session file contains:SERVER_URL Configuration
By default, the CLI connects tohttp://localhost:3000. To connect to a different server:
@better-skills/env/cli for runtime config, which respects:
- Environment variable
SERVER_URL .envfile in the project root- Default value
http://localhost:3000
Authentication Flow Diagram
Troubleshooting
Browser Doesn’t Open
If the CLI can’t open your browser automatically:- Copy the verification URL from the terminal
- Open it manually in any browser
- The CLI will continue polling
Session Expired
If you see “session invalid or expired”:Server Unreachable
If the CLI can’t reach the server:- Check your
SERVER_URLenvironment variable - Verify the server is running
- Check network connectivity
Permission Denied
If you can’t write to~/.config/better-skills/:
- Check directory permissions
- Set
XDG_CONFIG_HOMEto a writable directory - Run with appropriate user permissions
Next Steps
Skill Commands
Start managing skills after authentication
Sync Workflow
Configure automatic skill syncing