Docs  Code, git and pull requests

Tools

Code, git and pull requests

Finding your way around a project, building it, looking at what was built, keeping work apart in worktrees, and opening pull requests that never touch main.


What this family is for

These tools turn a request into a working project and carry it to a pull request: learn the repository, start a project, preview it, test it, commit it, and publish it for review. Shell commands, toolchains and dependencies live next door in Terminals and runtimes. The whole build cycle is described in Coding and builds.

Orient, then build

In a repository she has not seen this session, Mori starts with repo_map: the project's own instructions file, how it builds and tests, and its layout with file counts, in one call. From there she reads only what the job needs.

A new project starts in its own folder. scaffold_web_app starts a web app on Vite, React and Tailwind with a design system already in place, and the simpler scaffolds start a plain page or a small Node project. A static page with no app logic is written by hand instead.

Seeing what she built

A build is not done until something ran. For pages, Mori looks at her own work in the Mori Preview window, never your desktop:

  • preview_screenshot takes the picture, whole page or close ups, and reports the console errors since the page loaded.
  • preview_snapshot reads the page the way a screen reader meets it.
  • preview_act walks through journeys, clicking, typing and checking, each journey on a fresh page, and says which step failed.

These need no permission because they act only on a file or a dev server she started. start_dev_server returns once the server prints its address, so dev_server_logs is how she catches the errors that show up after that, including a server that crashed.

Tests that can fail

A green suite only proves the tests agree with the code. verify_tests breaks the code one change at a time and runs the tests again; a change no test notices is behaviour nothing checks. crash_logs reads the newest crash reports of a native program, Java, Minecraft, Roblox Studio, Godot or Unreal when you ran it yourself.

Worktrees keep work apart

A big or risky job gets its own workspace: a git worktree with its own branch and folder, so the change never lands on your checkout by accident and parallel helpers do not collide. While a workspace is active, the shell, git and relative file paths point into it.

  • Merging a workspace commits what is pending, then merges into its base.
  • Removing one keeps the branch, refuses a workspace that belongs to another thread, and refuses one with uncommitted work unless you said to throw it away. Then the folder goes to the Trash.

Pull requests, and why no tool merges

pr_open makes a fresh mori/ branch off the base, commits, pushes and opens the pull request with GitHub's own command line tool, signed in as you. It never commits on main. Called again from the same thread it updates the same pull request, and pr_stack opens the next one in a stack on top of the last.

After that, CI is watched and the thread wakes when it fails. pr_checks shows each job, pr_fix_ci reads the failing log, and pr_comments reads the unresolved review threads, ignoring bots unless you name one. pr_preview finds the preview deploy link.

No tool can merge. Merging is a button on the Pull requests page, with a confirmation, so the last step is always yours.

Permissions

Git, workspace, scaffold and pull request tools follow the File Writing switch in Settings > Permissions. Reading the state, status, diff, log, branches, the pull request ledger, its checks and preview link, always runs. Starting and stopping dev servers follows Terminal Commands, and opening VS Code itself follows App Launching. Files that run things later, such as git hooks, .git/config and CI workflows, are written only when your own words name them; see Asking and the safety rails.

55  The toolsfrom the app itself

Each description below is the exact text her model reads when it decides which tool to call.

secret_scan

Scan a repo or project folder for hardcoded keys, tokens and passwords with Mori's own pinned gitleaks, read only (nothing in the folder is changed or run, secrets are redacted). Every code or security review runs it first, on the folder it reviews, and merges every finding into the review.

repo_map

Orient in an unfamiliar project in ONE call: its own instructions file (AGENTS.md / CLAUDE.md / CONTRIBUTING.md), how it builds and tests (package.json scripts and package manager, Makefile, pyproject, Cargo, go.mod), and its top-level layout with file counts, plus the REPO card repo_understand saved for it. Call this FIRST when asked to work in a repo you have not seen this session.

git_status

