docs(agents): fix accuracy bugs and flip AGENTS.md to canonical#208
Merged
docs(agents): fix accuracy bugs and flip AGENTS.md to canonical#208
Conversation
…canonical Two outright bugs that would mislead any agent following the docs: - commands.md said \`pnpm version\` / \`pnpm release\` — bare \`pnpm version\` collides with pnpm's built-in (silently prints \`process.versions\` instead of running the changeset script). Switched to \`pnpm run version\` / \`pnpm run release\` and added a release-flow walkthrough that documents the OIDC + RELEASE_PAT setup. - handlers.md imported \`declareWorkflow\` from \`@temporal-contract/worker\`, but the worker package's exports map only declares \`./activity\`, \`./worker\`, and \`./workflow\` subpaths — no root entry. Fixed to \`@temporal-contract/worker/workflow\`. Stale claims now matching reality: - code-style.md: documented the legitimate \`interface\` exception for declaration merging (testing/src/global-setup.ts), softened the type-imports rule (not actually lint-enforced), and clarified that published packages don't log — pino is for examples only. - dependencies.md: dropped the unused-pino claim, added ts-pattern, and documented peer-dependency policy + the \`pnpm.overrides\` security pins. Coverage gaps filled: - contract-patterns.md: added \`updates\`, \`searchAttributes\`, and the standalone \`define*\` helpers (defineActivity / defineSignal / defineQuery / defineUpdate / defineSearchAttribute / defineWorkflow). - AGENTS.md: inlined the 5 highest-leverage rules at the top so an agent reading only the entry doc already knows the load-bearing constraints (ResultAsync, no \`any\`, \`.js\` imports, ESM, catalog versions). Structural change: AGENTS.md is now the canonical file (matches the cross-tool standard) and CLAUDE.md is a symlink to it. Reverses the previous direction. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the agent-facing documentation (AGENTS.md rule set) to correct inaccurate guidance and expand coverage around releases, dependency management, and contract authoring patterns.
Changes:
- Fixes incorrect usage examples (e.g.,
declareWorkflowimport path;pnpm version/releaseinvocation). - Expands dependency guidance (catalog usage, peer dependency policy,
pnpm.overrides) and contract patterns (updates + search attributes +define*helpers). - Refines code-style guidance (interface exception for module augmentation; clarify logging expectations).
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| .agents/rules/handlers.md | Fixes declareWorkflow import to use the exported subpath. |
| .agents/rules/dependencies.md | Reworks dependency documentation: catalog, peer deps, overrides, and monorepo conventions. |
| .agents/rules/contract-patterns.md | Expands contract examples with define* helpers, updates, and search attributes. |
| .agents/rules/commands.md | Updates version/release commands and documents the release workflow mechanics. |
| .agents/rules/code-style.md | Clarifies TS rules (interface exception, type-import preference) and logging guidance. |
…ckage scaffolding The previous accuracy pass fixed bugs but left real footguns undocumented. Adds the high-impact missing tribal knowledge identified in the audit. New rule files: - workflow-determinism.md — banned APIs (Date.now, Math.random, setTimeout, crypto, native I/O) and Temporal-provided replacements. Promoted to the #1 entry in AGENTS.md's top-rules list since determinism is the leading cause of broken Temporal workflows. - adding-a-package.md — step-by-step runbook covering tsconfig extension, vitest config, knip + changeset registration, peer-dep mirroring, and the multi-entry exports gotcha. Expanded existing files: - handlers.md: added Cancellation section (cancellableScope / nonCancellableScope / WorkflowCancelledError) and ApplicationFailure semantics (type / nonRetryable / cause / details), each with file:line breadcrumbs to the canonical source. - code-style.md: documented the three non-default tsconfig flags (noUncheckedIndexedAccess, exactOptionalPropertyTypes, noPropertyAccessFromIndexSignature) with the spread idiom for optional cause. Stated that oxlint enforces only two rules. - commands.md: listed all 11 commitlint-allowed types (config-conventional) with one-line guidance per type. - testing.md: added file:line breadcrumb to vitest.config.ts:11-27, noted contract package's unit-only template, documented turbo's cache: false on test tasks and the vitest --coverage flag passthrough. - project-overview.md: added repo-layout table (packages / examples / tools / docs), canonical entry-point breadcrumbs per package, and cross-links to determinism + handlers rules. Cleanup: - AGENTS.md: top-rules list grew from 5 to 6 with determinism at #1; rule-reference table now includes the two new files. - CONTRIBUTING.md: trimmed to a contributor on-ramp that delegates to .agents/rules/ as canonical, eliminating the prior duplication (commit types, code-style, test conventions). Adds a where-to-look table covering all nine rule files. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CI was red on the Format job because AGENTS.md and CONTRIBUTING.md were checked in without going through oxfmt. Fixed. Five review comments from the Copilot reviewer, all accurate: 1. contract-patterns.md said \`defineContract\` enforces activity-name collisions "at the type level" — wrong, it's a Zod runtime validation pass that throws (\`packages/contract/src/builder.ts:441\`). Reworded to match reality and added the file:line breadcrumb. 2. dependencies.md "Key Dependencies" labeled \`zod / valibot / arktype\` as purely user-side, but \`zod\` is a direct runtime dep of the \`contract\` package (used by the validation pass above). Split the row so \`zod\` is documented as both internal and a user-facing schema lib. 3. dependencies.md "Peer Dependencies" said \`testing\` had no peer deps, but \`@temporal-contract/testing\` declares \`vitest ^4\` as a peer (the \`globalSetup\` hook integrates with vitest's runner). Documented. 4. commands.md release-flow step 3 said \`pnpm run release\` runs \`pnpm publish ...\`, omitting the \`pnpm build &&\` prefix from the actual root script. Step now mirrors the package.json command. 5. code-style.md anti-pattern claimed \`packages/*/src/\` is silent re: logging — not true, \`packages/testing/src/global-setup.ts\` uses \`console.log\`/\`console.error\` to surface testcontainers progress. Narrowed the rule to library packages (\`contract\`/\`client\`/\`worker\`) and explicitly carved out \`testing\` as the documented exception. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Audit pass on
AGENTS.md/CLAUDE.mdand the seven.agents/rules/*.mdfiles. Two outright bugs were misleading agents; several stale claims and coverage gaps cleaned up.Outright bugs fixed
commands.md—pnpm versionandpnpm releaseare documented but barepnpm versioncollides with pnpm's built-in (silently printsprocess.versionsinstead of running the changeset script — the release workflow already worked around this inrelease.yml). Switched topnpm run version/pnpm run releaseand added a release-flow walkthrough that documents OIDC Trusted Publishing + theRELEASE_PATsetup.handlers.md—import { declareWorkflow } from "@temporal-contract/worker"doesn't work. The worker package'sexportsmap only declares./activity,./worker, and./workflowsubpaths; there's no root entry. Fixed tofrom "@temporal-contract/worker/workflow".Stale claims now matching reality
code-style.md— Documented the legitimateinterfaceexception for declaration merging (packages/testing/src/global-setup.tsaugments vitest'sProvidedContext), softened the type-imports rule from "use" to "prefer" (it isn't lint-enforced), and clarified thatpinois forexamples/only — publishedpackages/*/src/are silent.dependencies.md— Dropped the unused-pinoclaim, addedts-pattern(used by examples), added a Peer Dependencies table documenting theneverthrow ^8peer dep policy that just landed in feat!: replace @swan-io/boxed with neverthrow #206, and a section onpnpm.overrides(security pins forlodash/vite/ etc. that agents bumping deps will trip over).Coverage gaps filled
contract-patterns.md— Addedupdatesblocks,searchAttributes(KEYWORD/INT/DATETIME/ etc.), and the standalonedefine*helpers (defineActivity,defineSignal,defineQuery,defineUpdate,defineSearchAttribute,defineWorkflow).AGENTS.md— Was pure delegation (just a 7-row table of links). Now inlines the 5 highest-leverage rules at the top so an agent reading only the entry doc already knows the load-bearing constraints (ResultAsync, noany,.jsimports, ESM, catalog versions). Rule table preserved for deep dives.Structural change: symlink direction flipped
Was:
AGENTS.md → CLAUDE.md(Anthropic-named file as source).Now:
CLAUDE.md → AGENTS.md(cross-tool standard as source — Cursor / Aider / Continue / Codex etc. all look forAGENTS.md).Git captures this as a type-change on both files (
Tingit status).Test plan
.agents/rules/*.mdlinks fromAGENTS.mdresolve (verified locally — see grep loop in commit).pnpm run versionandpnpm run releasereferenced incommands.mdmatch the scripts defined in rootpackage.json.import { declareWorkflow } from "@temporal-contract/worker/workflow"matches theexportsfield inpackages/worker/package.json.🤖 Generated with Claude Code