Configure tokens
Ensure GITHUB_TOKEN and SNYK_TOKEN exist in the user’s shell profile so other skills can rely on them. Use .zprofile for zsh and .bash_profile for bash (typical on macOS).
Variables
| Variable | Purpose |
|---|---|
GITHUB_TOKEN |
GitHub API / gh / git HTTPS |
SNYK_TOKEN |
Snyk CLI and Snyk API |
SNYK_CASES_DIR |
Directory where support cases are stored (written by configure) |
Optional: GH_TOKEN is treated as an alias for GitHub when reading the profile; the script normalizes to GITHUB_TOKEN in the profile.
Cases directory
- Default path:
~/Desktop/cases(i.e.$HOME/Desktop/caseson macOS). - On each run, configure creates that folder if it does not exist and sets
SNYK_CASES_DIRin the same managed profile block as the tokens so other skills can use"${SNYK_CASES_DIR}"(or$SNYK_CASES_DIR) for per-case subfolders. - Override the path for the script only:
CASES_ROOT=/custom/path ./configure/scripts/configure_tokens.sh(the profile will still exportSNYK_CASES_DIRpointing at that path).
When this skill runs
- Detect profile file from the user’s login shell (
$SHELL):zsh→~/.zprofile,bash→~/.bash_profile. Override withPROFILE_FILEif needed. - Read existing tokens from the profile (
GITHUB_TOKEN, thenGH_TOKENfor GitHub;SNYK_TOKENfor Snyk). If the profile value is missing, empty, or only whitespace, fall back to the current environment (GITHUB_TOKEN/GH_TOKEN/SNYK_TOKEN). Anything still empty after that is treated as unset. - Validate each token when possible (skipped when
SKIP_VALIDATION=1, but empty tokens are never accepted):- GitHub:
GET https://api.github.com/userwithAuthorization: Bearer <token>. - Snyk:
GET https://api.snyk.io/v1/userwithAuthorization: token <token>.
- GitHub:
- If a value is unset (including
export GITHUB_TOKEN=""or whitespace-only in the profile) or validation fails, prompt again until the user enters a non-empty token that validates (when validation is enabled). - If a value exists and validates, skip that variable and continue.
- Ensure the cases directory exists and write
SNYK_CASES_DIRinto the managed profile block (refreshed every successful run).
Script (recommended)
Run the interactive helper from the repo root:
chmod +x configure/scripts/configure_tokens.sh
./configure/scripts/configure_tokens.sh
Optional:
PROFILE_FILE="$HOME/.zprofile" ./configure/scripts/configure_tokens.sh
If you cannot reach GitHub/Snyk APIs (offline/air-gapped), skip HTTP checks (non-empty token only):
SKIP_VALIDATION=1 ./configure/scripts/configure_tokens.sh
The script:
- Creates the profile file if it does not exist.
- Creates
~/Desktop/cases(orCASES_ROOT) and exportsSNYK_CASES_DIRin the managed block. - Treats empty and whitespace-only token values as missing and re-prompts until values are non-empty (and valid when checks are on).
- Adds or updates a marked block (
# --- snyk-skills-tokens (managed by configure skill) ---) so repeated runs do not duplicate lines. - Tells the user to
sourcethe profile or open a new terminal.
Agent behavior (no script)
If the user cannot run the script, the agent should:
- Determine profile path from
$SHELL(or ask). - Inspect the profile for existing exports; treat empty / whitespace-only as not set; consider
GITHUB_TOKEN/GH_TOKEN/SNYK_TOKENin the environment only when the profile does not supply a non-empty value. - For each unset or invalid token, keep prompting until the user provides a non-empty value (and valid where applicable), then append or replace exports in the marked block.
- Never echo full tokens back in chat; confirm only that they were set.
- Ensure
~/Desktop/casesexists (or the path the user chose viaCASES_ROOT) and thatSNYK_CASES_DIRis documented in the profile block after a successful configure.
Undo (demos / misconfiguration)
To remove the configure-managed token block from the profile, use the reset-configure-tokens skill: reset/SKILL.md and reset/scripts/reset_configure_tokens.sh.
References
- Shell profile details:
references/profiles.md