Run End-to-End Tests from Your Terminal with Kane CLI

Author and Run Tests Right from the Terminal in Natural Language, with an Evidence-Backed Pass or Fail from a Real Browser.

npm install -g @testmuai/kane-cli

Claude Code Best Practices: From Prompt to Merged PR

Claude Code best practices: plan, prompt, CLAUDE.md, checks and evidence, then the PR stages from verify skill to merge gate, and where Kane CLI fits.

Published

Summarise with AI

Claude Code best practices that actually matter most are to have a check that you can run and let the result of that check decide whether to merge. Write a particular prompt or a spec.

Keep CLAUDE.md to the commands that confirm it works. Ask for evidence rather than "all tests pass". Enforce your must-hold rules with hooks, deny rules, CI and branch protection.

Key facts (checked 28 Nov 2026):

  • Anthropic's Best Practices guide says to give Claude a check that comes back as pass or fail.
  • Claude's Code Review just reads the diff and the surrounding code. It doesn't build or run your app at all.
  • Claude Ship has three agents: Code Review (GA), PR Steward (beta) and Claude Approvals (beta).
  • Claude's approvals count as real approvals on GitHub.

TL;DR

The most important Claude Code best practices, from Anthropic's own guide, are to tell Claude what it can't see, give it a check that comes back pass or fail, and enforce the rules that can't bend with hooks, deny rules, CI and branch protection. That check's result, not Claude's summary of its work, decides the merge.

What should be in CLAUDE.md and what should be in REVIEW.md?

  • CLAUDE.md best practices: Keep the file to what Claude can't learn from the code: the unit, typecheck and end-to-end commands, conventions and gotchas. Anthropic calls the command that runs your check the single most useful line in the file.
  • REVIEW.md: Review-only rules for Anthropic's Code Review service, read from the base or default branch and never from the pull request itself. Local /code-review ignores REVIEW.md, so rules both reviewers need belong in CLAUDE.md.
  • Verify skill: A .claude/skills/verify/SKILL.md file tells Claude how to start the app, which check to run on the changed flow, and to report the command, exit code and evidence path before it claims success.

Gating an AI-Written Pull Request

  • Claude Code GitHub Actions: The anthropics/claude-code-action workflow runs Claude in your repository to answer @claude mentions and push fixes. It writes and fixes code; a separate end-to-end job proves the result works.
  • Kane CLI by TestMu AI: Runs committed _test.md acceptance tests and seals an evidence pack per run. Real browser: Yes. Exit code: 0 for a pass, 1 for a failed step. LLM cost on an unchanged, cached step: None, so the check stays fast enough to require on every pull request.
  • Merge gate: Make the Kane CLI end-to-end job a required status check with no path filter, because GitHub counts a skipped required check as passing. Claude's approvals count as real GitHub approvals, so require a person who isn't a PR author for tests and rule files.

What Are the Fundamental Claude Code Best Practices?

The core Claude Code best practices are three in number and all taken from Anthropic's guide: tell Claude what it can't see, give it a check to run and enforce the rules that can't have any exceptions. The ten habits below are all examples of those three principles in action. The table also indicates who is responsible for enforcing each habit and where a runtime check would be applicable.

PracticeWhat to doWho enforces itRuntime check
Write a specific promptName the file, describe the symptom, say what "fixed" looks likeModelThe "fixed" definition becomes a test file
Brainstorm before buildingAsk Claude to interview you and write SPEC.md, then build in a fresh sessionModelSPEC.md holds the acceptance criteria
Keep CLAUDE.md shortOnly what Claude can't learn from the code: commands, conventions, gotchasModel (a guideline)List the command that runs your end-to-end check
Give Claude a check to runA test file, a build's exit code, a linter, a screenshotModel or harnessA Kane CLI run returns exit code 0 or 1
Ask for evidenceThe command Claude ran and its output, or the screenshotModelKane CLI seals an .evidence pack per run
Enforce checks with hooksA Stop hook that blocks the turn until typecheck passesClaude Code harnessKeep slower browser runs in a skill and in CI
Limit access with deny rules and the sandboxDeny reads of .env and secrets; turn on /sandboxClaude Code harnessNot applicable
Use subagents for fresh eyes and long outputA read-only reviewer subagent with tools: Read, Grep, GlobModel; tool limits by the harnessA reviewer reads code but doesn't run the app
Reset instead of re-correcting/clear between unrelated tasks and after two failed correctionsYouNot applicable
Run parallel work in worktreesclaude -w feature-auth; list the gitignored files you need in .worktreeincludeYouA fresh worktree lacks .env, so copy it in before tests run

