Skip to content

Conversation

@piersolenski
Copy link

@piersolenski piersolenski commented Jan 23, 2026

Summary

Adds a cwd option to sidekick.cli.send(), sidekick.cli.prompt(), and sidekick.cli.render() that allows overriding the working directory used when resolving context variables like {file} and {position}.

Use Case

When working in nested project directories (e.g., monorepos or related projects in a parent folder), it's useful to send file context relative to the parent directory rather than the current project root. This allows AI tools to understand the broader project structure.

Changes

  • Added optional cwd field to sidekick.cli.Send and sidekick.cli.PromptOpts
  • Updated Context.get() to accept optional cwd parameter
  • Enhanced path normalization in location.lua to handle custom cwd correctly
  • Backward compatible: defaults to current working directory when not specified

Example Usage

-- Send file with parent directory as context root
require("sidekick.cli").send({
  msg = "{file}",
  cwd = vim.fn.fnamemodify(vim.fn.getcwd(0), ":h")
})

Allow passing `cwd` option to `send()` to override the working directory
used for path resolution. This enables "parent mode" where Claude Code
runs from a parent directory while correctly resolving file paths.

All placeholders ({file}, {position}, {diagnostics}, etc.) now work
correctly when a custom cwd is provided.
@github-actions github-actions bot added the size/l Large PR (<100 lines changed) label Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/l Large PR (<100 lines changed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant