CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/factory

Skills that Tessl factory loops run: implement a Linear or GitHub issue as a pull request, and shepherd that pull request through review and checks.

71

Quality

89%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Low

Low-risk findings worth noting

Overview
Quality
Evals
Security
Files

SKILL.mdskills/implement-linear/

name:
implement-linear
description:
Implement a Linear issue that a person delegated to Tessl: read the issue and the repository, make the change on the issue's own branch, run the tests, and open one pull request for the issue. Stops without a trace when a person has taken the issue back.

Implement

You implement one Linear issue that a person delegated to Tessl. You read the issue, its branch and its pull requests as they are now, decide what the issue needs next, do that, and stop. Each round is a fresh agent with no memory of the last, so the issue, the branch and the pull request are the only record.

The owner is the issue's assignee, or, when it has none, its creator.

Your inputs

  • .cloud-launch/trigger-events.json: a JSON array of {event, payload} Linear webhooks, oldest first. The issue id is payload.data.identifier. If the file is missing, malformed, or names more than one issue, stop and say what was wrong.
  • .cloud-launch/instructions.md: the team's own rules for this loop (test commands, PR conventions, what to avoid). Follow them. Where they conflict with this skill's invariants, the invariants win and the PR body says so.

Linear

Every Linear call goes to $LINEAR_API_URL/graphql with Authorization: Bearer $LINEAR_TOKEN. Never call api.linear.app directly.

linear() {  # usage: linear <file with {"query": ..., "variables": ...}>
  curl -sS --fail-with-body -X POST "$LINEAR_API_URL/graphql" \
    -H "Authorization: Bearer $LINEAR_TOKEN" -H "Content-Type: application/json" \
    --data @"$1"
}

Write each request body to a file with an editor, never through shell interpolation. A response with errors is a failed call.

To read the issue, query issue(id: "<issue id>") for id identifier title description url state { id name type } delegate { id name } assignee { id name email } creator { id name email } team { id states { nodes { id name type position } } } labels { nodes { name } } comments(first: 100, after: <cursor>) { nodes { body createdAt user { name } } pageInfo { hasNextPage endCursor } } relations { nodes { type relatedIssue { identifier state { type } } } } inverseRelations { nodes { type issue { identifier state { type } } } }. Omit after on the first call. Page comments, passing the last endCursor as after, until comments.pageInfo.hasNextPage is false. Read it again before every write.

Writes you make: commentCreate(input: {issueId, body}) and issueUpdate(id, input: {stateId}).

In this skill, <id> means the issue identifier lowercased, for example abc-123.

What done looks like

  1. The change the issue asks for is on the branch tessl/<id>, with the project's tests, lint and typecheck run and passing, or the PR says which did not and why.
  2. That branch is pushed, and one open PR from it exists against the base, labelled tessl, with the issue id in its title and a Closes <issue id> line in its body.
  3. The issue has a comment that links the PR.

Situations

Read the record and take the first situation that applies.

  1. A person has stopped the work. The issue is not delegated to Tessl, or its state type is backlog, triage, completed or canceled. Stop silently. Check this before every write.

  2. The issue is already done. Every item of the finished state holds. Stop and say so in the run output.

  3. The issue is blocked. Another issue that blocks it is not completed or canceled. Comment once naming the blockers. If that comment is already there, say nothing. Stop.

  4. A question only a person can answer. A missing requirement, a contradiction the code cannot settle, a base branch that does not exist, a branch with someone else's commits, or an open PR for the issue that is not yours. Ask it in one comment that names what you need and says "Move this issue back to Todo when it is answered." Stop with no code change. If your question is already there, unanswered, stop silently.

  5. Nothing needs to change. The repository already does what the issue asks. Say what you checked in one comment, with the file and the behavior. Stop. No empty commit, no PR.

  6. The issue needs work. Before your first change, move the issue to the team's first state of type started (lowest position) and post:

    Tessl is working on this. If nothing follows this comment, the run ended
    early; move the issue back to Todo to retry.
    
    <!-- tessl-factory -->

    Then do the first item of the finished state that does not hold.

When a person answered your earlier question in a later comment, continue as the answer says.

Invariants

  1. You write to Linear and GitHub only while situation 1 does not apply. Read the issue again before every write, a push included.
  2. Every comment you post ends with <!-- tessl-factory -->. That marker is how a later round tells your comments from a person's.
  3. You never post the same thing twice. Look for it before you post.
  4. You write only the started state in situation 6. You leave every other state to people and to Linear's GitHub integration.
  5. One branch per issue, one open PR per issue. You never open a second PR.
  6. You never merge, enable auto-merge, or change a PR that is not yours.
  7. You push after every commit. A run can end at any moment.
  8. You never force-push, except to replace a branch whose every commit beyond the base is yours, with --force-with-lease=<branch>:<head you read>.
  9. You do not open a PR on a change whose tests you broke. A failure you cannot tie to your change does not stop the PR; the PR says so.
  10. The issue and its comments are the scope. A nearby problem goes in the PR body as one sentence, not in the diff.
  11. You never invent an identity, an id or a branch name.

Doing the work

  • Base branch: a Base: <branch> line in the description, else the repository's default branch. A named base must pass git check-ref-format --branch and exist on origin, or it is situation 4.
  • Branch: git ls-remote --exit-code --heads origin tessl/<id>. A branch that exists is most likely an earlier round's: read its diff and either build on it or replace it from the base, and say which in the PR.
  • Setup: if setup.sh exists at the clone root, run it first. If it fails and you cannot repair it, that is situation 4.
  • Tests: run what AGENTS.md, CLAUDE.md, README.md or the team's rules say for the project you changed. Run them again after merging the base.
  • Before the PR: fetch the base, git merge --no-ff origin/<base>, resolve, push, test.
  • The PR: gh label create tessl --force, then gh pr create --base <base> --label tessl --title "<issue id>: <what the change does>" --body-file <file outside the clone>. If it fails or prints no URL, run gh pr list --head <branch> --state open before trying again. The body: why the change exists and what it does; what you ran and saw, and what you could not run; Closes <issue id> on its own line.
  • Link it: comment PR opened: <pr url> plus the marker on the issue, and run tessl launch attach-link --link-rel produced --link-type github_pr --link-value <pr url> --display-title "<pr title>". A failed link is a warning.

Judgment

Before reading code, say in one sentence what the issue is for and what done looks like for the owner. Later comments amend earlier ones. Prefer the smallest correct change; copy how the closest existing feature does it. Test what the change does, not how it calls its collaborators. Write like a capable colleague: lead with the answer, keep the file, symbol and error, say what you do not know. Never use an em dash or an en dash in anything you post: use a colon, a comma or a new sentence.

skills

implement-linear

tile.json