Each row maps to a section of Anthropic's best practices guide. Our Claude Code explainer goes into more depth on sessions, skills, hooks and sub-agents.

Most 'best practice' lists stop at the commit. The rest of this page is a walkthrough of Claude's work from the spec through to a merged PR, stage by stage and shows where TestMu AI fits in.

For a quick visual walkthrough of this concept, watch the video below from TestMu AI.

Youtube thumbnail

Subscribe to the TestMu AI YouTube channel for more tutorials on testing and automation.

Why Does Claude Code Need a Check It Didn't Write?

Claude Code needs an external check, as a model's summary of its own work is not in itself evidence. Anthropic's guide divides the instructions into two categories.

The model reads the prompt (either a CLAUDE.md or a skill) and then decides what to do. Other rules are enforced outside of the model (Claude Code enforces the hooks and deny rules; your CI and GitHub enforce the tests and branch protection).

Code review is on the model side. The Claude Code review docs state that a review is performed on the diff and the surrounding code "without building or running your code," and on its own it will never approve or block a PR. Our post on why Claude's code review still requires a test gate provides a direct comparison of the two.

Kane CLI's agent works out the path on the first run. Subsequent runs just replay the saved steps from cache (no LLM involved) and pass only if all the acceptance criteria are met.

Kane CLI is the terminal testing agent for coding agents. It runs a user flow in a real browser, returns an exit code that a pipeline can gate on and produces an evidence pack for every run.

What Happens at Each Stage of an AI-Written Pull Request?

An AI-written PR goes through 8 stages from spec to release. Stages 1 and 2 occur prior to anyone opening the PR, and the majority of failures originate in those two stages.

StageWhat goes wrongControlWhere TestMu AI fitsStays with you
1. Spec"Done" is undefinedCriteria in a committed test file a person signs offKane CLI *_test.md; KaneAI from Jira ticketsProduct decisions
2. Agent loop"All tests pass" with no outputVerify skill reports command, exit code, evidenceKane CLI agent mode and skillUnit tests, typecheck, lint
3. CICI skips the agent's commits; flaky runsSame test files, headless, evidence keptKane CLI GitHub Action; HyperExecuteBuild and static analysis
4. ReviewChecks edited to passREVIEW.md flags edits to check sentencesEvidence link in the PR commentCode Review; design review
5. Watch and fixRetry loops; tests "fixed"Steward rules per exit code; escalate after three pushesExit codes and Result.mdMerge conflicts, comment replies
6. Merge gateAuto-merge without runtime proofRequired check, enforced approvalsKane CLI job as required checkApprovals policy, CODEOWNERS
7. ReleaseBrowser, device, layout, a11y regressionsFull suite across browsers and devicesHyperExecute, Real Device Cloud, SmartUI, Accessibility TestingProduction monitoring
8. AI featuresAgent answers driftConversation tests before releaseAgent Testing; Agent Assurance (Rook)Model evals
Note

Note: Try it on your next change. Install the Kane CLI via npm install -g @testmuai/kane-cli and then add the skill to Claude Code via npx @testmuai/kane-cli-skill. Kane CLI is free to install. It runs on your KaneAI credits. New accounts come with 10,000 credits valid for 30 days (as of 28 Nov 2026). Get started with Kane CLI.

How Do You Write Acceptance Criteria? Claude Code Can't.

Acceptance criteria: Claude Code can't re-interpret live outside of the prompt in a committed file that a person signs off. The model will assess the prompt. A test file is the contract against which the run is judged.

Kane CLI test files are plain Markdown, and each ## heading is a step. The Kane CLI docs state that you should end every flow by performing a check of what is on screen. By convention, you start that sentence with 'Verify' or 'Assert' so that reviewers and the REVIEW.md rules can find it:

---
mode: testing
url: http://localhost:3000
tags: [smoke, checkout]
---

# Checkout applies a discount code

