claudemd

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package claudemd loads CLAUDE.md instruction files from the project directory hierarchy and injects them into the agent system prompt.

Load order (mirrors utils/claudemd.ts):

  1. User global: ~/.claude/CLAUDE.md and ~/.claude/rules/*.md
  2. Project: CLAUDE.md, .claude/CLAUDE.md, .claude/rules/*.md discovered by walking from cwd up to filesystem root (closer to cwd = higher priority = loaded later)
  3. Local private: CLAUDE.local.md (gitignored, per-directory)

Within each directory, files closer to cwd override files from parents. @include directives are resolved recursively with circular-reference protection.

Index

Constants

View Source
const MaxCharCount = 40000

MaxCharCount is the recommended max character count for a single memory file. Files larger than this are truncated with a warning. Mirrors TS constant.

Variables

This section is empty.

Functions

func BuildPrompt

func BuildPrompt(files []File) string

BuildPrompt builds the system-prompt text block from loaded CLAUDE.md files. Returns empty string if no files were loaded.

Types

type File

type File struct {
	Path    string
	Content string
	Type    MemoryType
}

File is one loaded CLAUDE.md file.

func Load

func Load(cwd string) ([]File, error)

Load reads all applicable CLAUDE.md files for cwd and returns them in priority order (global first, local project last = highest priority).

type MemoryType

type MemoryType int

MemoryType identifies where a file came from.

const (
	TypeUser    MemoryType = iota // ~/.claude/CLAUDE.md
	TypeProject                   // CLAUDE.md or .claude/CLAUDE.md in project tree
	TypeLocal                     // CLAUDE.local.md (private, gitignored)
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL