Skip to content

Comments

feat(agents): add --status flag to display live session info in Claude Code status bar#154

Merged
codemie-ai merged 3 commits intomainfrom
feature/statusline-flag
Feb 20, 2026
Merged

feat(agents): add --status flag to display live session info in Claude Code status bar#154
codemie-ai merged 3 commits intomainfrom
feature/statusline-flag

Conversation

@vadimvlasenko
Copy link
Collaborator

@vadimvlasenko vadimvlasenko commented Feb 20, 2026

Summary

Adds a new --status flag to codemie-claude that enables a live status bar inside Claude Code, showing real-time session info: AI model, current directory, git branch, context window usage, cost, and elapsed time.

Changes

  • New --status CLI flag — added to AgentCLI and wired into the Claude plugin lifecycle
  • Statusline script (codemie-statusline.mjs) — standalone Node.js script deployed to ~/.claude/ at session start; reads Claude Code's JSON hook payload via stdin and renders a two-line status bar with ANSI colors
  • Session lifecycle integrationbeforeRun deploys the script and injects statusLine config into ~/.claude/settings.json; afterRun restores the original settings after the session ends
  • Supported version bumpCLAUDE_SUPPORTED_VERSION updated from 2.1.31 to 2.1.41
  • Unit tests — 13 tests covering beforeRun and afterRun hooks (script deployment, path quoting, settings injection/cleanup, parse error safety, flag idempotency)

Impact

# Enable live status bar for a session
codemie-claude --status

# Status bar shows two lines inside Claude Code:
# [Claude Sonnet 4] 📁 my-project | 🌿 feature/my-branch
# ████████░░ 82% | $0.0142 | ⏱️ 3m 12s
  • No impact on sessions that don't pass --status
  • Settings are restored to their original state after each session
Screenshot 2026-02-20 at 10 50 10

Checklist

  • Self-reviewed
  • Manual testing performed
  • Documentation updated (if needed)
  • No breaking changes (or clearly documented)

…ssues

- Rename CLI flag --statusline → --status and CODEMIE_STATUSLINE → CODEMIE_STATUS
- Convert codemie-statusline.js to codemie-statusline.mjs (ESM, removes require())
- Fix path quoting in statusLine command to handle spaces in home directory
- Fix settings.json data loss: abort injection on JSON parse failure instead of overwriting
- Replace CODEMIE_STATUSLINE_MANAGED env var with module-level flag to avoid subprocess leakage
- Sanitize logger.warn args with sanitizeLogArgs in afterRun cleanup
- Add mkdirSync before copyFileSync in copy-plugins.js to prevent ENOENT in clean builds
- Add 13 unit tests covering beforeRun and afterRun statusline lifecycle hooks

Generated with AI

Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
@vadimvlasenko vadimvlasenko changed the title fix(agents): rename --statusline to --status and fix lifecycle hook issues feat(agents): add --status flag to display live session info in Claude Code status bar Feb 20, 2026
The file is now picked up by the existing recursive cpSync in copy-plugins.js,
removing the redundant copyFiles loop and copyFileSync import.
Update read path in claude.plugin.ts and test constant accordingly.

Generated with AI

Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
Copy link
Collaborator

@8nevil8 8nevil8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review — Approved

Files reviewed: src/agents/core/AgentCLI.ts, src/agents/plugins/claude/claude.plugin.ts, src/agents/plugins/claude/plugin/codemie-statusline.mjs, src/agents/plugins/claude/__tests__/claude.plugin.statusline.test.ts, scripts/copy-plugins.js


Summary

The --status flag implementation is clean, well-scoped, and follows project conventions correctly. The code introduces a live status bar for Claude Code sessions with proper lifecycle management, cross-platform guards, and good error handling. All critical areas pass review.


What was checked

Cross-Platform Compatibility — The chmod call is correctly gated behind process.platform !== 'win32', and path.join() is used consistently throughout. The statusline script itself uses execSync with a stdio: ['pipe', 'pipe', 'ignore'] option that works cross-platform. No hardcoded path separators.

Architecture Adherence — The feature lives entirely within the Claude plugin's lifecycle hooks (beforeRun/afterRun), which is the correct layer for session-scoped setup. No layer violations.

Settings Safety — The beforeRun hook correctly parses settings.json before writing and bails out with a warning on malformed JSON, preventing data loss. The afterRun hook restores original state and handles the no-settings case gracefully.

Module-level flag design — Using statuslineManagedThisSession at module scope (instead of an env var) is the right call — it keeps internal state out of subprocess environments. The flag is reset to false at the start of afterRun, so a second call is correctly a no-op.

SecuritysanitizeLogArgs is used on all logger.warn calls that include path or error context. No credentials or sensitive data are logged.

Error Handling — Uses logger.warn (not logger.error or throw) for non-critical failures like parse errors and cleanup failures, which is appropriate since the status bar is an optional feature. Silent fail in the statusline script itself is correct — crashes must not propagate to Claude Code.

Standalone script justification — The comment in codemie-statusline.mjs explaining why child_process and path are imported directly (the script runs in isolation without the project runtime) is accurate and appreciated.

Previously raised comment — The redundant copyFiles loop flagged by 8nevil8 on scripts/copy-plugins.js has been fully addressed: codemie-statusline.mjs is now in the plugin/ subfolder and is picked up by the existing cpSync, with the copyFiles loop and copyFileSync import removed entirely. Resolved the thread.

Tests — 13 tests cover the meaningful paths: no-op when flag is absent, script deployment, directory creation, path quoting, idempotency on existing statusLine, malformed JSON safety, afterRun cleanup, double-call no-op, and cleanup failure logging. Test isolation via vi.resetModules() in beforeEach is correct for resetting the module-level flag.


Positive observations

  • The module-level flag approach for session tracking is a thoughtful alternative to polluting subprocess env vars.
  • Quoting the script path in the command field (node "${scriptPath}") correctly handles home directories with spaces.
  • The afterRun cleanup is unconditional on exit code, ensuring settings are always restored even after failed sessions.
  • Build integration via the existing cpSync mechanism (scripts/copy-plugins.js) is clean and minimal.

LGTM. Ready to merge.

Path constants derived via path.join() so they use backslashes on Windows
and forward slashes on Unix, matching what the production code produces.
CLAUDE_HOME is kept as the raw mock string (not path.join'd) since it is
passed directly to mkdir without normalization.

Generated with AI

Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
@codemie-ai codemie-ai merged commit 0833656 into main Feb 20, 2026
5 checks passed
@codemie-ai codemie-ai deleted the feature/statusline-flag branch February 20, 2026 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants