Docs · Beta
per.hr for Codex
per.hr logs your Codex sessions: your time, Codex's working time, tokens and what shipped, on the right client, project and Plan item. Sessions wait in Review until you confirm them, so nothing reaches an invoice without you.
per.hr for AI is in beta. Request Access and start right away while per.hr Customer Support reviews it (on Free, a 14-day trial starts with your first recorded session), or see what it does.
Getting Started
You need a per.hr account with per.hr for AI, Codex, Node 18.17 or later and git. In a terminal on the computer where you run Codex:
npx perhr setup
Setup signs this computer in (you approve a code at per.hr/device, so there's no key to copy), walks through your business, how clients pay you, your first client and project, then sets up the agents it finds on this computer. For Codex, it shows what it adds to Codex's hooks file and asks Add them? Say yes. Linking your code folders comes next. Claude Code doesn't need to be on the computer. To add Codex on a computer that's already set up, run the Codex step alone:
perhr setup --step codex
- The hooks. Setup adds per.hr's hooks to Codex's
hooks.jsonand saves the previous file beside it ashooks.json.perhr-backup. Each hook runs one command:nodeand per.hr's script in~/.perhr/codex/. - Your folders. Run
perhr repo linkinside each git folder you work in with Codex, and choose its project. Each folder records to the workspace where it's linked, your Personal workspace or a team, and per.hr records only the folders you link. - Claude Code too. Both agents can be set up on the same computer. Their sessions record side by side on the same clients, projects and Plan items, each labeled with its agent.
Approving the Hooks
Codex runs a new hook only after you approve it. The next time you start Codex, it shows Hooks need review. Choose Review hooks, look over what each one runs, and press t to approve them all. per.hr records from that point on.
- Codex lists per.hr's hooks as per.hr session recording, and each runs a command that ends in
.perhr/codex/hook.mjs. Hooks set up before perhr 0.7.2 show as Unnamed hook; runperhr setup --step codexto name them, and approve them once more. - There is one for each point per.hr hears about: the session starting and ending, a prompt sent, a tool used, a model request finished, a subagent starting and stopping, and a reply finished.
- If setup changes one of the hooks, Codex asks you to review that one again.
perhr doctorshows whether Codex has run per.hr's hooks yet.
Working in Codex
Work the way you already do. A session starts with your first prompt in a linked folder and appears on Work → Review right away, with both clocks running.
- On a Plan item. Ask Codex to work on the item by its reference, like
PAY-214(it ends its reply with aper.hr start:line, and the session attaches), or work on a branch named after it (feat/pay-214-reset). In a terminal in the same folder,perhr start PAY-214does the same. - Without one. The session still records, on the client and project of the folder you're in, and takes its name from its latest note until you choose an item in Review.
- From the terminal.
perhr statusshows the session, your time, Codex's time and cost so far.perhr pauseandperhr resumestop and restart recording, andperhr endsends the work to Review now.
/perhr:start and the rest do in Claude Code, the perhr command does from a terminal in the same folder.Notes and Summaries
per.hr asks Codex to end each reply with one line that starts per.hr note: and says what was just done, written about the work itself. The latest note is the session's running summary: it names the session on the Work page, and it's the summary waiting in Review when the session ends.
- Edit the summary in Review before you confirm. Clients see it on invoices for the clients you share it with.
- To write one yourself, run
perhr note "What was done"in the folder.
Time, Tokens and Cost
- Your time is the span you were attending the session: prompting, reading, testing and waiting on Codex. A gap of more than 15 minutes with nothing running is a break and is left out.
- Codex's time is counted on its own clock, subagents included, and is never added to yours.
- Tokens come from Codex itself, for every model request in the session: input, cached input and output, by model.
- Compute is an estimate at OpenAI's published API rates. A model per.hr has no rate for yet shows its tokens with no estimate.
- Your real cost. On a ChatGPT plan you pay a flat price. Add the plan in Configure → per.hr for AI, and each session shows its share of what you really pay. Only you see it.
Review and Billing
A finished session waits in Work → Review with its summary, commits and both clocks. Confirm it and its time is ready to invoice; dismiss it and nothing is billed. From there, Codex sessions bill exactly like Claude Code sessions: by Hours Worked or Agreed Hours, client by client, with AI kept off a client's invoices until you turn the receipt on for them. The Claude Code guide covers reviewing, closing Plan items and billing in full, and all of it applies here.
Teams
In a team with per.hr for AI, each developer sets up their own computer and approves the hooks in their own Codex. A folder linked to one of the team's projects records to the team, at that developer's rate, and their sessions go to their own Review. Owners and admins see each developer beside their agents in Reports and in the Monday summary, whichever agent did the work.
What per.hr Receives
- When the session and each turn started and ended, and when a subagent started and stopped.
- The folder's git remote address (or only its name, if you chose that) and the branch.
- The model and token counts for each request.
- The
per.hr note:lines, aper.hr start:line naming the Plan item you asked for, and any note you write withperhr note.
Your prompts, your code and files, and the rest of Codex's replies stay on your computer. per.hr discards events from folders you haven't linked, never connects to your repos, and never writes to commits, pull requests, issues or tickets. When per.hr can't be reached, events wait on your computer in ~/.perhr/queue.jsonl and go out in order once it's back.
Taking It Out
perhr setup --step codex --remove
This removes per.hr's hooks from Codex and leaves any other hooks in place. perhr uninstall takes per.hr off the computer altogether, Codex hooks included. Your per.hr account and everything recorded stay as they are.
Troubleshooting
- Nothing shows on the Work page. Run
perhr doctor. If it says per.hr's hooks haven't run yet, start Codex, choose Review hooks and presst. If it says the hooks are missing, runperhr setup --step codex. - The session doesn't appear until I type. That's expected: Codex tells per.hr a session has started with your first prompt, not when the window opens.
- The folder isn't recording. per.hr records only linked folders. Run
perhr repo listto see them andperhr repo linkinside the folder to link it. - The step says Codex comes with per.hr for AI. Your account doesn't have per.hr for AI yet. Request Access, then run the step again.
- A session has tokens and no estimate. Codex used a model per.hr has no rate for yet. The tokens are kept, and the estimate appears once the rate is added.
- Mac or Linux. The hook is the same Node script on every system, and it has been run on Windows so far. If something looks off, tell us.