agentleFS
saadnvd1saadnvd1/aTerm/CLAUDE.md

aTerm

CLAUDE.md19 starsChanged 10 months agoMITView on GitHub

Agent-focused terminal workspace built with Tauri (Rust) + React + xterm.js. VSCode terminal (~/dev/ascent/src/vs/workbench/contrib/terminal/) — gold standard for xterm.js usage: - browser/xterm/xtermTerminal.ts — xterm.js wrapper, renderer selection, addon management - browser/terminalInstance.ts — write path, data segmentation, flush handling - browser/terminalProcessManager.ts — flow control, ack batching, process lifecycle - common/terminalConfiguration.ts — all terminal config options codemirror-rich-markdoc (github.com/segphault/codemirror-rich-markdoc) — reference for CM6 rich markdown editing (Obsidian-style): - src/richEdit.ts — decoration plugin pattern: collect Range<Decoration>[], use Decoration.set(widgets) for auto-sorting - src/renderBlock.ts — block…

The file

We split this CLAUDE.md into the rules it gives an agent

7 rules. About 0 are common, 4 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Commit form: Write commit message, commit, or commit & push

    line 85
  2. Very specific:

    Use cn() for conditional classes: cn("base", condition && "active")

    line 167
  3. Distinctive:

    Prefer shadcn components over custom implementations

    line 168
  4. Very specific:

    Use semantic color names (bg-primary not bg-purple-500)

    line 169
  5. Very specific:

    Use semantic z-index names (z-modal not z-50)

    line 170
  6. Distinctive:

    Keep tightly coupled logic in one file (e.g., a component + its small helpers)

    line 202
  7. Distinctive:

    Don't split just to hit 300 lines if it hurts readability

    line 203

≈ “Common” is an estimate: at least 1 in 5 of the 29,248 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

aTerm

Agent-focused terminal workspace built with Tauri (Rust) + React + xterm.js.

Reference Implementations

VSCode terminal (~/dev/ascent/src/vs/workbench/contrib/terminal/) — gold standard for xterm.js usage:

  • browser/xterm/xtermTerminal.ts — xterm.js wrapper, renderer selection, addon management
  • browser/terminalInstance.ts — write path, data segmentation, flush handling
  • browser/terminalProcessManager.ts — flow control, ack batching, process lifecycle
  • common/terminalConfiguration.ts — all terminal config options

codemirror-rich-markdoc (github.com/segphault/codemirror-rich-markdoc) — reference for CM6 rich markdown editing (Obsidian-style):

  • src/richEdit.ts — decoration plugin pattern: collect Range<Decoration>[], use Decoration.set(widgets) for auto-sorting
  • src/renderBlock.ts — block widget replacements for complex elements
  • Uses cm-markdoc-hidden CSS class pattern for hiding syntax characters

Architecture

src/                        # React frontend
├── components/
│   ├── git/                   # Git panel components
│   │   ├── GitPane.tsx           # Main git panel container
│   │   ├── GitPanelTabs.tsx      # Changes/History tab switcher
│   │   ├── FileChanges.tsx       # Staged/Unstaged/Untracked sections
│   │   ├── FileItem.tsx          # File row with stage/unstage actions
│   │   ├── DiffViewer.tsx        # Unified diff display
│   │   ├── CommitForm.tsx        # Commit message + buttons
│   │   ├── CommitHistory.tsx     # Scrollable commit list
│   │   └── CommitItem.tsx        # Expandable commit with files
│   ├── agent-config/              # Agent config pane components
│   │   ├── AgentConfigPane.tsx       # Main pane container with editor
│   │   └── AgentConfigSidebar.tsx    # Sidebar listing config files by agent
│   ├── AddProjectModal.tsx    # Project creation (browse/clone)
│   ├── ProjectSidebar.tsx     # Left sidebar with project list
│   ├── SettingsModal.tsx      # Settings with tabs (Appearance, Profiles, Layouts)
│   ├── TerminalLayout.tsx     # Pane grid with resize, context menu, maximize
│   └── TerminalPane.tsx       # Individual terminal (xterm.js wrapper)
├── context/
│   └── ThemeContext.tsx       # Theme provider with localStorage persistence
├── lib/
│   ├── agent-config.ts        # Agent config file definitions per tool
│   ├── config.ts              # AppConfig, ProjectConfig types
│   ├── git.ts                 # Git types (GitStatus, GitFile, CommitSummary)
│   ├── layouts.ts             # Layout, LayoutRow, LayoutPane types
│   ├── profiles.ts            # TerminalProfile type, defaults
│   ├── providers.ts           # AI provider registry
│   └── themes.ts              # Theme definitions
├── App.tsx                    # Main app with project/terminal state
└── main.tsx                   # Entry point

src-tauri/src/
└── lib.rs                     # Rust backend (PTY, config, git, filesystem)

Key Patterns

Terminal Persistence

Terminals stay alive when switching projects. App.tsx tracks openedProjects Set and renders all opened projects, hiding inactive ones with display: none.

Pane Maximize

Uses CSS positioning, not conditional rendering. Maximized pane gets position: absolute to cover container, others get visibility: hidden. No unmounting.

Keyboard Shortcuts in Terminal

xterm.js captures keyboard events. Use onKeyDownCapture on container div to intercept before xterm. Store callbacks in refs to avoid stale closures.

Event Handlers Across Projects

