finish-and-close

finish-and-close is a command for coding agents from JPM1118/Threadwork. It costs 0 tokens per session (1,668 once invoked), scanned A, original, MIT.

A command that finishes a software task by merging its code or opening a pull request, then cleaning up the work.

In plain words
What is it for?
Use it to complete a Beads project epic, either by merging its feature branch into the base branch or by creating a pull request.
Why use it?
It removes the manual steps needed to land completed work after checks have passed. It also helps prevent unfinished tasks or uncommitted changes from being closed accidentally.

Command

Part of the threadwork plugin — 20 skills, 4 commands, 1 agent, 1 hook shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/jpm1118/threadwork/finish-and-close
Clone the repo
git clone --depth 1 https://github.com/JPM1118/Threadwork

Or install threadwork, the plugin that ships this one along with the rest of its 20 skills, 4 commands, 1 agent, 1 hook.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for finish-and-close

README.md
[![agentmods](https://agentmods.dev/badge/commands/jpm1118/threadwork/finish-and-close.svg)](https://agentmods.dev/commands/jpm1118/threadwork/finish-and-close)
Your own site
<a href="https://agentmods.dev/commands/jpm1118/threadwork/finish-and-close"><img src="https://agentmods.dev/badge/commands/jpm1118/threadwork/finish-and-close.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,668 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01668
Opus 5 $0.00000 $0.00834
Sonnet 5 $0.00000 $0.00334
Haiku 4.5 $0.00000 $0.00167

Measured 3d ago against content hash 87fe18a2612c, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

finish-and-close scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/finish-and-close.md · 291 lines

How it starts

The opening of the file, as written. The whole thing — 291 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/finish-and-close - Complete Feature and Close Epic

Execute the landing strategy determined by the finishing skill. This command handles the actual merge/PR creation and cleanup.

Usage

/finish-and-close --epic {epic-id} --strategy {merge|pr}

Parameters

Parameter Required Description
--epic Yes The Beads epic ID (e.g., bd-a3f)
--strategy Yes Landing strategy: merge or pr

Prerequisites

This command should only be invoked by the finishing skill after verification:

  • All tasks closed
  • Tests passing
  • Landing strategy determined

Execution Steps

Strategy: Merge

When --strategy merge:

Step 1: Ensure Clean State
# Check for uncommitted changes
git status --porcelain

# If changes exist, abort
# User should commit or stash first
Step 2: Update Base Branch
# Read config for base branch
base_branch=$(grep base_branch .threadwork.yaml | cut -d: -f2 | tr -d ' ')

# Fetch and update
git fetch origin
git checkout $base_branch
git pull origin $base_branch
Step 3: Merge Feature Branch
# Get current feature branch name
feature_branch=$(git rev-parse --abbrev-ref HEAD)

# Checkout base and merge
git checkout $base_branch
git merge --no-ff $feature_branch -m "Merge {feature_branch}: {epic title}

Closes epic {epic-id}

Tasks completed:
- {task-1-id}: {task-1-title}
- {task-2-id}: {task-2-title}
...
"
Step 4: Push to Remote
git push origin $base_branch
Step 5: Close Epic in Beads
bd --no-daemon close {epic-id} --reason "Merged to {base_branch}. {N} tasks completed."
Step 6: Cleanup
# Get worktree path
worktree_path=$(git worktree list | grep {feature_branch} | awk '{print $1}')

# Remove worktree (if exists and not current directory)
if [ -n "$worktree_path" ] && [ "$worktree_path" != "$(pwd)" ]; then
    git worktree remove "$worktree_path"
fi

# Delete feature branch
git branch -d {feature_branch}

Read the full file on GitHub · 291 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 291 lines · 0 tokens per session scan A 87fe18a2612c

Subscribe to this mod's changes

finish-and-close is a command published in the GitHub repository JPM1118/Threadwork (5 stars, last pushed 8mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,668 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.