agentleFS
junhoyeojunhoyeo/tokscale/AGENTS.md

tokscale

AGENTS.md5.6k starsChanged 2 months agoMITView on GitHub

This document provides context for AI agents working on the Tokscale project. When updating AGENTS.md files, follow these principles: When writing PR bodies, issue bodies, or comments through gh pr create, gh issue comment, etc.: prefer --body-file with a written-out file over inline --body heredocs. Why: inline --body "$(cat <<'EOF' ... EOF)" patterns lead to recurring mistakes where backticks are written as \ (incorrectly escaping them inside a single-quoted heredoc where no escaping is needed). The literal \ then renders…

  • Commits and pushes

Trending

Less talk lately.about the whole repository

Dec 2025: 3 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 1 mentionApr 2026: 1 mentionMay 2026: 3 mentionsJun 2026: 4 mentionsJul 2026: 11 mentionsAug 2026: 11 mentionsSep 2026: 10 mentionsOct 2026: 1 mentionNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the junhoyeo/tokscale repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about junhoyeo/tokscale

The biggest 5 of 45 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 45

Talked about on GitHub, Bluesky and Hacker News (45 times).

On GitHub · 39

34 more on GitHub

On Bluesky · 4

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

The file

Show its rules and text

We split this AGENTS.md into the rules it gives an agent

21 rules. About 0 are common, 7 are distinctive, and 14 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 14

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When updating AGENTS.md files, follow these principles:

    line 7
  2. Very specific:

    When writing PR bodies, issue bodies, or comments through gh pr create, gh issue comment, etc.: prefer --body-file with a written-out file …

    line 18
  3. Very specific:

    Write the body to /tmp/pr-body.md (or similar) with the Write tool, then gh pr create --body-file /tmp/pr-body.md

    line 24
  4. Very specific:

    Use gh pr create --body "$(cat <<'EOF' ...

    line 29
  5. Distinctive:

    Use double-quoted heredoc for bodies containing backticks unless you intend command substitution.

    line 30
  6. Very specific:

    Before any commit, inspect the effective Git identity (git config user.name / user.email) and remotes.

    line 37
  7. Very specific:

    Never commit as worker/agent identities such as worker1, worker2, worker3, or *@example.invalid.

    line 38
  8. Very specific:

    When merging pull requests through gh, use merge commits (gh pr merge --merge ...) unless the user explicitly requests another merge …

    line 39
  9. Very specific:

    Before merging, verify the merge commit title is the intended conventional PR title and does not contain worker/agent/internal review …

    line 40
  10. Distinctive:

    Keep commits atomic (one logical change per commit)

    line 77
  11. Very specific:

    Use the format: <type>(<scope>): <what changed and why>

    line 78
  12. Distinctive:

    Use agent-internal jargon: "wave", "hardening", "compliance", "verification pass"

    line 83
  13. Distinctive:

    Use vague messages like "fix issues" or "address feedback"

    line 85
  14. Very specific:

    Never hand-edit drizzle/meta/_journal.json timestamps or sequence numbers.

    line 107
  15. Very specific:

    If two branches generate migrations with the same index, resolve the conflict by re-running drizzle-kit generate on the branch that was …

    line 112
  16. Very specific:

    When running tokscale CLI commands from an automated agent (tests, CI, or tool-driven shells), always pass --no-spinner unless spinner …

    line 118
  17. Very specific:

    Default to -F when the pattern contains any of $ { } ( ) [ ] | * + ?

    line 140
  18. Very specific:

    Verify the chore: bump version to X.Y.Z commit was pushed by CI or reused by recovery

    line 179
  19. Very specific:

    Verify tag vX.Y.Z targets the release provenance commit

    line 180
  20. Distinctive:

    Verify the GitHub Release exists and follows the release notes style below

    line 181
  21. Distinctive:

    Add a short bullet list summary (before "What's Changed") when:

    line 254

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AI Agent Guidelines

This document provides context for AI agents working on the Tokscale project.

Maintaining AGENTS.md Files

When updating AGENTS.md files, follow these principles:

  • No hardcoded counts — Don't write "10 crates" or "5 modules"; these become outdated instantly
  • No exhaustive lists — Prefer dynamic commands (ls crates/) over maintaining complete lists
  • Document constraints, not descriptions — Focus on non-obvious behaviors, gotchas, and cross-crate dependencies
  • Use nested AGENTS.md — Place crate-specific details in crates/{name}/AGENTS.md, not here
  • Verify before documenting — Grep/read the code to confirm claims are accurate
  • Delete outdated info — Outdated docs are worse than no docs

Authoring PR/Issue Content via gh CLI

When writing PR bodies, issue bodies, or comments through gh pr create, gh issue comment, etc.: prefer --body-file with a written-out file over inline --body heredocs.

Why: inline --body "$(cat <<'EOF' ... EOF)" patterns lead to recurring mistakes where backticks are written as \` (incorrectly escaping them inside a single-quoted heredoc where no escaping is needed). The literal \` then renders in GitHub markdown as backslash + backtick instead of inline code formatting.

DO:

  • Write the body to /tmp/pr-body.md (or similar) with the Write tool, then gh pr create --body-file /tmp/pr-body.md
  • For comment edits: gh api -X PATCH repos/<owner>/<repo>/issues/comments/<id> -F body=@/tmp/comment.md

DON'T:

  • Use gh pr create --body "$(cat <<'EOF' ... \ ... ` ... EOF)" — single-quoted heredoc means backticks are already literal; escaping with `` \ `` is wrong and renders incorrectly.
  • Use double-quoted heredoc for bodies containing backticks unless you intend command substitution.
  • Hard-wrap paragraphs at ~80 columns inside PR/issue/comment bodies. GitHub's markdown collapses single newlines into spaces so the rendered output looks fine, but the raw markdown view is what reviewers and authors edit in, and mid-sentence line breaks read as if the prose was chopped. Write each paragraph as one continuous line and let the renderer wrap it. Same rule for blockquotes, list items that span multiple lines, and table cells. Hard wraps are still fine inside fenced code blocks where preserving line layout matters.

This applies to all GitHub-content authoring through the CLI — PR bodies, issue bodies, comments, edits. Commit message bodies should also follow this rule: write prose paragraphs as continuous lines, not hard-wrapped at 80 columns.

Git Identity & Merge Discipline

  • Before any commit, inspect the effective Git identity (git config user.name / user.email) and remotes. If the identity does not match the contributor or expected automation account for the current branch, stop and ask for confirmation.
  • Never commit as worker/agent identities such as worker1, worker2, worker3, or *@example.invalid.
  • When merging pull requests through gh, use merge commits (gh pr merge --merge ...) unless the user explicitly requests another merge strategy.
  • Before merging, verify the merge commit title is the intended conventional PR title and does not contain worker/agent/internal review jargon.

Commit Message Convention

<type>: <description>

[optional body]

Types

TypeDescription
featNew feature
fixBug fix
refactorCode refactoring (no behavior change)
docsDocumentation only
testAdding or updating tests
choreMaintenance tasks
perfPerformance improvements

Examples

feat: add session branching with /fork command
fix: handle empty response from provider
refactor: extract streaming logic to separate module
docs: update README with new CLI options

Commit Message & PR Title Rules (CRITICAL)

These rules apply to both commit messages AND pull request titles. PR titles become the squash-merge commit message, so they must follow the same conventions.

DO:

  • Describe the actual change in plain, technical terms
  • Keep commits atomic (one logical change per commit)
  • Use the format: <type>(<scope>): <what changed and why>

DON'T:

  • Reference internal review labels (P0, P1, P2, etc.) in commits or PR titles
  • Mention "Oracle", "audit", "review findings", "hardening" in commits or PR titles
  • Use agent-internal jargon: "wave", "hardening", "compliance", "verification pass"
  • Bundle multiple unrelated fixes into one commit
  • Use vague messages like "fix issues" or "address feedback"

Good Examples:

fix(lsp): pass server args to stdio spawn command
fix(lsp): convert 1-indexed input lines to 0-indexed LSP positions
fix(gemini): parse SSE data frames instead of raw JSON lines
fix(orchestrator): route provider tools through approval flow

Bad Examples (NEVER do this):

fix: address P0 issues from Oracle review      ❌
fix(hardening): Oracle Round 4 fixes           ❌
fix: audit findings                            ❌
fix: various improvements                      ❌
fix(tui): harden unreleased changes — P0-P3    ❌  (PR title)
fix: hardening wave 1 compliance fixes         ❌  (PR title)

Migration journal hygiene

Never hand-edit drizzle/meta/_journal.json timestamps or sequence numbers. Always run drizzle-kit generate to claim a migration slot — the tool assigns the correct monotonic index and timestamp atomically.

Migrations 0010 and 0011 have round-number hand-edited timestamps ("when": 1780000000000 and "when": 1780086400000) as a one-time historical exception made during the 2026-05-25 schema audit. No future migration should follow this pattern; use drizzle-kit generate exclusively.

If two branches generate migrations with the same index, resolve the conflict by re-running drizzle-kit generate on the branch that was merged later — do not manually renumber files or edit _journal.json.

Never edit the SQL of a migration file after it has been applied to any database. drizzle stores the SHA256 of the migration content in drizzle.__drizzle_migrations on first apply. If the local file content changes (even just a comment), the local hash diverges from the stored hash and drizzle-kit migrate will treat the migration as missing and attempt to re-apply it — which fails on idempotent-unsafe DDL. If you need to document a migration after the fact (lock-window risk, rollback notes, anything), put the commentary in a sidecar 0NNN_*.md next to the .sql, in schema.ts, or in this file — never as comments inside the applied .sql.

Agent Command Execution

  • When running tokscale CLI commands from an automated agent (tests, CI, or tool-driven shells), always pass --no-spinner unless spinner behavior is the thing being tested.
  • This avoids non-interactive terminal issues and keeps command output stable for assertions and logs.

Searching the codebase with rg

An empty rg result and a malformed rg command look identical. Both print nothing. This is the failure that matters: a broken search reads as "I verified this does not exist," and that conclusion then gets stated as fact. Before concluding something is absent, run a control pattern you know matches the same file and confirm it does:

rg -c "fn parse_opencodereview_file" "$F"   # control: must print 1
rg -c "cost" "$F"                           # only now is 0 meaningful

