agentleFS
dearlordylorddearlordylord/huly-mcp/CLAUDE.md

huly-mcp

CLAUDE.md64 starsChanged 2 days agoMITView on GitHub

Rules are reflexive: when adding a rule, apply it immediately. Keep or introduce legacy behavior only for a demonstrated current requirement. Before preserving a compatibility path, name the concrete supported consumer that needs it, verify that need, and test whether an update or ordinary client restart resolves it. Apply especially strict scrutiny to every legacy proposal; hypothetical consumers, stale specifications and "just in case" are insufficient. When no current requirement remains, remove the legacy path and update its specification and…

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

The file

Show its rules and text

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

20 rules. About 0 are common, 8 are distinctive, and 12 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 12

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When setting up a new project from this one, ALL of these components must be copied:

    line 16
  2. Very specific:

    Use pnpm, not npm. Prefer package.json scripts over raw commands (e.g., pnpm typecheck not pnpm tsc --noEmit).

    line 36
  3. Distinctive:

    Run relevant integration scenarios against local Huly (Docker) when needed to prove changed behavior.

    line 45
  4. Very specific:

    When running integration tests from this container, source .env.local and override the URL for the command:

    line 57
  5. Very specific:

    If the container has instead been attached to the Huly Docker network, the NODE_OPTIONS="-r ./scripts/container-patch.cjs" path documented …

    line 67
  6. Distinctive:

    Use names that preserve meaning:

    line 98
  7. Very specific:

    Avoid validateX when the function returns a refined value.

    line 103
  8. Distinctive:

    Avoid top-level side effects except in true entrypoint/bootstrap files.

    line 119
  9. Distinctive:

    IMPORTANT: Always consult the project-pinned Effect references before writing Effect code.

    line 135
  10. Very specific:

    Run effect-solutions list to see available guides

    line 137
  11. Very specific:

    Run effect-solutions show <topic>...

    line 138
  12. Very specific:

    Read docs/mcps/effect.md for the authoritative lookup order

    line 139
  13. Very specific:

    Read node_modules/effect/AGENTS.md for guidance shipped with the exact installed package

    line 140
  14. Very specific:

    Search .reference/effect-v4.0.0/ for exact target implementations and declarations

    line 141
  15. Distinctive:

    Use the installed 4.0.0 declarations and the smallest relevant pinned source region.

    line 147
  16. Distinctive:

    Search examples for real usage patterns when implementing MCP tools.

    line 163
  17. Distinctive:

    Use short timeouts (5s) - MCP keeps connection open.

    line 179
  18. Very specific:

    After creating a secondary worktree, run bash scripts/bootstrap-worktree.sh from that worktree.

    line 186
  19. Very specific:

    Before deleting a worktree or branch, always check for uncommitted changes (git status) and unmerged commits (git log <branch> --not …

    line 188
  20. Very specific:

    After merging a worktree branch, verify the merge commit actually landed (git log --oneline -1) and that CODE_SMELLS.md updates are staged …

    line 190

≈ “Common” is an estimate: at least 1 in 5 of the 29,248 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

Project Instructions

Rules are reflexive: when adding a rule, apply it immediately.

Legacy requires evidence

Keep or introduce legacy behavior only for a demonstrated current requirement. Before preserving a compatibility path, name the concrete supported consumer that needs it, verify that need, and test whether an update or ordinary client restart resolves it. Apply especially strict scrutiny to every legacy proposal; hypothetical consumers, stale specifications and "just in case" are insufficient. When no current requirement remains, remove the legacy path and update its specification and tests together.

Design Principle: LLM-First API

The primary consumer of this MCP server is an LLM coding agent, not a human developer. All design decisions — tool naming, parameter shapes, description writing, error messages, defaults — must optimize for LLM comprehension and single-call correctness. Prefer fewer tool calls with clear semantics over multi-step protocols. Auto-resolve identifiers where possible rather than requiring the caller to decompose them. Write tool descriptions as if the reader has no documentation beyond the schema and the description string.

Project Harness (COPY TO NEW PROJECTS)

This project's quality harness is the reference template for new TypeScript/Effect projects. When setting up a new project from this one, ALL of these components must be copied:

  1. Test coverage (vitest.config.ts): v8 provider, 99% thresholds, test:coverage script. Requires @vitest/coverage-v8 dev dep.
  2. Code duplication (.jscpd.json + jscpd src in lint script): threshold 2%, console reporter.
  3. Circular dependency detection (dpdm --exit-code circular:1 in circular, wired into check-all): catches import cycles while ignoring type-only dependencies.
  4. Cyclomatic complexity (oxlint.complexity.json, wired into check-all): The lint gate caps classic McCabe complexity at 8 for all production TypeScript, with no suppression baseline.
  5. Pre-commit hooks (.husky/pre-commit): lint-staged + gitleaks secrets scanning.
  6. check-all (pnpm check-all): build + TypeScript 7 and Effect diagnostics + circular + complexity + lint (Oxlint + jscpd) + test. Preserve this full gate; choose its execution cadence according to Verification below.
  7. Effect testing (@effect/vitest): Effect-aware test runner integration.
  8. Effect language-service diagnostics (effect-tsgo diagnostics --project tsconfig.json --strict --severity error,warning): run through @effect/tsgo as part of typecheck without patching TypeScript; Effect errors and warnings fail the gate.
  9. Oxc lint and formatting (.oxlintrc.json + oxlint-tsgolint + dprint.json with dprint-plugin-oxc): type-aware Oxlint plus Oxc formatting through dprint, without the ESLint runtime. Project-only architectural rules live in scripts/oxlint-project-plugin.mjs.
  10. Property test placement: fast-check/property-based tests live in *.property.test.ts files only. Oxlint must reject fast-check imports in ordinary *.test.ts files so generated tests stay discoverable and reviewable as a distinct test class.
  11. Strict TypeScript 7 baseline (@typescript/native + tsconfig.json): project typechecking uses TypeScript 7 with strict, exactOptionalPropertyTypes, noUncheckedIndexedAccess, noImplicitOverride, and noFallthroughCasesInSwitch. The typescript-compiler-api alias is TypeScript 5 used only by the README AST generator because the native TypeScript 7 package does not expose the JavaScript compiler API.

Missing any of these degrades the quality gate. Coverage and duplication detection are especially easy to forget.

Line-count limits are architecture signals. If max-lines fails, split the file along a coherent module boundary; do not shave, compress, alias, or otherwise game individual lines just to get under the threshold.

Package Manager

Use pnpm, not npm. Prefer package.json scripts over raw commands (e.g., pnpm typecheck not pnpm tsc --noEmit).

Verification

For movement qualification retries, follow verified quality receipt reuse before repeating preparation. For a multi-suite campaign or a completion report, use campaign policy and evidence publication.

Prefer focused local verification during implementation: run the affected tests and checks, and broaden only when a concrete failure or cross-cutting change requires it. Do not routinely run pnpm check-all or whole integration suites after each increment. Keep full qualification for the coherent final candidate or release, subject to the user's current instructions. Preserve all thresholds and diagnostics.

Run relevant integration scenarios against local Huly (Docker) when needed to prove changed behavior; follow the current campaign cadence rather than repeating the whole suite. Do not defer authorized verification to the user. See INTEGRATION_TESTING.md for test patterns and CLAUDE.local.md for credentials/setup.

For movement qualification and failure diagnosis, follow bounded movement qualification.

Local Huly from This Container

This checkout normally runs inside a container. .env.local is shared with host-side workflows and may contain HULY_URL=http://localhost:8087; inside the container that localhost is the container itself, not the host Huly nginx. In this environment:

  • host.docker.internal resolves and reaches local Huly.
  • docker.host.local does not resolve reliably.
  • localhost:8087 is not reachable from the container.

When running integration tests from this container, source .env.local and override the URL for the command:

pnpm build
set -a && source .env.local && set +a
HULY_URL="${HULY_URL/localhost/host.docker.internal}" bash scripts/integration_test_full.sh

Integration preflight rejects cross-platform node_modules before fixture writes.

If the container has instead been attached to the Huly Docker network, the NODE_OPTIONS="-r ./scripts/container-patch.cjs" path documented in INTEGRATION_TESTING.md is also valid.

Type Safety

Type casts (as T) are a sin. Avoid them. All data crossing system boundaries (APIs etc.) must be strongly typed with Effect Schema.

Schema as Source of Truth at I/O Boundaries

At every I/O boundary, Effect Schema owns the payload contract. Examples include MCP tool input/output, HTTP requests and responses, database records, SDK DTOs, files, environment/config, and serialized cache/storage data.

For boundary payloads, define the schema first and derive the TypeScript type from it:

export const FooSchema = Schema.Struct({ ... })
export type Foo = Schema.Schema.Type<typeof FooSchema>

This keeps the runtime codec, JSON schema, parser/encoder, and TypeScript type tied to one source of truth.

Hand-written interfaces are reserved for internal-only ports, services, and implementation details that are not parsed, encoded, serialized, or exposed across an I/O boundary. When a boundary-adjacent type is intentionally not schema-derived, leave a short comment explaining why the schema is not the owner of that shape.

Optional Boundary Fields

With exactOptionalPropertyTypes, handwritten field?: T | undefined usually means the code is modeling Effect Schema's default Schema.optional(T) behavior manually.

For schema-owned payloads, let the schema derive that type. Mappers should usually omit absent output fields rather than materialize explicit undefined values. When explicit undefined is not part of the accepted contract, use Schema.optionalKey(T) for an exact optional field.

Parse, Don't Validate

Boundary code must turn unknown or less-structured input into domain types as early as practical. Do not validate a raw DTO or primitive and then pass the raw value onward; pass the parsed/refined value so downstream code can rely on what was learned.

Use names that preserve meaning:

  • parseX(input) for untrusted or less-structured input that returns a typed value or typed parse error.
  • makeX(...) / createX(...) for smart constructors from already-typed pieces.
  • isX(value): boolean only for true predicates.

Avoid validateX when the function returns a refined value. It parsed something.

Effect Schema is the default boundary parser. Use schemas at system edges and MCP tool boundaries; core/application logic should receive parsed domain input instead of repeatedly revalidating the same facts. Expected parse, domain, authorization, integration, and persistence failures must stay in typed Effect error channels. Throwing/rejected promises are only for defects, framework-required behavior, or startup/bootstrap failures.

Functional Core, Imperative Shell

Keep reusable behavior out of protocol handlers and SDK glue. The functional core contains domain logic, parsers, state transitions, target resolution, projection/mapping decisions, and other deterministic decisions. It should avoid I/O, hidden dependencies, ambient time/randomness, thrown expected failures, and MCP/HTTP/stdin framework concerns.

The imperative shell owns Effect sequencing, Huly SDK calls, storage/network I/O, config loading, telemetry, resource lifetime, and protocol translation. Entrypoints should parse protocol-specific input, call shared modules with parsed domain values, and render protocol-specific output. Do not duplicate business rules in MCP handlers when a shared operation can own them.

Config and Resource Boundaries

Parse configuration at startup or the earliest request boundary into typed config with redacted secret values. Do not read process.env throughout the app. Missing or invalid config is a typed startup/request-boundary failure with useful context.

Secrets such as tokens, passwords, API keys, and credential headers must be wrapped in Redacted at the boundary and unwrapped only inside the adapter that needs the raw value. Do not put raw secrets in errors, logs, traces, snapshots, diagnostics, or tool results.

Avoid top-level side effects except in true entrypoint/bootstrap files. Modules must not start servers, open connections, read env, register handlers, or perform I/O at import time. Resource creation and cleanup should be explicit and owned by bootstrap/imperative-shell code or Effect layers/scopes.

No Test Mocks

Test mocks are banned. Do not use vi.mock, vi.doMock, vi.hoisted, vi.spyOn, vi.stubGlobal, Jest-style jest.mock, or any module-level monkey-patching. If a test needs to substitute behavior, the subject must expose a dependency-injection seam — an Effect Context.Service provided via Layer, or a plain ports argument. Tests then provide a real stub implementation through that seam.

This applies to every side effect, including time. Code that reads the clock must depend on Effect.Clock (or a Clock-like service) rather than calling Date.now(), performance.now(), or new Date() directly. Tests supply a deterministic TestClock or equivalent stub via Layer.provide.

The intent: if a test cannot be written without reaching into another module's internals, that is a design signal — refactor the subject to accept its dependencies explicitly.

Code Review

Code review agents must consult .claude/review-rules.md for project-specific quality gates.

<!-- effect-solutions:start -->

Effect Best Practices

IMPORTANT: Always consult the project-pinned Effect references before writing Effect code.

  1. Run effect-solutions list to see available guides
  2. Run effect-solutions show <topic>... for relevant patterns (supports multiple topics)
  3. Read docs/mcps/effect.md for the authoritative lookup order
  4. Read node_modules/effect/AGENTS.md for guidance shipped with the exact installed package
  5. Search .reference/effect-v4.0.0/ for exact target implementations and declarations

In secondary worktrees, .reference may exist only in the master checkout at /workspace/typescript/hulymcp/.reference. After creating a worktree, run bash scripts/bootstrap-worktree.sh to link ignored local resources (node_modules, .reference, .env.local, CLAUDE.local.md) from the master checkout when available. If effect-solutions is not on PATH, use the pinned references directly. Exact installed package declarations and pinned source override generic or globally installed skill guidance.

Topics: quick-start, project-setup, tsconfig, basics, services-and-layers, data-modeling, error-handling, config, testing, cli.

Use the installed 4.0.0 declarations and the smallest relevant pinned source region. Never guess at Effect patterns.

<!-- effect-solutions:end -->

Huly API Reference

Source: https://github.com/hcengineering/huly-examples/tree/main/platform-api

Local clone: .reference/huly-examples/platform-api/ - examples showing API usage patterns

Keep updated: cd .reference/huly-examples && git pull

Key examples to reference:

  • Issue management: examples/issue-*.ts
  • Document operations: examples/documents/document-*.ts
  • Contact/person handling: examples/person-*.ts

Search examples for real usage patterns when implementing MCP tools.

Huly API Gotchas

Eventual consistency: Huly's client does not see its own writes immediately within the same session. findOne, addCollection (resolves attachedTo ref internally), and other read-after-write patterns will hang or return stale data if the target document was just created.

Query typing: Huly's SDK DocumentQuery<T> permits arbitrary string keys. Use hulyQuery<T>() for new or changed direct client.findAll / client.findOne query object literals, and use StrictDocumentQuery<T> for mutable query builders before passing them through hulyQuery. This catches invented fields such as "blockedBy._id" locally. If a dynamic or intentionally escaped query must bypass this helper, document the Huly behavior being relied on at the call site.

Manual Testing (stdio)

echo '{"jsonrpc":"2.0","method":"server/discover","params":{"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientCapabilities":{},"io.modelcontextprotocol/clientInfo":{"name":"test","version":"1.0"}}},"id":1}
{"jsonrpc":"2.0","method":"tools/call","params":{"name":"list_projects","arguments":{},"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientCapabilities":{},"io.modelcontextprotocol/clientInfo":{"name":"test","version":"1.0"}}},"id":2}' | \
HULY_URL=... HULY_EMAIL=... HULY_PASSWORD=... HULY_WORKSPACE=... timeout 5 node dist/index.cjs

