Skip to content

Monorepo support: hooks fail when running aspens in a subdirectory #38

@mvoutov

Description

@mvoutov

Command

aspens doc init

What happened?

When running aspens doc init from a subdirectory of a monorepo
(e.g. repo/backend/), docs and hooks are generated correctly in
backend/.claude/. However:

  1. Hook paths break — settings.json uses
    $CLAUDE_PROJECT_DIR/.claude/hooks/..., but Claude Code sets
    CLAUDE_PROJECT_DIR to the git root (e.g. repo/), not the cwd
    where claude was launched. So the hooks resolve to
    repo/.claude/hooks/... instead of repo/backend/.claude/hooks/...,
    causing UserPromptSubmit hook error on every prompt.
  2. aspens doc sync fails — Running aspens doc sync --install-hook
    from the subdirectory returns Error: Not a git repository
    because .git/ lives at the parent.

Environment:

  • Monorepo: tutor/ (git root) with tutor/backend/ and
    tutor/frontend/ as separate projects
  • aspens v0.6.0
  • Claude Code on macOS

Workaround:
Replace $CLAUDE_PROJECT_DIR with a hardcoded absolute path or the
subdirectory-relative path in settings.json.

What did you expect?

Expected behavior:

  • Hook paths should account for subdirectory offset from git root
    (e.g. $CLAUDE_PROJECT_DIR/backend/.claude/hooks/...)
  • aspens doc sync should walk up to find .git/ or accept a
    --git-root flag

Steps to reproduce

No response

Node.js version

No response

OS

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions