Agent skill

smith-ctx

Universal context management with proactive recommendations. Agent checks context levels and recommends context resets to users. Always active as foundation for context optimization.

Stars 1
Forks 0

Install this agent skill to your Project

npx add-skill https://github.com/tianjianjiang/smith/tree/main/smith-ctx

SKILL.md

Context Management

  • Load if: Always active (context management foundation)
  • Prerequisites: @smith-guidance/SKILL.md

CRITICAL: Proactive Context Management (Primacy Zone)

Agent role: Check context levels proactively, RECOMMEND actions to user.

Context lifecycle: explore → monitor → prepare (at warning threshold) → reset (at critical threshold)

To check context: Prompt "What is the current context usage?" to get percentage.

Agent RECOMMENDS - user executes the platform's context reset command.

Platform Reference

  • Claude Code: Warning 50%, Critical 60%, Targeted: "Summarize from here" (Esc+Esc), Action: /clear (stop hook enforced)
  • Kiro: Warning 70%, Critical 80%, Compact Auto, Clear New session
  • Cursor: Warning 70%, Critical 80%, Compact /summarize, Clear New chat

Progressive Disclosure

Loading order (cheapest first):

  1. Metadata scan: Glob/Grep for file locations
  2. Targeted read: Specific file sections only
  3. Full file: Only when actively modifying
  4. Broad explore: Delegate to subagent (isolated context)
  • NEVER read entire directories without Grep filtering
  • NEVER load full files when targeted sections suffice
  • NEVER repeat file reads without using context

Serena MCP Preference

When Serena MCP is available, prefer Serena tools over native tools:

Why: Kiro's readFile truncates, strReplace fails on duplicates. Serena's regex mode handles complex replacements reliably.

Tool preference:

  • Reading: search_for_pattern > find_symbol > native readFile
  • Writing: replace_content (regex) > replace_symbol_body > native strReplace
  • Context savings: 99%+ reduction with symbol-level operations

Information Retention

Always preserve:

  • Task goals
  • File:line locations
  • Architectural decisions
  • Incomplete work

Always discard:

  • Verbose tool outputs
  • Failed explorations
  • Redundant file reads

Reference format: Use file:line (e.g., auth.ts:234) instead of embedding content

Ralph Loop Context Management

Ralph burns ~1-3.5k tokens/iteration. At critical threshold, persist state to Serena memory before context reset.

See @smith-ralph/SKILL.md for full context strategy and retention criteria.

  • @smith-guidance/SKILL.md - Core agent behavior
  • @smith-ctx-claude/SKILL.md - Claude Code: /clear (stop hook enforced)
  • @smith-ctx-cursor/SKILL.md - Cursor: UI indicator, /summarize
  • @smith-ctx-kiro/SKILL.md - Kiro: 80% auto-summarize, Serena memory
  • @smith-serena/SKILL.md - Serena MCP for persistent memory

ACTION (Recency Zone)

Proactive context checks:

  1. Periodically check context (platform-specific method)
  2. At warning threshold: Recommend context reset with retention criteria
  3. At critical threshold: Urgently recommend before degradation
  4. User executes command, agent continues with focused context

Before recommending context reset, prepare:

  • Task requirements summary
  • File paths with line numbers
  • Key design decisions
  • Remaining todos

Recommendation format:

text
Context at [X]%. Recommend context reset (see platform skill for command).
Keep: [task], [files], [decisions], [todos]

Expand your agent's capabilities with these related and highly-rated skills.

tianjianjiang/smith

smith-style

File naming, path standards, and conventional commits. Use when naming files, creating branches, writing commit messages, or setting up new projects. Covers underscore vs hyphen conventions, commit format, and branch naming patterns.

1 0
Explore
tianjianjiang/smith

smith-stacks

Stacked pull request workflows for large features. Use when creating stacked PRs, managing dependent PRs, or rebasing after parent merges. Covers stack creation, merge order, and squash merge handling.

1 0
Explore
tianjianjiang/smith

smith-python

Python development with uv, pytest, ruff, and type hints. Use when writing Python code, running tests, managing Python packages, or working with virtual environments. Covers import organization, type hints, pytest patterns, and environment variables.

1 0
Explore
tianjianjiang/smith

smith-principles

Fundamental coding principles (DRY, KISS, YAGNI, SOLID, HHH). Use when starting any development task, evaluating implementation approaches, or reviewing code quality. Always active as foundation for all development decisions.

1 0
Explore
tianjianjiang/smith

smith-nuxt

Nuxt 3 development patterns including auto-import stubbing for tests, environment variable conventions, and middleware testing. Use when working with Nuxt projects, testing Nuxt components/middleware, or configuring Nuxt environment variables.

1 0
Explore
tianjianjiang/smith

smith-plan

Plan tracking protocol (portable). Progress tracking with checkboxes, iteration workflow, completion/blocker signals. Use when executing multi-step plans, tracking task progress, or working from plan files. IMPORTANT - Always update the plan file after completing tasks.

1 0
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results