## Add an item
Go to the products page and add the "Basic Tee" to your cart.
Check that the cart icon has a count of 1.

## Apply the code
Just open the cart, enter SAVE10 in the discount field and apply it.
Assert the order total is 10% less than the subtotal.

The best practices for CLAUDE.md start with the command that runs your check. That's what Anthropic's guide calls the single most useful line in the file. A very short CLAUDE.md in the guide's Commands and Gotchas section:

# Commands
- Unit tests: npm test
- Typecheck: npm run typecheck
- End-to-end: kane-cli testmd run tests/e2e/<name>_test.md --agent --headless --timeout 300

# Gotchas
- All the files in tests/e2e/ are acceptance criteria. Don't edit any Verify or Assert statements without asking first.

CLAUDE.md has a limit: Claude may decide that a particular rule doesn't apply. Anthropic states that rules which must apply every time should go in a hook, a permission deny rule or a managed setting. For acceptance criteria, the hard stop is a required check and an approvals rule at the merge gate.

When the product manager owns the criteria, then KaneAI will take a Jira ticket, a PRD or a PDF and turn it into structured test cases without any code.

How Do You Get Claude Code to Verify Its Own Work Prior to Committing?

Claude Code verifies its work prior to committing via a verify skill, which runs a real check and reports what it saw. The Anthropic shipping guide has this file at .claude/skills/verify/SKILL.md, and the example in that guide finishes by telling Claude not to report success unless it has actually run the steps.

A verify skill that calls Kane CLI on the test files covering the changed flow:

---
name: verify
description: Launch the app and verify that the new user flow works in a real browser. Only then commit.
---

1. Start the stack with npm run dev:stack. Wait for /healthz on port 3000 to return 200.
2. Find the files in tests/e2e/ that cover the changed flow. If none exists, draft one
   and ask me to approve its Verify and Assert sentences prior to running it.
3. Run each file: kane-cli testmd run <file> --agent --headless --timeout 300
4. Read the exit code:
   0 = passed.
   1 = a step failed, or the upload failed. If Result.md shows every step passed,
       treat it as an upload failure and re-run it once.
   2 = the run never started (sign-in, config or Chrome issue). Report it.
   3 = timed out or canceled.
5. On a failure, open output-<name>/Result.md next to the test file, and the .evidence
   pack in .testmuai/evidence/. Fix the app code. Don't change Verify or Assert sentences.
6. Report the command, the exit code and the evidence pack path.
   Don't report success without them.

Change the start command, port and paths to match your repo. The Kane CLI is using the --agent flag to stream NDJSON that Claude can parse, and the exit codes are as per the Kane CLI CI/CD docs. For the install and agent mode walk-through, see the Kane CLI in Claude Code.

A stop hook is ideal for cheap checks. Anthropic's example has pnpm tsc --noEmit running every time Claude attempts to end a turn and then sends Claude back to work on exit code 2. A browser run is slower, so it goes in the verify skill and in CI.

Anthropic's guide also makes the point that "people ignore verification they don't trust". Kane CLI simply replays the unchanged steps of a saved test from cache with no agent at all and no LLM cost. The repeat runs are very fast, and they always take the same path, so the team is happy to keep trusting the verify skill.

How Do Claude Code's GitHub Actions and the Kane CLI Check Work Together?

Claude Code, the GitHub Actions and the Kane CLI check are two separate jobs. The anthropics/claude-code-action is the one that runs Claude in your workflows (it answers @claude mentions, makes the changes and pushes the commits). The Kane CLI GitHub Action is the one that takes your committed test files and runs them against the app to report pass/fail.

You use the first to write and fix code and the second to prove that the result actually works.

The Kane CLI Action runs the *_test.md files headless and in parallel. It uploads the evidence pack as a build artifact (retained for 30 days) and posts the verdict as a PR comment.

# .github/workflows/kane-e2e.yml
name: kane-e2e
on: [pull_request]
permissions:
  contents: read
  pull-requests: write   # lets the action post the verdict comment
