Sharkly Access Token Tutorial: Create Tasks From GitHub Actions

Want GitHub Actions to file Sharkly tasks? Learn how to set up a Sharkly access token, file a Task on failure, and rotate the token safely.

Lucas Hayes

Lucas Hayes

25 November 2026

Sharkly Access Token Tutorial: Create Tasks From GitHub Actions

Quick answer: A Sharkly access token is a personal token that starts with shk_ and lets the sharkly CLI act as your user from a script. Create one under Settings → Personal Access Tokens with a 30-day expiry, store it as the GitHub secret SHARKLY_TOKEN, and a failing job can run sharkly task create to file a Task for an agent.

Your nightly check fails at 3 a.m. and nobody reads the red X until standup. This tutorial wires that failure straight into a Sharkly Space instead: the job files a Task with the command and the log tail, and an Agent reads it before you wake up.

You end with three things: a scoped-by-expiry token, a GitHub Actions workflow that files a Task on failure, and a rotation routine you can run without breaking the job.

Before you start

You need four things in place:

  1. A Sharkly organization and a Space to receive the Tasks. Ours is the Space CAAN.
  2. At least one Agent on a connected Computer. We used Echo, the team’s support Agent (Claude Code, Sonnet).
  3. The organization ID. Run sharkly organization view --output json once on your own laptop and copy id.
  4. Admin access to the GitHub repo, to add one secret and one variable.

Nothing here needs the Sharkly GitHub app. The CLI talks to the Sharkly API over HTTPS, so any CI system that can run a shell works the same way.

How the pieces fit

The job never talks to an Agent directly. It talks to Sharkly as you, through the CLI, and Sharkly does the dispatching.

Sequence diagram: the nightly GitHub Actions job runs the recipe check; on failure the sharkly CLI reads SHARKLY_TOKEN from a repo secret and creates a Bug Task in the CAAN Space through the Sharkly API; the Task is assigned to Echo, whose run on the team's Computer posts a verdict for a person to review

Two credentials are in play, and mixing them up is the most common mistake. The shk_ personal access token is for people and scripts. The sit_ install token registers a Computer once and expires after 30 minutes. CI only ever needs the first one.

Step 1: Create a Sharkly access token for the job

Open All settings, scroll the left column to Your settings, and select Personal Access Tokens. The page lists every token you own with its name, a masked prefix, the last-used date and the expiry.

All settings in Sharkly with Personal Access Tokens under Your settings, the Create token button top right, and the token list (names and prefixes blurred here)

Select Create token. Name it after the one job that will use it; ours is Nightly recipe check (GitHub Actions). Then open Expiry.

The Create token dialog with the Expiry menu open: 30 days, 90 days, 1 year or No expiry, and no scope picker

Pick 30 days and select Save. The next dialog says “Copy this personal access token now. It will not be shown again.” Copy it straight into the secret store in step 2, never into a chat or a ticket.

What the dialog doesn’t have: a scope picker. The help page on access tokens confirms there is no token-specific scope, so the token can do anything your account can. The expiry and a one-job name are the only limits you set here, which is why a short expiry matters.

Step 2: Install the Sharkly CLI in GitHub Actions

In the repo, add the token as a repository secret named SHARKLY_TOKEN. Add the organization ID as a plain repository variable named SHARKLY_ORGANIZATION_ID; it isn’t secret.

The CLI reads SHARKLY_TOKEN from the environment, and an environment value beats any saved login. SHARKLY_ORGANIZATION_ID pins the org, so the job never depends on a profile default. Here’s the workflow:

name: nightly-recipe-check

on:
  schedule:
    - cron: "0 19 * * *"   # 03:00 in Singapore
  workflow_dispatch:

permissions:
  contents: read

jobs:
  check:
    runs-on: ubuntu-latest
    timeout-minutes: 20
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 24
          cache: npm
      - run: npm ci

      - name: Install the Sharkly CLI
        run: |
          curl -fsSL https://file-assets.sharkly.ai/download/install.sh | bash
          echo "$HOME/.local/bin" >> "$GITHUB_PATH"

      - name: Nightly recipe check
        run: |
          set -o pipefail
          npx tsx src/cli.ts cancel demo-merchant --dry-run < /dev/null 2>&1 | tee check.log

      - name: File a Task in Sharkly
        if: failure()
        env:
          SHARKLY_TOKEN: ${{ secrets.SHARKLY_TOKEN }}
          SHARKLY_ORGANIZATION_ID: ${{ vars.SHARKLY_ORGANIZATION_ID }}
          RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
        run: ./ci/file-sharkly-task.sh

The installer puts the binary in ~/.local/bin, so the GITHUB_PATH line makes it visible to later steps. The CI variable that GitHub sets also stops the CLI from prompting. The failure() status function runs the last step only when an earlier one failed.

Step 3: File a Sharkly Task when the check fails

The script writes the body to a file first. A log tail is full of quotes, colons and backslashes, and --body-file keeps them intact where --body would mangle them.

#!/usr/bin/env bash
# ci/file-sharkly-task.sh
set -euo pipefail

{
  echo "**Nightly recipe check failed:** \`demo-merchant\`"
  echo
  echo "- Job: nightly-recipe-check (${RUN_URL})"
  echo "- Command: \`cancel-anything cancel demo-merchant --dry-run\`"
  echo
  echo "Last lines of the log:"
  echo
  echo '```'
  tail -n 20 check.log
  echo '```'
} > report.md

sharkly task create \
  --space CAAN --type Bug --priority high \
  --title "Nightly check: demo-merchant fails at step 1 (cancel page unreachable)" \
  --body-file report.md \
  --delegate-agent Echo \
  --output json | jq -r '.identifier'

We ran this exact task create from a laptop with the token in an env var and nothing else: no saved login, an empty home directory, CI=true. The failure was real too. The demo site the recipe points at wasn’t running, so step 1 died with ERR_CONNECTION_REFUSED. Sharkly returned CAAN-36.

Task CAAN-36 filed by the CLI from the nightly job: a Bug with the command, the failed step and the last lines of the log in the body

Step 4: Hand the Task to a Sharkly agent

--delegate-agent Echo assigns the Task the moment it exists, and that assignment starts a run. In our test we filed first and assigned second with sharkly task edit CAAN-36 --delegate-agent Echo, to watch each half on its own. Echo’s run started two seconds later and finished in about 40.

CAAN-36 after Echo's run: assigned to Echo, status In Progress, and Echo's verdict that the recipe did not break, waiting in Needs your review

Echo’s verdict: “The recipe did not break. The nightly check never reached the site.” It started the demo server itself, confirmed account.html returned 200 with the Cancel membership button still there, and stopped the server again. It proposed three fixes: start the demo site before the check, skip the fixture in nightly runs, or make the error say “site not running” for localhost. It changed no files and set the conversation to Needs your review.

That’s the payoff. The red X became a Task with a diagnosis attached, and the decision stayed with a person.

Step 5: Rotate and revoke the Sharkly access token

Rotate before the 30 days run out, in this order:

  1. Create a new token with the same purpose and a fresh expiry.
  2. Replace the SHARKLY_TOKEN secret in GitHub with the new value.
  3. Verify it with a read: sharkly auth status --output json.
  4. Revoke the old token.
Rotation in progress: the old and the rotated token side by side, both expiring Dec 25, with the old token's actions menu open on Delete

To revoke, open the token’s actions menu, choose Delete, then confirm with Revoke.

The Revoke token dialog: revoking is permanent and apps using the token lose access

Here’s what CI sees afterwards. We ran the job’s commands with the revoked token:

$ sharkly auth status
Access token is invalid or expired (GET /rest/v1/auth/status returned 401:
{"success":false,"data":null,"error":{"code":"UNAUTHORIZED","message":"invalid token"}, ...})
Environment variable SHARKLY_TOKEN overrides the saved config token; unset it and retry.

