Bootstrap .env with runtime context defaults and task management connection details from the platform instance
Bootstrap the repo-root .env file with runtime context defaults and connection credentials for the task management platform. This is the first skill a new user runs to set up their workspace.
!cat "$(git rev-parse --show-toplevel 2>/dev/null || echo .)/.env" 2>/dev/null || echo "No .env file found"
If .env doesn't exist, create it from .env.defaults:
REPO_ROOT="$(git rev-parse --show-toplevel)"
if [ ! -f "$REPO_ROOT/.env" ]; then
cp "$REPO_ROOT/.env.defaults" "$REPO_ROOT/.env"
echo "Created .env from defaults"
fi
Then verify key runtime context variables are set:
source "$REPO_ROOT/.env"
echo "Cluster: $NEB_CLUSTER_CONTEXT"
echo "Domain: $NEB_DOMAIN"
echo "GitOps: $NEB_GITOPS_DEPLOY_DIR"
echo "AWS Account: $NEB_AWS_ACCOUNT_ID"
If the user provides different values during setup, update the .env file accordingly.
Read the .env file at the repo root ($REPO_ROOT/.env where $REPO_ROOT is determined by git rev-parse --show-toplevel).
NEB_TASK_* variables and preserve their values as defaults.Store these as the current state:
NEB_TASK_API_URL=<existing or empty>
NEB_TASK_COMPANY_ID=<existing or empty>
NEB_TASK_PREFIX=<existing or empty>
NEB_TASK_AGENT_ID=<existing or empty>
NEB_TASK_API_KEY=<existing or empty>
If NEB_TASK_API_URL is already set, show the current value and ask if the user wants to keep it.
If not set, use AskUserQuestion to prompt:
Platform instance URL? This is the URL where your task management platform is running. Default:
http://127.0.0.1:3101Press Enter to accept the default, or enter a custom URL.
If the user provides no input or confirms the default, use http://127.0.0.1:3101.
Store the result as API_URL.
Determine whether the instance is local (direct Paperclip) or remote (platform-backend proxy):
127.0.0.1 or localhost — Paperclip API is accessed directly at /api/*https://api.nebcore.ai) — Paperclip API is behind platform-backend proxy at /api/v1/orgs/{companyId}/ai/*Store as DEPLOY_MODE (local or remote).
Health check depends on deployment mode:
Local mode:
curl -sf --max-time 5 "${API_URL}/api/health"
Remote mode (platform-backend):
# Platform liveness probe — no auth required
curl -sf --max-time 5 "${API_URL}/healthz"
Then, if NEB_TASK_API_KEY and NEB_TASK_COMPANY_ID are already set, also verify the AI server is reachable through the proxy:
curl -sf --max-time 5 "${API_URL}/api/v1/orgs/${NEB_TASK_COMPANY_ID}/ai/health" \
-H "Authorization: Bearer ${NEB_TASK_API_KEY}"
Expected response: JSON with {"status":"ok",...}
If the health check fails, report the error and provide troubleshooting guidance:
ERROR: Cannot reach the platform at ${API_URL}
Troubleshooting:
1. Verify the platform is running
2. Local: confirm port matches (default: 3101)
3. Remote: /healthz should respond without auth
4. If API key is set, verify AI server health via proxy:
curl ${API_URL}/api/v1/orgs/{companyId}/ai/health -H "Authorization: Bearer $KEY"
Run /neb-env-setup again once the platform is accessible.
STOP here if health check fails. Do not proceed.
How to list companies depends on deployment mode:
Local mode (direct Paperclip, local_trusted — no auth needed):
curl -sf --max-time 5 "${API_URL}/api/companies"
Remote mode (platform-backend proxy — requires JWT auth):
The AI proxy path requires a company ID to construct the URL, creating a bootstrap problem. Handle it as follows:
NEB_TASK_COMPANY_ID and NEB_TASK_API_KEY are already in .env, verify them:curl -sf --max-time 5 "${API_URL}/api/v1/orgs/${NEB_TASK_COMPANY_ID}/ai/companies/${NEB_TASK_COMPANY_ID}" \
-H "Authorization: Bearer ${NEB_TASK_API_KEY}"
echo "$NEB_TASK_API_KEY" | cut -d. -f2 | base64 -d 2>/dev/null | python3 -c "import sys,json; print(json.load(sys.stdin).get('company_id',''))"
Expected response: JSON company object with id, name, and issuePrefix fields.
If zero companies are returned or validation fails:
ERROR: No companies found or company not accessible.
For remote instances, ensure you have a valid API key with company access.
STOP here.
If exactly one company exists (local mode): Auto-select it. Print:
Found company: <name> (prefix: <issuePrefix>)
Using this as your active company.
If multiple companies exist (local mode): Use AskUserQuestion to prompt the user to select:
Multiple companies found. Which one should be your active company?
- <name1> (prefix: <prefix1>)
- <name2> (prefix: <prefix2>) ...
Enter the number of your choice:
From the selected/verified company object, extract:
COMPANY_ID = the id fieldPREFIX = the issuePrefix fieldConfirm access by fetching the specific company:
Local mode:
curl -sf --max-time 5 "${API_URL}/api/companies/${COMPANY_ID}"
Remote mode:
curl -sf --max-time 5 "${API_URL}/api/v1/orgs/${COMPANY_ID}/ai/companies/${COMPANY_ID}" \
-H "Authorization: Bearer ${NEB_TASK_API_KEY}"
If this fails, report the error and stop.
Write the .env file at the repo root. Preserve any existing NEB_TASK_AGENT_ID and NEB_TASK_API_KEY values if they were already set (these are populated by /neb-work).
The .env file content:
# Task Management Platform — connection credentials
# Generated by /neb-env-setup on <current date>
# Agent credentials are set by /neb-work
NEB_TASK_API_URL=<API_URL>
NEB_TASK_COMPANY_ID=<COMPANY_ID>
NEB_TASK_PREFIX=<PREFIX>
NEB_TASK_AGENT_ID=<existing value or empty>
NEB_TASK_API_KEY=<existing value or empty>
IMPORTANT: If the .env file contained other non-NEB_TASK_* variables, preserve them at the end of the file under a # Other settings comment.
Print a clear success message:
Environment setup complete.
API URL: <API_URL>
Company: <company name>
Company ID: <COMPANY_ID>
Prefix: <PREFIX>
Deploy Mode:<local or remote>
Agent ID: <set or "not set — run /neb-work to configure">
API Key: <set or "not set — run /neb-work to configure">
.env written to: <repo_root>/.env
Next steps:
- Run /neb-work to register as an agent and get API credentials
- Then use /neb-task-exe, the platform orchestrator, etc. to work on tasks
curl commands use --max-time 5 to avoid hanging on unreachable hosts.-sf (silent + fail) so non-2xx responses are treated as errors.python3 -c "import sys,json; ..." for reliability..env.${NEB_TASK_API_URL}/api/v1/orgs/${NEB_TASK_COMPANY_ID}/ai/*.NEB_TASK_ prefix..env file lives at the repo root only — never in subdirectories.AskUserQuestion for all interactive prompts — never assume user input.