rg is not grep, and the differences are silent rather than loud:

  • -r is --replace, not --recursive. rg -rn 'pattern' path parses as "replace matches with n" and prints plausible-looking transformed output. rg recurses by default; there is no -r to add.
  • --include does not exist. That is a grep flag. Use -g/--glob (rg -g '*.ts' pattern).
  • The pattern is a regex, so shell/template syntax breaks it. ${ is a repetition quantifier and ( opens a group, so searching for SUM(${submittedDevices.totalActiveTimeMs}) or for (const day of is a parse error — or worse, matches the wrong thing. Use -F for literal searches:
rg -nF 'GREATEST(${submittedDevices.totalActiveTimeMs}' "$R"

Default to -F when the pattern contains any of $ { } ( ) [ ] | * + ? . \ and you mean them literally — which, in this codebase, is most searches for drizzle sql template fragments or Rust macro bodies.

Release & Deployment

Overview

Releases are published to npm via a GitHub Actions workflow_dispatch pipeline, followed by a manually created GitHub Release with handwritten notes. There is no staging environment — publishes go directly to npm latest.

Release Pipeline

Workflow: .github/workflows/publish-cli.yml

Trigger: Manual — GitHub Actions UI → "Publish" → "Run workflow"

Inputs:

  • bump: Version bump type — patch (x.x.X) | minor (x.X.0) | major (X.0.0)
  • version (optional): Override string (e.g., 2.0.0-beta.1), takes precedence over bump
  • recovery (optional): Retry an already committed release version. Requires version and reuses the current release commit when the manifests already match.

Stages (sequential):

JobDescription
bump-versionsReads current version from packages/cli/package.json, calculates new version, updates the Rust workspace version plus Cargo.lock, the CLI, wrapper, and platform package manifests, then uploads the bumped release files as an artifact
build-cli-binaryBuilds the native Rust binaries defined by the workflow matrix
prepare-release-provenanceChecks npm auth/release state, then commits and pushes the release provenance files as chore: bump version to X.Y.Z. In recovery mode, reuses the already committed release SHA when there are no manifest diffs.
publish-platform-packagesPublishes platform-specific packages (@tokscale/cli-darwin-arm64, etc.) containing native binaries to npm, skipping package versions that already exist only during recovery
publish-cliPublishes @tokscale/cli to npm (binary dispatcher + optionalDependencies)
publish-aliasPublishes tokscale wrapper package to npm
finalizeCreates or updates tag vX.Y.Z and the GitHub Release after npm publishing succeeds

Duration: ~15-20 minutes end-to-end.

Package publish chain: @tokscale/cli (with platform packages as optionalDependencies) → tokscale (depends on cli). Each waits for the previous to succeed.

Post-Pipeline: Git Tag & GitHub Release

The CI pipeline creates or updates the git tag and GitHub Release after npm publishing succeeds. After the workflow completes successfully:

  1. Verify the chore: bump version to X.Y.Z commit was pushed by CI or reused by recovery
  2. Verify tag vX.Y.Z targets the release provenance commit
  3. Verify the GitHub Release exists and follows the release notes style below

Versioning Conventions

Bump TypeWhen to UseExample
patchBug fixes, small features, additive parser support1.2.0 → 1.2.1
minorNew client support, significant features, UI overhauls1.1.2 → 1.2.0
majorBreaking changes (never used so far)1.2.1 → 2.0.0

Release version is stored in the Rust workspace and the npm package manifests, and CI updates them together:

  • Cargo.toml ([workspace.package].version) — Rust binary and exported metadata version
  • Cargo.lock — local workspace package versions for tokscale-cli and tokscale-core
  • packages/cli/package.json — CLI package version and platform optional dependency versions
  • Platform packages (packages/cli-*/package.json) — native package versions
  • packages/tokscale/package.json — wrapper version plus @tokscale/cli dependency version

CI-Only Workflow

.github/workflows/build-native.yml — Runs on PRs that affect the Rust workspace, CLI platform manifests, or native build workflow. Builds the configured native target matrix to verify compilation. Does not publish.


Release Notes Style

Title Conventions

Release TypeTitle Format
Standard patch/minor`tokscale@vX.Y.Z` is here!
Flagship featureEMOJI `tokscale@vX.Y.Z` is here! (Short subtitle with [link](...))
Feature spotlightCustom banner image replacing the standard hero + call-to-action

Examples from past releases:

  • Standard: `tokscale@v1.1.2` is here!
  • Flagship: 🦞 `tokscale@v1.2.0` is here! (Now supports [OpenClaw](https://github.com/openclaw/openclaw))
  • Spotlight: Custom Wrapped 2025 banner + Generate your Wrapped 2025 with `tokscale@v1.0.16`

Release Notes Template

<div align="center">

[![Tokscale](https://github.com/junhoyeo/tokscale/raw/main/.github/assets/hero-v2.png)](https://github.com/junhoyeo/tokscale)

# `tokscale@vX.Y.Z` is here!
</div>

## What's Changed
* scope(area): description by @author in https://github.com/junhoyeo/tokscale/pull/NNN
* scope(area): description by @author in https://github.com/junhoyeo/tokscale/pull/NNN

## New Contributors
* @username made their first contribution in https://github.com/junhoyeo/tokscale/pull/NNN

**Full Changelog**: https://github.com/junhoyeo/tokscale/compare/vPREVIOUS...vNEW

Style Rules

ElementRule
HeaderAlways centered <div align="center"> with hero banner image linked to the repo
TitleBacktick-wrapped tokscale@vX.Y.Z — package name, not just version
PR list* scope(area): description by @author in URL — mirrors the PR title exactly as merged
Optional summaryFor releases with many changes or when PR titles alone don't convey impact, add a brief bullet list between the title and "What's Changed" (see v1.0.18 as example)
New ContributorsInclude section when there are first-time contributors
Full ChangelogAlways present at bottom as a GitHub compare link vPREV...vNEW
ToneConcise. No prose paragraphs. Let the PR list speak for itself.
No draft issuesNever reference draft release issues (e.g., #121) in the notes

When to Add a Summary Block

Add a short bullet list summary (before "What's Changed") when:

  • The release has 4+ PRs spanning different areas
  • PR titles alone don't convey the user-facing impact
  • A new client/integration is the headline

Example (v1.0.18):

- Improved model price resolver (Rust)
- Add support for Amp (AmpCode) and Droid (Factory Droid)
- Improved sorting feature on TUI

Deployment Checklist

1. [ ] All target PRs merged to main
2. [ ] `cargo test` passes in crates/tokscale-cli
3. [ ] No open blocker bugs (regressions from changes being released)
4. [ ] Run "Publish" workflow via GitHub Actions UI
   - Select bump type (patch/minor/major)
   - For a failed publish retry, set `version` to the already committed release version and enable `recovery`
   - Wait for all stages to complete
5. [ ] Verify `chore: bump version to X.Y.Z` commit was pushed
6. [ ] Verify packages on npm: @tokscale/cli, tokscale
7. [ ] Verify GitHub Release
   - Tag: vX.Y.Z targeting the bump commit
   - Release notes follow the template above
8. [ ] Smoke test: `bunx tokscale@latest --version`

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.