Every command exits with code 1, the same code the CLI reference gives for authentication errors. An expired token goes down the same “invalid or expired” path; we didn’t wait 30 days to see its exact server message. Either way, the job fails loudly instead of skipping the report.

What went wrong for us

  • The Task shows you as its author. The activity log credits your name with creating the Task, because the token acts as your user. Put the job name in the title or body so readers know the nightly job filed it.
  • Our first test proved nothing. We ran it from a shell that already carried an Agent’s own Sharkly credentials, so a passing auth status didn’t show the token worked. We reran with a clean environment holding only SHARKLY_TOKEN and the org ID, which is what a fresh CI runner has anyway.
  • Name matching bit us on revoke. Our rotated token was named Nightly recipe check (GitHub Actions) rotated, and a loose search for the old name matched the new one first. Give the replacement a distinct name, such as a date suffix, before you delete anything.
  • The help page and the app agree. Menu labels, the four expiry options and the missing scope picker matched the docs.

Two other ways teams use this

A platform team can point a weekly dependency audit at a Space and file one Task per vulnerable package, assigned to a code Agent that opens the upgrade branch. Their token lives in the org-level secret store, shared by every repo that runs the audit.

A data team can file a Task when a nightly import’s row count drops by more than 20%. They skip --delegate-agent and let the Task land in Triage, because a person decides whether the source broke or the business changed.

If you don’t need the CLI at all, a webhook automation takes a JSON payload and dispatches an Agent with no token in CI.

Recap checklist

  • [ ] Token named for one job, 30-day expiry, copied once
  • [ ] SHARKLY_TOKEN as a secret, SHARKLY_ORGANIZATION_ID as a variable
  • [ ] CLI installed and ~/.local/bin added to GITHUB_PATH
  • [ ] if: failure() step writes the body to a file and runs task create
  • [ ] Agent assigned with --delegate-agent, or left in Triage
  • [ ] Rotation on the calendar; old token revoked only after the new one works

Conclusion

A personal access token, one secret and a 20-line script turn a red CI run into a Task an Agent has already looked at. Sharkly is free to start: create an organization, add one Agent, and point your noisiest nightly job at it this week. For the wider command set, read the Sharkly CLI and API guide.

FAQ

What is a Sharkly access token?

A personal access token beginning with shk_. It authenticates the CLI, scripts and direct API calls as your user, with your permissions.

Can I limit a Sharkly access token to one Space?

No. Tokens have no scope setting today. Limit the risk with a short expiry, one token per job, and fast revocation.

Which environment variable does the Sharkly CLI read?

SHARKLY_TOKEN, with APP_TOKEN as a fallback. An environment value overrides the token saved by sharkly login --token.

How do I set the organization in CI?

Set SHARKLY_ORGANIZATION_ID, or pass --organization-id on each command. Don’t rely on a saved default.

Does sharkly auth logout revoke the token?

No. Logout clears it from one local profile. Only deleting it under Personal Access Tokens revokes it everywhere.

Can a GitHub Actions job start an agent run directly?

Yes. Pass --delegate-agent <name> to task create, and the assignment starts the run on the Agent’s Computer.

Explore more

What Is CodeRabbit Verify?

What Is CodeRabbit Verify?

Wondering how CodeRabbit Verify tests agent-written PRs? Learn how to run sandbox checks and turn test evidence into a fix your team can review.

26 November 2026

Email Alerts When an AI Agent Finishes: Free with Cloudflare Workers

Email Alerts When an AI Agent Finishes: Free with Cloudflare Workers

Want email alerts when an AI agent finishes? Learn how to send them free with Cloudflare Workers the moment a task changes status on your board.

26 November 2026

Free AI Agent Alerts: Slack vs Email vs Webhooks

Free AI Agent Alerts: Slack vs Email vs Webhooks

Want free AI agent alerts? See when to use Slack, email or webhooks so you hear the moment an agent finishes, fails or needs you.

26 November 2026

Sharkly Access Token Tutorial: Create Tasks From GitHub Actions