עברית 📰 Blog
← Back to Blog
AI Automation

How to Make Claude Code Finish Long Tasks: 5 Files and a Finish Line

Claudia
Masterphub AI
November 1, 2026

Share this article

How to Make Claude Code Finish Long Tasks: 5 Files and a Finish Line
Short answer: Long Claude Code runs fall apart for boring reasons: the agent forgets what was decided, checks its own work, or stops without a clear end. Five small files fix most of it: a project memory file, a skill for the repeated procedure, a reviewer subagent, permission rules, and a progress note. Then you give the run a goal it has to prove.

Why long tasks break

A ten minute task usually works. A two hour task drifts. By the third hour the agent has forgotten a decision from the first, marks its own draft as "verified", or stops halfway and tells you it is done.

The model is not the problem. The setup around it is. Anthropic calls that setup a harness: the instructions, tools, permissions, saved state and checks that sit around the model.

Below is a setup you can build in about 20 minutes. Our example is a content job: research a topic, write an article, check every fact. The same structure works for code.

Step 1: A project memory file (CLAUDE.md)

Claude Code reads CLAUDE.md from the project root at the start of every session. Put only things that stay true across tasks: where files go, writing rules, what counts as a source.

Project rules
Reference material lives in sources/. Work in progress goes in drafts/.
Finished, approved files live in published/.
Short paragraphs. One idea per paragraph.
Every factual claim needs an official source URL and the date you checked it.
After each stage, update progress.md: what is done, what was decided, what comes next.
When you finish, list the output files and the check results.

Keep deadlines and one-off questions out of this file. They belong to the task, and next week they will only confuse the agent.

Step 2: Turn the repeated procedure into a skill

If you do the same job every week, write the steps once. A skill lives in .claude/skills/<name>/SKILL.md. You run it with a slash command, and whatever you type after the name lands in $ARGUMENTS.

---
name: research-article
description: Research a topic from sources/ and write a fact-checked article draft.
---
Topic: $ARGUMENTS

  1. Read the relevant files in sources/ and open the official links they cite.
  2. Write an outline, then save the draft to drafts/article.md.
  3. Send the draft to the fact-checker subagent.
  4. Fix what it marks as wrong. Leave unresolved claims clearly marked.
  5. Save the fact-check table to drafts/factcheck.md.
  6. Update progress.md.
  7. Reply with both file paths and a one-line summary of the check.

Notice that every step leaves something you can open. "Check accuracy" is not a step. "Save the fact-check table to drafts/factcheck.md" is.

Now /research-article AI voice cloning laws runs the whole procedure on a new topic.

Step 3: A reviewer that is not the writer

An agent checking its own draft tends to agree with itself. A subagent gets its own context and its own tool list. Give it read and search tools only, so it reports problems and the main agent fixes them.

Save this as .claude/agents/fact-checker.md:

---
name: fact-checker
description: Checks factual claims in a draft against primary sources.
tools: Read, Grep, Glob, WebSearch, WebFetch
effort: high
---
Read the draft you are given and the material in sources/.
Check every factual claim against a source you actually opened.
Return a table: claim | verdict | source URL | fix needed.
Verdicts: verified, wrong, unresolved.
For unresolved claims, say exactly what evidence is missing.

The effort: high line gives the checker more thinking time than the writer. That is where it pays off.

Step 4: Permission rules, not promises

"Please don't touch the published folder" in a prompt is a request. A rule in .claude/settings.json is enforced by Claude Code before the tool runs.

{
  "permissions": {
    "deny": [
      "Read(.env)",
      "Read(.env.*)",
      "Edit(published/**)"
    ]
  }
}

Test it once: ask Claude to edit a dummy file inside published/. It should be refused. Run /permissions to see the rules that are actually loaded.

One honest limit: these rules cover Claude's own file tools. A script Claude runs can still touch files through its own code. If that matters, use operating system sandboxing as well.

Step 5: A progress note the next session can read

Long runs get compacted, and sessions end. A short progress.md is what lets tomorrow's session pick up instead of starting over.

Task: [topic]
Files: [draft and fact-check paths]
Done: [finished stages]
Decisions: [what was decided and why]
Open: [missing evidence, blockers]
Next: [one concrete next step]

Test it: open a fresh session and type "Read progress.md and continue from Next." If it starts from scratch, the note is missing something.

Step 6: Give the run a finish line

The /goal command (Claude Code 2.1.139 and later) keeps Claude working across turns until a condition is met. After each turn, a separate small model checks the condition. It only sees what is in the conversation, so the condition has to be something the run can show.

/goal Use research-article on the brief in sources/task.md. Done when drafts/article.md and drafts/factcheck.md exist, every claim marked wrong has been fixed, unresolved claims are clearly marked, and both file paths plus the check summary appear in the chat. If this is not met after 12 turns, stop and report what is blocking.

Type /goal clear to cancel it early.

You can also start the session with a set thinking level: claude --effort medium. Keep the main session at medium and let the fact-checker run at high.

Before you hit enter

  • /context: is CLAUDE.md loaded?
  • /agents: is fact-checker listed?
  • /permissions: is published/ protected?
  • /mcp: if you pull sources from Notion or Drive, is the connection authenticated?

Fix anything missing before the long run, not halfway through it.

When it is done, check the files, not the chat

The chat says what the agent believes happened. The files say what actually happened. Open the draft, open the fact-check table, and spot check three claims against their sources.

If something went wrong, /rewind can restore file edits Claude made. Changes made by shell commands are not covered, so keep the project in git.

Is it worth the setup?

For a one-off task, probably not. For a job you repeat every week, yes. The second run reuses the skill, the reviewer and the rules. You only bring a new topic and new sources. And every time the review catches the same kind of mistake, add one line to the skill so it stops happening.

Measure it on real work: how long you spent reviewing, how many fixes the result needed, and what /usage shows. That tells you more than any promise about token savings.

Sources

Share this article