jobs:
  kane-e2e:
    runs-on: ubuntu-latest
    timeout-minutes: 30
    steps:
      - uses: actions/checkout@v4
      # Build and run your app here, or point the test files at a preview URL.
      # Pinned to a published Kane CLI release (the docs example uses @main)
      - uses: LambdaTest/kane-cli/integrations/github-action/kane-cli-browser-run@0.10.11
        with:
          test-files: "tests/e2e/**/*_test.md"
          parallel: "4"
          extra-args: "--tags smoke"
          username: ${{ secrets.LT_USERNAME }}
          access-key: ${{ secrets.LT_ACCESS_KEY }}

Agent-written PRs hit three CI gotchas:

  • GitHub doesn't run workflows on commits pushed with the default GITHUB_TOKEN. If claude-code-action is given that token, then kane-e2e won't run on Claude's fixes. The Anthropic docs say to have it authenticate as the Claude GitHub App instead.
  • PRs from forks get a read-only token, so the Kane CLI Action just skips the comment on them.
  • Don't ever call kane-cli login in a CI environment, as it will open a browser. Pass the credentials in via secrets.

Keep the PR gate to a smoke subset that finishes in the time that the reviewers will wait. Our guide to E2E tests in pull requests shows you how to set that limit from your own merge rate.

Kane CLI - Testing Agent in Your Terminal

What Should REVIEW.md Tell Claude's Code Reviewer to Look Out For?

REVIEW.md is what Claude's Code Review uses to work out what's Important in your repo and which test edits require a human. Code Review reads REVIEW.md from the base (or default) branch, not from the PR branch itself. A PR can't therefore go and rewrite its own review rules.

Local /code-review makes no use of REVIEW.md whatsoever.

The reviewer reads code and can't see whether kane-e2e passed. Aim REVIEW.md at signals visible in the diff:

# Review instructions

## What Important means here
Wrong results, leaked data or anything else that would prevent a rollback.
A changed route, form or checkout step with no corresponding test file in tests/e2e/ to cover it.

## Always check
- Any edit to a Verify or Assert sentence in tests/e2e/*_test.md. Name the file and line,
  and say whether the app change accounts for it.
- New API routes have an integration test.

## Keep it quiet
- Report at most five Nits.
- Skip the generated files and lockfiles.

Code Review only recognizes lowered severities, path exclusions and nit caps from a protected default branch (as per the Anthropic Code Review customization docs). The Anthropic shipping guide has a team rule that's well worth adopting: a pattern has to appear on at least two PRs before it becomes a rule, and a person approves the PR that adds it.

How Should Claude Code Deal With a Failing CI Check?

Claude Code should be reading the evidence before it goes and changes any code, and it should be escalating when the same check keeps failing. The /ship and /steward watches and the team PR Steward service all read the house rules from .claude/skills/steward/SKILL.md. Anthropic's guide states that the watch will push at most three times for a given issue and then report what it has tried.

Steward rules that map Kane CLI exit codes to actions:

---
name: steward
description: House rules for looking after PRs in this repository
user-invocable: false
disable-model-invocation: true
---

- kane-e2e is the merge gate. Before changing code, read output-<name>/Result.md and the
  step screenshots in the .evidence pack.
- Exit code 1 with a failed step is a product bug. Fix the app code based on the evidence. Never fix the test to make it pass.
- Exit code 1 with every step having passed in Result.md is an upload failure. Re-run once.
- Exit code 2 means the run never actually started (sign-in, config or Chrome).
  Report it to the author. Don't change the app code for it.
- Exit code 3 is a timeout. Re-run once. If it times out again, then report it and stop.
- Never edit Verify or Assert statements in tests/e2e/. If a criterion looks wrong, ask the author.

The evidence pack contains exactly what the agent needs to fix the right thing. A Kane CLI .evidence file is a zip file containing per-step screenshots, console and network logs for each step, CLI logs and failure records with page state. Anthropic's guide cautions that anyone who can merge can edit the steward file, so you'd treat changes to that file in the same way as you would changes to CI.

How Do You Stop an Agent-Written PR From Merging Without Proof?

An agent-written PR can merge without proof in the case of a gate that is based on approvals and auto-merge rather than a required runtime check. Anthropic's guide states that their /ship watch will watch a PR for up to 7 days and is explicitly told not to merge it. The guide also mentions that with auto-merge in place, a fix that the watch pushes can be the very thing that allows GitHub to merge.

Four GitHub and approvals settings close the auto-merge gap:

  • Make kane-e2e a required status check (with GitHub Actions as the expected source). This is absolutely essential if you're using auto-merge. GitHub's protected branch rules will prevent the merge until the required checks have passed, and a status from any other source won't count.
  • Never filter the required job by path. GitHub will count a skipped required check as a pass, so a paths: filter on kane-e2e will open the gate silently. Our guide to quality gates for AI PRs covers that "skipped check" trap.
  • Require approval of the most recent push from someone other than the pusher and have the Claude GitHub App off the bypass list. Claude's approvals count as real approvals, so a one-approval ruleset could be satisfied by Claude alone.
  • Move the approvals policy from observe to enforce. In observe mode, it only reports what it would have approved. Compare its decisions against your reviewers, then switch mode from observe to enforce. Comment @claude approvals rerun on any open PRs to clear out the stale results and make the Claude Approvals check required via the Claude app as its source.

A rule that keeps an agent from approving changes to tests, its own review rules and skills:

# .claude/approvals.yml (on the default branch)
version: 1
mode: observe            # remove after comparing decisions with your reviewers
rules:
  - purpose: "A change to tests, review rules, or agent skills takes a person who isn't an author."
    paths: ["tests/e2e/**", "**/REVIEW.md", "**/.claude/**"]
    nested: inherit
    verdict:
      claude: comments
      seats: [{ count: 1, from: [humans, "!pr/authors"] }]

The syntax is according to Anthropic's guide; keep your existing rules in the same file. Our Claude Code Review test-gate post goes through the full policy, the QA-owner rule for tests/e2e/ and the GitHub settings.

What Should Run After Merge and Prior to Release?

After the merge, replay the full regression suite across the browsers, devices and screen states that the PR gate skipped. The PR gate is still a fast smoke subset, and breadth is at the release gate.

Kane CLI runs committed tests remotely and in parallel with the remote-execution plugin:

kane-cli plugin install remote-execution
kane-cli testrun run --match '^tests/web/' --remote --parallel 4 \
  --username "$LT_USERNAME" --access-key "$LT_ACCESS_KEY"

Remote runs require a plan with HyperExecute macOS runners.

For existing Selenium, Playwright and Cypress suites, HyperExecute's AI test orchestration will run the tests in parallel across machines, will stop on repeated failures and will re-run only the failed tests. TestMu AI has reported that suites can run up to 70% faster than a traditional grid (vendor figure as of 28 Nov 2026). Measure it for yourself.

Other TestMu AI release checks cover real devices (Real Device Cloud), visual baselines (SmartUI) and WCAG 2.2 scans (Accessibility Testing), and Kane CLI uploads to Test Manager by default.

If your product ships a chatbot or voice agent, then a browser check will just prove that the widget loads; it won't prove that the answers are correct. TestMu AI Agent Testing will simulate users in chat, voice and phone conversations and score each run. Agent Assurance (built on the Rook CLI) will grade what the agent did against the recorded evidence.

Neither of those replace your model evals.

What Does a Kane CLI Pass Actually Prove?

A Kane CLI pass proves your acceptance criteria were correct in a real run. Kane CLI's product page says "a pass means every acceptance criterion for that scenario is satisfied".

Healing works on the path only. Step-heal will re-find an element that has moved, and flow-heal will re-reason the route only when a step can't be healed. Neither of those actions alters the acceptance criteria in any way, and a wrong total will be reported as a bug.

Every run creates an evidence pack which opens up in the evidence viewer at evidence.lambdatest.com (with the step screenshots and logs). The evidence-cli format page says "No upload. No account. Opens offline."

A check only proves what it says. If a button maintains its label but now routes to a different place, a step that only clicks it doesn't check where it lands. For routes that actually matter, you need to add an explicit Verify statement on the destination page.

Kane CLI evidence pack for a failed checkout step, open in the evidence viewer with the step screenshot and network log

Demo shop repo, 28 Nov 2026: the SAVE10 code took $0.25 off a $25.00 subtotal, leaving an order total of $24.75 instead of $22.50.

$ kane-cli testmd run tests/e2e/checkout_test.md --agent --headless --timeout 300
{"type":"test_md_summary","overall_status":"failed","duration_s":110,"steps":{"total":2,"passed":1,"failed":1}}
$ echo $?
1

$ cat tests/e2e/output-checkout/Result.md
## Add an item ✓ passed (33.6s)
## Apply the code ✗ failed (62s)
Reason: Final verification failed: "the order total is 10% less than the subtotal" - bug verdict: SAVE10 applies a 1% discount instead of 10% [application_issue/functional_defect, confidence 0.99]

# Fix in app.js: return pct / 100 (was pct / 1000), then run it again
$ kane-cli testmd run tests/e2e/checkout_test.md --agent --headless --timeout 300
{"type":"test_md_summary","overall_status":"passed","duration_s":65,"steps":{"total":2,"passed":2,"failed":0}}
$ echo $?
0

What in a Claude Code Workflow Doesn't TestMu AI Replace?

TestMu AI doesn't in any way replace code review, unit tests, security scanners, model evaluation or the person who ultimately approves the merge. Anthropic says exactly the same thing about its own agents: you keep your existing tests, scanners and reviewers. The team still owns the scope, the design, the evidence and the merge rules.

Kane CLI is a standalone tool, and the examples above are the patterns that you configure, not an Anthropic integration. Kane CLI will work with Codex, Cursor and Gemini CLI too.

Where Should You Start on Your Next PR?

Start with one critical user flow and carry it through every stage:

  • Write the flow as a *_test.md file in which each step ends in a Verify or Assert sentence.
  • Add its run command to CLAUDE.md under Commands.
  • Add a verify skill that runs the Kane CLI and reports the command, exit code and evidence path.
  • Add the kane-e2e job and make it a required status check (no path filter).
  • Add a rule to REVIEW.md to mark any edits to Verify or Assert sentences.
  • Add steward rules for exit codes 1, 2 and 3, then run /ship on your next PR and see what happens.

Conclusion

Pick the one user flow that would hurt most if it broke, and take it through the six steps above on your next PR. Once its kane-e2e check is required and the evidence pack backs every pass, add the next flow to the same test folder and keep CLAUDE.md, REVIEW.md and the steward rules in step with it.

Make every Claude Code change carry proof. Install Kane CLI (npm install -g @testmuai/kane-cli), add the skill (npx @testmuai/kane-cli-skill), and run your first test file before your next commit. Start with Kane CLI.

Testing from the terminal? Kane CLI by TestMu AI lets SDETs and developers plan, write, run and debug tests from the command line.

To run your first test, start free, or
for a full walkthrough of the product.

Sources

Was this helpful?

Authors

Mudit Singh

Mudit Singh

Author · 8 posts

Mudit Singh is Co-Founder and Head of Growth at TestMu AI, and a member of the founding team that has grown the platform to 2.8M+ users across 132 countries. He drives growth and go-to-market across the full product portfolio, including KaneAI, Kane CLI, the Real Device Cloud, SmartUI, accessibility testing, and HyperExecute. Over more than eight years on the founding team he has helped build and bring these testing products to market from scratch, scaling the company from cross-browser testing into a full-stack agentic AI quality engineering cloud backed by Sequoia, Qualcomm Ventures, and Premji Invest. He brings over 15 years of experience building and marketing software products and holds a B.Tech in Computer Science from Jaypee Institute of Information Technology.

Mayank Bhola

Mayank Bhola

Reviewer

Mayank Bhola is Co-Founder and Head of Products at TestMu AI, where he leads the entire product portfolio across KaneAI, Kane CLI, HyperExecute, SmartUI, the Real Device Cloud, Accessibility, and other software testing product lines. As an early Lead Architect he designed and built the company's flagship Tunnel technology from scratch, created the React-based automation platform, and architected the data-intensive pipelines and FAAS services that scale it. He brings more than 10 years of experience in software development and product engineering, with earlier roles as Head of Technology at Juggernaut Books and Senior Software Engineer at PressPlay TV and Zomato. Mayank holds a B.Tech in Computer Engineering from JIIT Noida.

Claude Code Best Practices FAQs

TestMu AI forEnterprise

Get access to solutions built on Enterprise
grade security, privacy, & compliance

  • Advanced access controls
  • Advanced data retention rules
  • Advanced Local Testing
  • Premium Support options
  • Early access to beta features
  • Private Slack Channel
  • Unlimited Manual Accessibility DevTools Tests