Git status: branch, plus changed, staged and untracked files. Use before committing.

git_diff

Git diff of unstaged (or staged) changes. Review edits before committing.

git_commit

Stage everything and commit. Use after finishing a unit of work.

git_log

Recent commits, one line each.

git_branch

List branches, local and remote.

git_checkout

Switch branch, or create one with create="true".

git_init

Start a git repository in a folder.

pr_open

Publish the work as a pull request: makes a fresh mori/<slug> branch off the base (never commits on main), commits everything, pushes, and opens the PR with gh. Called again from the same thread it reuses the branch and updates the same PR. CI is then watched and this thread woken if it fails. It cannot merge.

pr_stack

Open the NEXT pull request in a stack: a fresh mori/<slug> branch based on the previous PR's branch, not on main, committed, pushed and opened with that branch as its base.

pr_status

The pull requests Mori opened on this repo: number, state, branch, CI state, unread comments, owning thread, URL.

pr_checks

CI checks on a PR (gh pr checks): each job with pass/FAIL/running and its link. Defaults to this thread's open PR.

pr_fix_ci

Read the FAILING job log of a PR (gh run view --log-failed) so you can fix the cause. Returns the failing jobs and the log tail. Fix, verify locally, then pr_open again with the same title to push.

pr_comments

Unresolved review threads and human comments on a PR. Bot comments are ignored unless allow_bots names them; a bot named once is remembered on that PR, so the watch wakes this thread for it too.

pr_preview

The preview deployment URL for a PR: a Vercel/Netlify link posted in a PR comment first, then the deploy check's details URL, then a dashboard. Says so when there is none.

create_workspace

Make an isolated git-worktree WORKSPACE for a big or risky code job, its own branch + directory, so changes never clobber the main checkout (and parallel subagents don't collide). Afterward, shell/git/relative-file tools default to it. Use before a large refactor or an experiment.

list_workspaces

List the isolated git-worktree workspaces and which one is active.

enter_workspace

Switch into a workspace (by id, name, or branch), shell/git/relative-file tools then default to its directory.

exit_workspace

Leave the current workspace, tools go back to their normal working directories.

merge_workspace

Merge a workspace's branch back into its base (commits pending work first, then a no-ff merge). Set delete_after='true' to remove the worktree once merged.

remove_workspace

Remove one of THIS thread's workspaces (worktree directory; the branch is kept). It refuses another thread's, and refuses one with uncommitted changes: merge it, or ask the person. force='true' only when the person said to throw that work away; the folder then goes to the Trash.

create_project_folder

Create a new named project folder

scaffold_web_app

START HERE for a web APP (state, routing, a dashboard, anything with a build step): a Vite + React + Tailwind v4 project built for its subject; it picks the direction (layout, type, ground, motion) and returns it; then write that layout in src/App.tsx. A static page (landing page, menu, one-pager with no app logic) is hand-built instead.

scaffold_simple_html_project

Create a simple HTML project with index.html, style.css, and script.js

scaffold_simple_js_project

Create a simple Node.js project with package.json and src/index.js

open_preview

Show the user what you built in the Mori Preview window. Pass a project folder or an .html file to render it live, or a localhost URL to show a running dev server. ALWAYS call this right after building a web project.

preview_screenshot

LOOK at a page you built in the Mori Preview window (never the desktop): url = a dev server, path = a static .html or its folder, neither = the preview already open. section = one viewport-high close-up (1 = top); sections = several close-ups in ONE look ("1-4", "2,5" or "all", up to 4). It reports the page's console errors and warnings too. Use it, not take_screenshot, to check a build.

preview_snapshot

READ a page you built as a person with a screen reader meets it: the Mori Preview's controls, lists, headings, live regions and text, with states (focused, checked, value) and a ref (e52) for each element preview_act can use. url = a dev server, path = a static .html or its folder; neither = the preview already open. within = one part (a ref, or role "name"). Text only; preview_screenshot is the look.

preview_act

TRY what you built in the Mori Preview (never the desktop; no permission needed): one call runs every journey of a check pass, one step per line, each journey opening with a journey "name" line that opens the call's page fresh, with storage and cookies cleared (a failed step ends only its own journey; a plain reload stays inside it), and returns each step's result, what changed, the page's console since, and a verdict. A failed expect is a bug to fix, then run the same steps again. Steps: click T | type T "x" | fill T "x" | press Enter | press Space on T | press ArrowRight x2 | drag T to T via pointer | drag T to T via keyboard | scroll down | resize 390x844 | reload | journey "name" | screenshot | screenshot section 2 | wait for "x" | expect "x" | expect no "x" | expect "x" in T | expect focused T | expect T checked | expect T value "x" | expect T has 3 items | expect announce "x" | expect console clean | expect storage "key" contains "x". T = a ref (e52), "text", role "name" (button "Add", list "Done"), or #css. Acts only on a file or a dev server you started.

start_dev_server

Start a project's dev server (vite/next/expo) and leave it RUNNING in the background. Returns the pid and the local URL once it prints one. Check it with open_preview or http_request against that URL, and READ its output after changes with dev_server_logs. Stop it with stop_dev_server.

stop_dev_server

Stop a running dev server by pid, or by a fragment of its command/folder. Omit to stop all.

list_dev_servers

List the dev servers you currently have running (pid, command, uptime).

dev_server_logs

Read the recent output of a dev server you started, or one that CRASHED (its last output stays readable). start_dev_server returns after ~3.5s, so compile errors, module-not-found on first load, port conflicts and crashes all happen AFTER it reports success. Call this after making changes or whenever the preview looks wrong, and fix what the log actually says.

verify_tests

Prove a test suite can actually FAIL. Breaks the subject file one change at a time and re-runs the tests: a change no test notices is behaviour nothing is checking. Use after writing tests, before saying they pass, and when a suite has been green for a long time. This is the only check that distinguishes 'the code works' from 'the tests agree with the code'.

crash_logs

Read the newest crash or error logs and summarize them: kind "native" (a C/C++ program, by its file name), "java" (hs_err logs in a folder), "minecraft" (a server or dev client folder: crash-reports, latest.log), "roblox" (Roblox Studio's logs), "godot" or "unreal" (a project folder). A command that crashes already reports its fresh crash report; use this for a game the person ran themselves or an older crash.

open_vscode

Open Visual Studio Code

open_new_vscode_window

Open a new VS Code window

open_project_in_vscode

Open a folder/project in VS Code (opens the folder AND reveals its main file)

vscode_create_project

Create a new project with HTML/CSS/JS files and open it in VS Code. A complete workflow shortcut, creates files, opens VS Code, opens the main file.

vscode_open_and_write

Create a file with content and open it in VS Code immediately.

apply_patch

Change several files in ONE call, all or nothing: a V4A patch (*** Begin Patch, then *** Update File: path with @@ hunks of lines starting with a space for context, - to remove and + to add, *** Add File: path with every line starting with +, *** Delete File: path, *** Move to: newpath under an update, then *** End Patch) or a unified diff (--- a/path, +++ b/path, @@ -12,3 +12,4 @@). Every file is checked first (it must have been read, every hunk must land in exactly one place), then each change is written through edit_file, create_file or delete_file. If any file fails, nothing is changed, and a write that is refused puts back the files already written. Use it for a refactor across files; use edit_file for one change in one file.

code_definition

Go to definition: where a name used in a file is defined, from the language server (TypeScript/JavaScript, Python, Go, Rust), else the symbol index. Give the file and either line and column, or the symbol name (with its line when it appears more than once).

code_hover

Hover: the type, signature and doc comment of a symbol at a position, from the language server.

code_references

Find references: every place a symbol is used across the project, the definition marked, from the language server (else a whole-word search). Same position arguments as code_definition.

code_rename

Rename a symbol everywhere it is the same symbol (not every word that looks like it), across files. The first call is a DRY RUN listing every edit; call again with apply "true" to write them all as one batch, each file checkpointed (undo_changes takes it back).

code_symbols

Symbols: a file's outline (classes, functions, methods, types with their lines), or with a query, the project's symbols whose name matches it (workspace symbols).

folder_checkpoints

Mori checkpoints a whole folder before the first change of each turn, shell changes included. With no n: the folder's checkpoints, newest first. With n: what changed in the folder since checkpoint n, as a diff. Reads only; the person rolls back with /rollback.

pr_ready

Is a PR really done? Reads the REQUIRED checks of its base branch (branch protection and rulesets, not every check) and says which required check is pending, failed, skipped or neutral. A PR is done only when every required check passed. Call it before saying a PR, or the work it carries, is done.

repo_understand

UNDERSTAND A REPO all the way through, from a git link (cloned shallow into Mori's own folder, never read off GitHub's web page) or a folder on this computer. Builds its map (languages, entry points, build and run commands from its manifests, monorepo packages, the module graph from its imports and its hubs, a symbol index, its tests), reads the important files in order within a budget, and returns and saves a REPO card: what it is, how it runs (the run recipe, in order), its architecture and where things are. Use it whenever the person gives a repo or asks to understand, explain, run or build on one.

resolve_conflicts

Settle a merge that conflicts, hunk by hunk, as a neutral arbiter, instead of giving up on it. First call with the workspace (or repo, ours and theirs): the merge is made in a temporary worktree, never your checkout, and you get every conflicting hunk with ours, base and theirs, both branches' intents and diffs, and a plan id. Then call again with the plan id and decisions for EVERY hunk (ours, theirs, both, base, or custom text, each with a reason). It writes them, checks no conflict marker is left, runs git diff --check and the project's own check, and only then moves the base branch to the merge. Every decision is reported.

run_tool_script

Run a short JavaScript program that calls Mori's file, search and git tools itself, so a long chain of calls (read 40 files, grep them, count, compare, then edit a few) is ONE step instead of 40. Inside the script: `await tools.read_file({ path })`, `await tools.search_files({ path, pattern })`, `await tools.edit_file({ path, old_string, new_string })` and the rest of the allowed list, each returning the tool's text; `print(...)` (or console.log) is the ONLY thing you get back, so print what you need. Top-level await works. The script keeps its state for this conversation: anything you put on `keep` (or globalThis) is still there in your next run_tool_script call. Allowed: reads (read_file, read_any, list_files, get_file_info, read_pdf, query_csv, git_status, git_diff, git_log, list_changes), searches (search_files, find_files, repo_map, search_history, search_sessions) and writes (edit_file, create_file, write_file, append_to_file, apply_patch, create_folder). A write asks exactly as it would if you called it yourself. Shell commands, the network, messages, money and the computer are not reachable from a script. Limits: 30 seconds by default (timeout_seconds up to 120), 120 tool calls per turn; a script that runs past its time is stopped and its saved state is cleared, and the result says so.

working_diff

Show a folder's own git changes in one read, untracked files included (git_diff leaves those out): scope "working" (not staged yet), "staged", or "all" (everything against the last commit, the default). A long diff keeps its head and tail and saves the rest to a file you can read.

workspace_trust

Whether a repo or folder is trusted. A clone is not trusted until the person says so: Mori type-checks it with its own servers (no build scripts, proc macros or the repo's own binaries) and installs skip install scripts. trust "yes" works only when the person's own message said to trust it.

verify_project

Prove a project really runs: detect how it is installed, built, tested and started (from its own files; the person's .mori/environment.json wins), run each step, start it, wait until its address ANSWERS (not just prints), then stop it. Use it before saying an app works. The last line is VERIFY PASSED or VERIFY FAILED at <step>, with that step's output.