Files
notescraft/scripts/waves/_common.md
T
Marcos Paulo 97a38180aa scripts: more agent lessons
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-13 19:20:48 -03:00

3.3 KiB

You are one of several parallel agents building NotesCraft (a native Obsidian-compatible notes app in Rust). You work in your own git worktree and own exactly ONE crate. Read SPEC.md section 3 (non-negotiables) and the SPEC sections named in your task before writing code.

Rules, all mandatory:

  • Edit ONLY files inside your crate directory (crates//). Never touch the root Cargo.toml, xtask, SPEC.md, ROADMAP.md or other crates. You may edit your crate's own Cargo.toml to add dependencies, but ONLY ones listed in your task; each as dep = { workspace = true }. If you need any other dependency, stop and say so in your final report.
  • No unwrap(), expect(), panic!, todo!, unreachable!, unimplemented! and no indexing/slicing with input-derived values in non-test code (use get(), checked_*). Keep the existing #![deny(clippy::unwrap_used, ...)] line. No unsafe. Bound recursion and cap allocations sized by input.
  • One thiserror enum Error and pub type Result<T> = std::result::Result<T, Error> per crate. Every pub item has rustdoc; every module has a //! comment. clippy::pedantic must be clean (fix, do not blanket-allow).
  • Test first: write the failing test, then the code. Unit tests in src, integration tests in tests/. Replace the stub // TODO(phase N) comment once the scope is done.
  • Lessons from earlier waves (mandatory): (a) never index with [i] or [a..b] even when guarded; use get()/split_at_checked/iterators. (b) Invalid input returns Err; never silently clamp, truncate or "fix" it. (c) No source file over ~400 lines: split by concern (error.rs, model.rs, io.rs, ...). (d) Reserved vault paths .obsidian/ and .notescraft/ are never written through public APIs unless the task says so. (e) Write each file with a single tool call of at most ~250 lines, then build; if you write a huge file in one response your output is cut off and you stall. Work in small steps, run the build often, keep thinking short.
  • More lessons: (f) every module you create must be declared in lib.rs (mod x;) and its tests must actually run: after writing tests check cargo test -p <crate> lists them. (g) Byte offsets in tests: é is 2 bytes; compute offsets with str::find, never by hand. (h) clippy pedantic rejects assert!(x.is_empty()) (use assert_eq!(x, [])), single-character binding clusters, a as f64 casts of usize, (a + b) / 2.0 (use f64::midpoint), by-value params that are not consumed, and format! appended to a String (use write!). Run clippy after every module, not only at the end.
  • Smallest working design. No unrequested abstractions, no extra features, no extra files except tests and fixtures. Existing tests in the crate may be kept.
  • Verify with (use these exact commands): cargo test -p notescraft-<name> and cargo clippy -p notescraft-<name> --all-targets -- -D warnings and cargo fmt -p notescraft-<name>. Fix every failure at the root cause; never weaken a test or add an allow to pass.
  • Do NOT run git commit, git add, or touch git state. Do not run commands outside your worktree.
  • Final report (max 15 lines): what is implemented, the public API (signatures), test counts, anything skipped or any dependency you needed but did not have.

If your crate already contains files from an earlier attempt, read them first, keep what is correct and finish the task; do not start over.

YOUR TASK: