Overview
GitHub Achievement CLI requires GitHub Personal Access Tokens (PATs) to interact with the GitHub API. You’ll need:- Main account token (required): For your primary GitHub account
- Helper account token (optional): For Galaxy Brain and YOLO achievements
Creating a GitHub Personal Access Token
Navigate to Token Settings
Go to GitHub’s Personal Access Token page:https://github.com/settings/tokensOr navigate manually:
- Click your profile picture (top right)
- Settings → Developer settings → Personal access tokens → Tokens (classic)
Generate New Token
Click Generate new token → Generate new token (classic)You may be asked to confirm your password.
Use “classic” tokens, not “fine-grained” tokens. The CLI is designed for classic PATs.
Configure Token
Fill in the token details:Note: Give your token a descriptive name
- Example:
GitHub Achievement CLI - Main Account - Example:
GitHub Achievement CLI - Helper Account
- Recommendation: 90 days (balance between security and convenience)
- You can regenerate when it expires
Select Scopes
Select the required scopes (permissions) for the token.
For Main Account Token:
Required scope:- ✅ repo (Full control of private repositories)
- Includes:
repo:status,repo_deployment,public_repo,repo:invite,security_events
- Includes:
- Create and delete branches
- Make commits
- Open and merge pull requests
- Create and close issues
- Access repository discussions
For Helper Account Token:
Required scopes:- ✅ repo (Full control of private repositories)
- ✅ write:discussion (Read and write discussion content)
The helper token needs
write:discussion to create discussion questions and mark answers as accepted.Generate and Copy Token
Click Generate token at the bottom of the page.Your token will be displayed once - copy it immediately!
- Format:
ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(classic) - Or:
github_pat_xxxxxxxxxxxxxxxxxxxxxxxxxxxx(fine-grained, if used) - Length: 40+ characters
Token Requirements
Main Account Token
Must start with
ghp_ or github_pat_repo - Full control of private repositories
Token must allow:
- Creating/deleting branches
- Creating commits
- Opening/merging pull requests
- Creating/closing issues
- Accessing discussions (if enabled)
Helper Account Token (Optional)
Must start with
ghp_ or github_pat_- repo - Full control of private repositories
- write:discussion - Read and write discussion content
Must be from a different GitHub account than the main token
Helper account should be added as a collaborator on the target repository
Setting Up Helper Account
Galaxy Brain and YOLO achievements require a second GitHub account:Create Second GitHub Account
If you don’t have a second account:
- Sign out of your main GitHub account
- Go to https://github.com/join
- Create a new account (free tier is sufficient)
- Verify email address
You can use a
+ alias in your email: [email protected]Generate Helper Token
While logged into your helper account:
- Go to https://github.com/settings/tokens
- Generate new token (classic)
- Select scopes: repo and write:discussion
- Copy the token
Add Helper as Collaborator
From your main account:
- Go to your target repository
- Settings → Collaborators → Add people
- Enter helper account username
- Send invitation
- Check email or GitHub notifications
- Accept the collaboration invitation
The CLI setup wizard can do this automatically for you.
Token Validation
The CLI validates tokens during setup:Using Tokens in Configuration
Tokens are stored in your.env file:
Token Security Best Practices
Protection
Never commit tokens to Git
Never commit tokens to Git
- Always use
.envfiles (excluded by.gitignore) - Never hardcode tokens in source code
- Use environment variables, not inline strings
- Review commits before pushing
Use minimal required scopes
Use minimal required scopes
- Main token: Only
reposcope - Helper token: Only
repoandwrite:discussion - Don’t grant additional unnecessary permissions
Set expiration dates
Set expiration dates
- Choose 30-90 day expiration periods
- Rotate tokens before expiration
- Delete old tokens from GitHub settings
- Keep track of expiration dates
Secure storage
Secure storage
- Store tokens in password manager
- Don’t share tokens via email/chat
- Don’t include in screenshots
- Clear terminal history after pasting
Monitor token usage
Monitor token usage
- Check GitHub Settings → Personal access tokens
- Review “Last used” dates
- Delete unused tokens
- Regenerate if compromised
If Token is Compromised
If you suspect your token has been exposed:Revoke Immediately
- Go to https://github.com/settings/tokens
- Find the compromised token
- Click Delete or Revoke
- Confirm deletion
Generate New Token
Follow the token creation steps to create a new token with the same scopes.
Token Expiration
When your token expires:-
CLI will fail with authentication errors
- Generate a new token with the same scopes
-
Update
.envfile with the new token - Restart the CLI - it will work immediately
Set a calendar reminder a few days before expiration to rotate tokens proactively.
Troubleshooting Tokens
Token Validation Failed
Symptoms: CLI shows “Token validation failed. Check your token and try again.” Solutions:- Verify token format starts with
ghp_orgithub_pat_ - Check token hasn’t expired (GitHub settings)
- Ensure repo scope is selected
- Try regenerating the token
- Check internet connectivity
- Verify no typos when copying token
Insufficient Permissions
Symptoms: Errors when creating branches, PRs, or issues Solutions:- Verify token has repo scope (not just
public_repo) - Check you have write access to target repository
- Ensure repository isn’t archived or disabled
- Confirm token is from correct account
Helper Token Rejected
Symptoms: “Helper account must be different from your main account” Solutions:- Use token from a different GitHub account
- Verify you’re logged into helper account when generating token
- Create a second GitHub account if needed
Rate Limiting
Symptoms: “Rate limit exceeded” errors Solutions:- Wait for rate limit reset (check error message for time)
- Increase
DELAY_MSin configuration - Reduce
BATCH_SIZEfor fewer parallel operations - Authenticated requests have higher limits (5000/hour vs 60/hour)
Checking Token Info
You can check token details via GitHub API:- Go to https://github.com/settings/tokens
- View token details (note, scopes, last used)
Next Steps
Initial Setup
Complete setup wizard with your tokens
Environment Variables
Configure all settings in .env file
Achievements
Start earning achievements
Troubleshooting
Common issues and solutions