agentleFS
VigtuVigtu/docmole/tests/CLAUDE.md

docmole / tests

CLAUDE.md18 starsChanged 10 months agoMITView on GitHub

Rule: One test file per source module. Don't create embedded.test.ts if tests belong in config.test.ts.

  • Reads credentials
  • In this repositoryOne other file it gives its agents.

The file

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

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    What bug would this catch?: If none, skip it.

    line 64
  2. Distinctive:

    Is this testing MY code or a library?: Only test your code.

    line 65

≈ “Common” is an estimate: at least 1 in 5 of the 26,980 CLAUDE.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
CLAUDE.md

Test Guidelines

File Organization

tests/
├── config.test.ts      # src/config/* (project config, loader)
├── mintlify-api.test.ts # src/backends/mintlify.ts
├── embedded.test.ts    # src/backends/embedded/*
└── <module>.test.ts    # One file per major module

Rule: One test file per source module. Don't create embedded.test.ts if tests belong in config.test.ts.

What Makes a Test Useful

Good Tests (Keep)

// 1. Integration with real systems (LanceDB, APIs)
test("persists data across instances", async () => {
  const kb1 = await createKnowledge(path, embedder);
  await kb1.addDocument({ name: "doc", content: "test" });
  await kb1.close();

  const kb2 = await createKnowledge(path, embedder);
  expect(await kb2.countDocuments()).toBe(1); // Real persistence!
});

// 2. Business logic that can fail
test("deduplicates by source URL (max 2 chunks)", async () => {
  // Tests actual deduplication logic, not just "it runs"
});

// 3. Error handling
test("handles errors gracefully", async () => {
  const mock = { retrieve: async () => { throw new Error("fail"); } };
  const result = await tool.execute({ query: "test" });
  expect(result.success).toBe(false); // Doesn't crash!
});

Bad Tests (Remove)

// 1. Testing hardcoded values
test("default model is gpt-4o-mini", () => {
  expect(config.model).toBe("gpt-4o-mini"); // So what? If it changes, is that a bug?
});

// 2. String matching on generated text
test("instructions contain 'agent'", () => {
  expect(instructions).toContain("agent"); // Superficial
});

// 3. Testing library behavior
test("LanceDB returns array", () => {
  expect(Array.isArray(results)).toBe(true); // Test your code, not theirs
});

Before Writing a Test, Ask

  1. What bug would this catch? If none, skip it.
  2. Is this testing MY code or a library? Only test your code.
  3. If this fails, is it actually broken? Changing defaults isn't a bug.

Integration Tests

// Skip if dependencies unavailable
const hasOpenAIKey = !!process.env.OPENAI_API_KEY;

describe.skipIf(!hasOpenAIKey)("OpenAI Integration", () => {
  setDefaultTimeout(60_000); // API calls are slow
  // ...
});

Mocking

// Type-safe mocks
type MockKnowledge = Pick<EmbeddedKnowledge, "search">;

const mock: MockKnowledge = {
  search: async () => [{ name: "doc", content: "test", metadata: {} }],
};

// Cast safely
const retriever = new Retriever(mock as unknown as EmbeddedKnowledge);

Naming

// Describe WHAT it does, not HOW
test("deduplicates by source URL (max 2 chunks per URL)") // Good
test("filters results array with map and reduce")          // Bad

// Test files match source
// src/backends/embedded/* → tests/embedded.test.ts
// src/config/*           → tests/config.test.ts

Running Tests

bun test                          # All tests
bun test tests/embedded.test.ts   # Single file
bun test --watch                  # Watch mode

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.