Skip to content

Feature Request: Per-Chat Working Directory (cwdOverrides) #14

@adam91holt

Description

@adam91holt

Summary

Allow different chats to use different working directories, so each chat can have its own CLAUDE.md with specific instructions and tool configurations.

Config Schema Addition

In config.ts:

cwdOverrides?: Record<string, string>; // Per-sender/group cwd overrides
contacts?: Record<string, string>;     // Phone number to display name mapping

With zod:

cwdOverrides: z.record(z.string(), z.string()).optional(),
contacts: z.record(z.string(), z.string()).optional(),

Example Config

{
  "cwdOverrides": {
    "+1234567890": "/home/user/chats/personal",
    "+0987654321": "/home/user/chats/work", 
    "[email protected]": "/home/user/chats/project-alpha"
  },
  "contacts": {
    "+1234567890": "Alice",
    "+0987654321": "Bob"
  }
}

Implementation in reply.ts

const cwdOverrides = cfg.cwdOverrides ?? {};
const customCwd = sessionKey ? cwdOverrides[sessionKey] : undefined;
const commandReply = {
  ...reply,
  command: reply.command,
  mode: "command" as const,
  cwd: customCwd ?? reply.cwd,
};

Directory Structure

Each chat directory contains its own CLAUDE.md with chat-specific instructions and tool configurations:

/home/user/chats/
├── personal/
│   └── CLAUDE.md    # Personal assistant + personal MCP tools
├── work/
│   └── CLAUDE.md    # Work instructions + work MCP tools
└── project-alpha/
    └── CLAUDE.md    # Project context + project MCP tools

Example CLAUDE.md with Per-Chat MCP Tools

Each chat's CLAUDE.md can document its own MCP server configuration. For example, a project group chat might have:

# Project Alpha - AI Assistant

You are an assistant for the Project Alpha team.

## MCP Tools

This chat has access to project-specific tools via mcporter:

### List Available Tools
```bash
MCPORTER_CONFIG=~/config/mcporter-chats/project-alpha.json mcporter list

Query Project Database

MCPORTER_CONFIG=~/config/mcporter-chats/project-alpha.json mcporter call 'postgres.query(sql: "SELECT * FROM tasks")'

Browse & Screenshot

MCPORTER_CONFIG=~/config/mcporter-chats/project-alpha.json mcporter call 'chrome-devtools.navigate(url: "https://example.com")'

With a corresponding mcporter config at `~/config/mcporter-chats/project-alpha.json`:

```json
{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://..."]
    },
    "chrome-devtools": {
      "command": "npx", 
      "args": ["-y", "chrome-devtools-mcp@latest", "--headless"]
    }
  }
}

Use Case

Running a multi-purpose AI assistant where:

  • Personal chats have personal tools (spotify, home automation)
  • Work chats have work tools (email, calendar, CRM)
  • Project group chats have project-specific tools (databases, deployment)
  • Each chat has tailored instructions via its own CLAUDE.md

Happy to contribute a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions