This file gives concise, actionable guidance to automated coding agents working in this repo. Follow project-specific rules, run the project's tests and linters, and prefer non-interactive commands that match existing .agents/prompts/* automation.
- Project: TypeScript + Svelte library for Obsidian plugins
- Key dirs:
src/,assets/locales/,scripts/,tests/,.agents/ - Common commands:
bun run build(runsbun run checkthennode scripts/build.mjs) — usenode scripts/build.mjs devfor dev buildsbun run check(TypeScript + ESLint + markdown + Prettier)bun run test(runsvitest run --coverage)bun run format(eslint + prettier + markdown fixes)
- Prefer
bunwhen managing versions/releases (this repo is bun-friendly —bun.lockmay be present).
- Always prefer non-interactive, reproducible commands. Do not ask confirmation questions when using built-in prompts like
commit-stagedorbump-version— those prompts are written for agents. - Do NOT run
vitestinteractively/watch mode. ThevitestCLI defaults to interactive/watch mode when invoked without therunsubcommand; agents must always usevitest run <options>or append--runso tests execute non-interactively. - Run project checks before making changes:
bun run checkandbun run testwhere applicable. If CI/coverage fails, include failing test details in your report. - Commit messages must conform to Conventional Commits and pass
bun run commitlint. Use thecommit-stagedprompt to generate and create commits. - When bumping versions use the repository's preferred manager:
bunif abun.lockexists; otherwise fall back to another supported package manager. - Keep changes minimal and scoped. Do not stage unrelated files; stage only files changed by your operation.
TypeScript typing rules (required)
- Never use
any. Preferunknown, explicit interfaces/types, unions, or generics. If you believeanyis unavoidable, leave a TODO and open an issue instead of committing it. - Never use
astype assertions/casts. Replace casts with properly-typed APIs, overloads, or type-guard helpers that narrow types at runtime. - Make code type-checking friendly. Add explicit
returntypes for public functions/components, annotate exported symbols, prefer narrow unions and discriminated unions, and add small helper types instead of widening toany. - Fix TypeScript errors by improving type declarations — do not silence the checker with
// @ts-ignoreorascasts. - Run
bun run checkafter changes and ensuretsc(withstrictsettings) passes locally before committing. - If an ESLint/TS rule is missing to enforce these practices, propose the lint/config update in a separate PR and reference it in your commit message.
- Default to
readonly. All type properties, interfaces, function parameters, and local variables must bereadonlyby default. Mutation requires explicit justification.
- Settings & persistence: use
SettingsManager/StorageSettingsManager+fix()helpers (seesrc/settings.ts). Persisted settings must be validated using.fix()helpers. - i18n: add keys first in
assets/locales/en/translation.jsonand keep interpolation tokens like{{...}}and$t(...)unchanged (see.agents/instructions/localization.instructions.md). - Svelte: components live under
src/components/and are compiled viascripts/build.mjs(usesesbuild-svelte+svelte-preprocess). For dev builds usenode scripts/build.mjs dev. - Tests: follow
tests/README.mdconventions — prefervi.fn()for stubs,vi.spyOnfor globals, reset/restore mocks inafterEachand usevi.useFakeTimers()for timer control. - Reveal machinery: the type-level semantics of
RevealPrivate, theRevealWhitelistwhitelist (private types$Xto reveal) and theRecursionBlacklistblacklist (types to stop recursing), plus the configurableDepthnumber generic (recursion bound, orthogonal to both), the exempt marker policy, and the empty$BakedHotkeybrand policy are specified in.agents/instructions/reveal-private.instructions.mdand the docstrings ofsrc/private.ts. Type tests live in the "Type system" describe block oftests/src/private.spec.ts.
- Build process performs
tsc --emitDeclarationOnly+ esbuild bundling (seescripts/build.mjs). Ensure declaration files are generated when changing public API. - Release bumps should update
package.jsonand run any version scripts; use thebump-versionprompt orbun version --no-git-tag-versionwhen applicable.
- Run
bun run check→bun run testlocally. - Add or update unit tests to cover behavior changes.
- Add i18n keys to
assets/locales/en/translation.jsonfirst (then update other locales if needed). - If public API or exports changed, run
bun run buildand verify.d.tsoutputs are updated. - Ensure commit message follows Conventional Commits and passes
bun run commitlint.
Applies to: src/**/*.ts, src/**/*.svelte, assets/locales/**/*.json, tests/**/*.spec.{ts,js}, .github/**, README.md
- Run checks before proposing code changes:
bun run checkandbun run test. - TypeScript: default everything to
readonly— interfaces, properties, variables, parameters. Do not useanyoras; preferunknown, explicit return types and type guards. - Commits: follow Conventional Commits and use
.agents/prompts/commit-stagedfor automation. - i18n: add new keys in
assets/locales/en/translation.jsonfirst; do not change{{...}}or$t(...)tokens. - Settings/persistence: use
SettingsManager/StorageSettingsManager+.fix()helpers for persisted data. - Tests: run non-interactively with
vitest run --coverage; follow existing test patterns and reset mocks inafterEach. - Build/API changes: run
bun run buildwhen changing public exports and verify generated.d.tsfiles. - Avoid interactive or broad operations in automation: do not run
vitestwithout--run, do not usegit add ., and avoid interactive prompts.
Follow the PR checklist above and the detailed
.agents/instructions/*files for area-specific rules (TypeScript, i18n, commit messages).
- "Write unit tests for
src/settings.ts::SettingsManager.fix()following existing test styles." - "Refactor
src/utils.tsto add explicit return types; do not useanyoras." - "Add i18n key
components.myPlugin.newFeatureto English and include tests that assert the translation is present." - "Create a non-interactive Conventional Commit for changes in
src/plugin.tsusing.agents/prompts/commit-stagedand ensurebun run commitlintpasses." - "Add unit tests for
src/components/find.svelteto cover keyboard navigation and initial focus behavior; usevi.useFakeTimers()and reset mocks inafterEach." - "Change an exported symbol in
src/index.ts: update types, runbun run build, and add tests validating the public API."
/create-prompt commit-staged— generate Conventional Commit messages for staged changes (automated, non-interactive). Example:commit-staged→ producefeat(settings): add fix() for malformed dataand ensurecommitlintpasses./create-instruction svelte-tests— guidance and test templates for Svelte components (applyTo:src/components/**). Example: "Add find.svelte keyboard/focus tests using existing test helpers."/create-agent pre-PR-check— agent that runsbun run check,bun run test, and returns a remediation report with failing tests and lint errors. Example:pre-PR-check→ list failures and suggested fixes./create-instruction i18n-check— validate that new i18n keys are added toassets/locales/en/translation.jsonand covered by tests. Example:i18n-check components.myPlugin.newFeature→ add English key + test scaffold.
- Commit and lint rules:
.commitlintrc.mjs,.agents/instructions/commit-message.instructions.md - TypeScript coding patterns:
.agents/instructions/typescript.instructions.md - Localization rules:
.agents/instructions/localization.instructions.md,.agents/instructions/i18n-check.instructions.md - Svelte component testing:
.agents/instructions/svelte-tests.instructions.md - Test best practices:
tests/README.md
If anything in this playbook is unclear or you want me to expand examples (e.g., sample commit message for a particular change), tell me which area to expand and I’ll update this doc. 💡