Give Claude extra directories and prompt instructions
cli flags & headless
// what it does
--add-dir lets Claude read and edit files outside the working directory (for example a sibling library), while --append-system-prompt adds instructions on top of the default system prompt without discarding Claude's built-in behavior. Prefer --append-system-prompt over --system-prompt, which replaces the entire prompt and drops Claude's default capabilities.
// shell
$ claude --add-dir ../shared-lib ../api$ claude --append-system-prompt "Always use TypeScript and 2-space indentation"// gotcha
By default CLAUDE.md files in --add-dir directories are not loaded; set CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1 if you want their memory too. --append-system-prompt must be passed on every invocation, so it suits scripts more than interactive use.