Global event handlers (Cmd+W via Tauri listen, Cmd+D via window.addEventListener) must use refs for isProjectActive, focusedPaneId, and layout — not closure values. Multiple TerminalLayout instances are mounted simultaneously (hidden via CSS), so stale closures can execute shortcuts in the wrong project. Pattern: register listener once ([] deps), read ref.current inside callback.

Smooth Output (PTY Write Batching)

PtyWriteBatcher in terminal-pane/pty-write-batcher.ts coalesces rapid PTY output into one terminal.write() per animation frame. Mitigates Claude Code's screen redraw flicker (anthropics/claude-code#367). Gated behind Settings > Appearance > Smooth Output. Uses a module-level smoothOutputEnabled flag (set by App.tsx, read by TerminalPane) to avoid prop drilling.

Profile/Layout System

  • Profiles: Reusable terminal configs (id, name, command, color, type)
    • type: "terminal" (default) - xterm.js terminal pane
    • type: "git" - Git panel with status, staging, commits
  • Layouts: Pane arrangements with rows containing panes, each referencing a profile
  • Projects: Reference a layout by ID

GitPane

Non-terminal pane type for git operations. Features:

  • Changes tab: View staged/unstaged/untracked files, stage/unstage, view diffs
  • History tab: Browse commit history, expand to see changed files, view diffs
  • Commit form: Write commit message, commit, or commit & push
  • Status auto-polls every 5 seconds

AgentConfigPane

Dedicated pane for viewing/editing AI agent config files (CLAUDE.md, AGENTS.md, .cursorrules, etc.). Toggle via Cmd+Shift+A or sidebar bot icon. Features:

  • Sidebar: Config files grouped by agent (Claude, Codex, Cursor, Copilot, etc.) with existence indicators
  • Create: One-click creation of missing config files with sensible defaults
  • Editor: Reuses MarkdownEditor for .md files, CodeEditor for .json — same editors as EditorPane
  • Config file definitions live in src/lib/agent-config.ts (easy to extend with new agents/files)

Config

Stored in ~/.config/aterm/config.json as flexible JSON. Rust backend uses serde_json::Value, frontend defines schema.

interface AppConfig {
  projects: ProjectConfig[];
  profiles: TerminalProfile[];
  layouts: Layout[];
  defaultProvider: ProviderId;
  defaultLayoutId: string;
}

Commands

npm run tauri dev      # Development
npm run tauri build    # Production build

Standards

  • Conventional commits (feat, fix, docs, etc.)
  • TypeScript strict mode
  • Tailwind CSS + shadcn/ui for styling (following LumifyHub conventions)
  • Always run npx tsc --noEmit after finishing a feature to catch type errors before committing

Design System

Uses Tailwind CSS + shadcn/ui, following the same conventions as LumifyHub:

Structure

src/
├── components/ui/        # shadcn components (Button, Dialog, etc.)
├── lib/utils.ts          # cn() utility for class merging
└── styles/globals.css    # Tailwind + CSS variables

Adding shadcn components

npx shadcn@latest add button dialog dropdown-menu

CSS Variables (HSL format)

Themes are defined in globals.css with CSS variables:

  • --background, --foreground - Base colors
  • --primary, --secondary, --muted, --accent - UI colors
  • --destructive - Danger/error states
  • --border, --input, --ring - Form elements

Theme Switching

Set data-theme attribute on <html>:

  • midnight (default), dracula, nord, tokyoNight, gruvbox, oneDark, catppuccin, monokai, solarized, rosePine

Z-Index Scale

Semantic z-index layers defined in tailwind.config.ts. Never use raw z-index values (z-10, z-50, etc.) — always use semantic names.

ClassValueUsage
z-sticky100Sticky headers, fixed sidebars
z-dropdown200Dropdown menus, maximized panes
z-popover300Popovers, context menus, floating panels
z-popover-nested400Selects inside popovers
z-modal500Modal dialogs, overlays
z-modal-nested600Selects/dropdowns inside modals
z-toast700Toast notifications
z-tooltip800Tooltips (highest regular layer)
z-max9999Escape hatch for edge cases

Conventions (from LumifyHub)

  • Use cn() for conditional classes: cn("base", condition && "active")
  • Prefer shadcn components over custom implementations
  • Use semantic color names (bg-primary not bg-purple-500)
  • Use semantic z-index names (z-modal not z-50)

File Size Rules

Target: Keep files under 300 lines. Large files are harder to understand, test, and maintain.

How to Split Components

  1. Extract sub-components into sibling files:
    components/
    ├── TerminalLayout.tsx        # Main orchestrator (~200 lines)
    ├── terminal-layout/          # Sub-components
    │   ├── SortablePane.tsx
    │   ├── RowWithResizer.tsx
    │   └── DropZones.tsx
  2. Extract hooks for complex state/effects:
    hooks/
    ├── useTerminalInstance.ts    # xterm.js lifecycle
    ├── usePaneResize.ts          # Drag resize logic
  3. Extract types into separate files when shared:
    lib/
    ├── types/terminal.ts

What Stays Together

  • Keep tightly coupled logic in one file (e.g., a component + its small helpers)
  • Don't split just to hit 300 lines if it hurts readability
  • Data files (themes.ts) can be longer - they're config, not logic

Current Violations (to fix)

  • TerminalLayout.tsx (1028 lines) → Split pane/row components
  • SettingsModal.tsx (935 lines) → Split tab contents
  • TerminalPane.tsx (690 lines) → Extract hooks
  • AddProjectModal.tsx (528 lines) → Split clone/browse sections
  • App.tsx (452 lines) → Extract handlers into hooks

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.