Use short timeouts (5s) - MCP keeps connection open.

Worktrees

Worktrees symlink node_modules and .reference to the main tree. .gitignore must use node_modules and .reference (no trailing slash) — trailing slash only matches directories, not symlinks, so git add . will commit the symlink.

When the checkout or node_modules is shared with another platform (for example, macOS and a Linux container), do not reinstall dependencies in the shared tree. Use an isolated checkout with its own platform-local dependencies for verification. A container reinstall can remove dependencies or replace native binaries while a host release is building. After creating a secondary worktree, run bash scripts/bootstrap-worktree.sh from that worktree. This links ignored local resources from /workspace/typescript/hulymcp, including node_modules, .reference, .env.local, and CLAUDE.local.md, so Effect and Huly reference material remains available outside the master checkout.

Before deleting a worktree or branch, always check for uncommitted changes (git status) and unmerged commits (git log <branch> --not master) first. Never force-delete without verifying all work is integrated.

After merging a worktree branch, verify the merge commit actually landed (git log --oneline -1) and that CODE_SMELLS.md updates are staged — don't leave integration work uncommitted.

Formatting

Formatting is handled by Oxc through dprint-plugin-oxc (included in pnpm lint).

  • pnpm format — auto-format TypeScript files with Oxc
  • pnpm check-format — check formatting without writing

Publishing

Versioning uses Changesets:

  1. npx changeset — describe changes (creates a changeset file)
  2. pnpm local-release — version bump + publish

prepublishOnly runs pnpm check-all automatically before publish.

Package: @firfi/huly-mcp on npm.

Current delivery ownership and validation cadence

The user disabled Dalph and transferred306–311 delivery to the overseer and its implementer/reviewer agents. Do not invoke Dalph or follow its obsolete orchestration instructions. You are not alone in this codebase; do not revert other agents' work. Each implementer owns its assigned worktree. All six issues and all71 criteria remain required.

306 is accepted at200075a4e86c21791130d57277bb252203b403a6.307 is unfinished; retained candidateac782a0c and corrections are in this worktree. Authoritative cached specifications are /tmp/hulymcp-dalph-306-311/issues/305.json through311.json.307 depends on306;308 and309 depend on307 and can run in parallel;310 depends on308/309;311 depends on310. Implement the complete assigned issue, persist through tests and review fixes, and do not return investigation-only work.

Live Huly integration runs ONLY after all six slices are implemented and integrated, per explicit user instruction overriding earlier per-feature scheduling. Author executable MCP/CLI fixtures now, keep every behavioral criterion, and record live evidence as pending final certification. Use focused checks during implementation and fresh Standards/Spec reviews through $code-review; run pnpm check-all on the coherent final candidate. Never weaken coverage thresholds, timeouts, inventory or diagnostics. GOMAXPROCS=2 is a current compiler concurrency experiment; compare actual results and retain all diagnostic checks.

Use Linux-local dependencies. Bootstrap with bash scripts/bootstrap-worktree.sh /tmp/hulymcp-dalph-306-311/retry-repository. Never reinstall dependencies in the canonical Darwin checkout. Consult pinned Effect references. Keep implementation progress and remaining work in the GitHub issues. Add durable design rationale to existing ADRs when needed; routine increments do not create implementation reports or handoff documents. The final combined candidate must pass check-all and the five relevant movement MCP/CLI fixtures under the bounded qualification workflow. All unique concurrency cases remain; unrelated whole-server MCP/full CLI regressions are separate from #305–311 feature completion under the user’s 2026-10-04 process correction. The overseer owns live suite execution.

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.