# Noridoc: plugin

Path: @/

### Overview

Claude Code plugin package providing comprehensive integration with the Nori Profiles system through a directory-based profile system. Each profile is a complete, self-contained configuration with its own CLAUDE.md instructions, skills, subagents, and slash commands. The installer CLI manages profile installation and switching, while backend API tools enable paid tier knowledge management features.

### How it fits into the larger codebase

This package is a complete Claude Code plugin that installs multiple components to enhance Claude's capabilities. The nori-ai installer CLI (defined in @/package.json bin) prompts users to select a profile, then installs that profile's complete configuration to ~/.claude/. Profiles are stored in @/src/cli/features/claude-code/profiles/config/ as directory structures containing CLAUDE.md, skills/, subagents/, and slashcommands/ subdirectories. The `features/` directory is organized by agent type (currently `claude-code/`), allowing future expansion to support other agentic tools. Built-in profiles include senior-swe (default), amol, and product-manager. The installer copies the selected profile directory to ~/.claude/profiles/ (making it the source of truth for future installs), then feature loaders read from ~/.claude/profiles/ to install skills to ~/.claude/skills/, subagents to ~/.claude/subagents/, slash commands to ~/.claude/slash-commands/, and generate CLAUDE.md by combining the profile's base instructions with a dynamically-generated skills list. For paid tier users, profiles can include paid skills that communicate with @/server via the API client in @/src/api.

### Core Implementation

The src directory contains three main areas: installer (CLI for installation and feature loaders), api (backend client for paid features), and providers (shared authentication providers like Firebase). The package.json defines the nori-ai bin executable that runs the installer. The build process (@/scripts/build.sh) compiles TypeScript, copies profile directories (CRITICAL: must mkdir -p and cp config directories or installer fails with ENOENT), sets permissions, and injects version strings. The publish process uses an interactive prepublish script (@/scripts/prepublish.sh) that prompts the user whether to generate release notes; if yes, it invokes Claude Code headless CLI (`claude -p`) to analyze git commits since the last version tag and update @/release-notes.txt following instructions in @/release-notes-update.md, then prompts whether to commit the changes (declining aborts publish with exit 1). The installer flow: (1) display banner and prompt for credentials, (2) determine install mode (free/paid) from credentials, (3) run profiles loader to copy all profile directories to ~/.claude/profiles/, (4) prompt for profile selection (reads from ~/.claude/profiles/), (5) save config with selected profile name to ~/nori-config.json, (6) run remaining feature loaders which all read from ~/.claude/profiles/{selectedProfile}/. The profiles loader (runs first before profile selection) copies all built-in profile directories from @/src/cli/features/claude-code/profiles/config/ to ~/.claude/profiles/, making ~/.claude/profiles/ the single source of truth. The claudemd loader reads the selected profile's CLAUDE.md, generates a skills list by globbing the profile's skills/ directory for SKILL.md files, extracts frontmatter metadata (name, description) from each skill, strips "paid-" prefixes to match installation paths, and embeds the complete skills list in the managed block. The skills, subagents, and slashcommands loaders copy files from ~/.claude/profiles/{profileName}/{skills|subagents|slashcommands}/ to their respective ~/.claude/ installation directories. The statusline loader installs a bash script that displays git branch, profile name (from ~/nori-config.json), token usage, cost, and Nori branding.

Testing infrastructure includes unit tests in @/tests (Vitest-based, run on every commit) and integration tests in @/nori-tests (markdown specifications executed by external nori-tests CLI in Docker, run selectively pre-release).

### Things to Know

The package is published to npm as nori-ai and installed globally. The directory-based profile system replaced the old JSON-based preference customization system in PR #197, deleting 8,296 lines including base-instructions.md and all preference-based CLAUDE.md generation. Profiles are now complete, self-contained configurations that can be copied and modified by users. The installer is idempotent - re-running it updates built-in profiles but preserves custom user profiles. Profile switching via `npx nori-ai@latest switch-profile` or `/nori-switch-profile` slash command preserves auth credentials while updating the selected profile, then re-runs installation non-interactively. The profile architecture fix in commit 70da534 made ~/.claude/profiles/ the source of truth - all feature loaders now read from there instead of the npx package location, enabling users to create and modify custom profiles. Skills are discovered at installation time via glob pattern \*\*/SKILL.md, so adding new skills to a profile requires re-running installation to regenerate the CLAUDE.md skills list. Paid skills (paid-memorize, paid-recall) are bundled TypeScript executables that call @/src/api methods which connect to @/server endpoints. The API client uses Firebase authentication via @/src/providers/firebase.ts, which provides a singleton FirebaseProvider for credential management and token caching. The statusline displays the active profile name (added in commit 5da74b7) alongside git branch, cost, and token metrics. Changes to CLAUDE.md take effect in new conversations without requiring a Claude Code restart, but profile switching triggers a restart to fully reload the configuration. The plugin architecture enables modular installation where free users get local workflow enhancements while paid users additionally get backend integration for knowledge persistence and retrieval. The prepublishOnly hook (@/scripts/prepublish.sh) runs only on `npm publish` (not on `npm install`) and is interactive - it prompts whether to generate release notes (using Claude headless mode if yes), then prompts whether to commit the changes (aborting publish if declined); this requires a tty and cannot run headlessly in CI.

Created and maintained by Nori.
