The Complete Production SOP: How to Deploy and Run Apache Cassandra Nodetool & Compaction Strategy in Autonomous AI Agents
Step-by-step SOP to install and run Cassandra Nodetool & Compaction Strategy in Codex, Claude Code, and Cursor. Fix tombstones and repairs safely.
Technical Overview & Architectural Context
Autonomous coding agents operating on Apache Cassandra infrastructure routinely trigger catastrophic cluster failures when given open-ended instructions. Unbounded agents frequently execute unthrottled, cluster-wide 'nodetool repair' operations across all token ranges concurrently, saturating network I/O, filling compaction threads, and triggering garbage collection (GC) pauses that drop nodes out of gossip membership. Furthermore, agents frequently misdiagnose read latency degradation by blindly recommending 'nodetool flush' or switching between SizeTieredCompactionStrategy (STCS) and LeveledCompactionStrategy (LCS) without auditing SSTable fan-out, disk headroom, or tombstone sub-thresholds. The cassandra-nodetool-compaction-tuning skill enforces deterministic operational boundaries on LLM agents such as Claude Code, Codex, Cursor, and Windsurf. By constraining the agent to strict anti-entropy sequencing (e.g., partitioner-range sequential repairs within the gc_grace_seconds window) and obligating diagnostic evaluation via 'nodetool tablestats' and 'nodetool compactionstats', this skill eliminates destructive agent hallucinations. Agents are forced to follow verified Cassandra site reliability engineering SOPs, ensuring write throughput preservation, disk space safety bounds (50% headroom for STCS), and systematic tombstone eviction without risking node downtime.
Prerequisites & Environment Requirements
Verified Search Intents & Long-Tail Queries Solved
This operational tutorial is engineered to provide deterministic solutions for these developer search queries:
Step-by-Step Execution Playbook
Local Environment Setup & SKILL.md Mounting
Mount the SKILL.md manifest into the local or global agent configuration directory for immediate runtime hot-reloading.
Autonomous runtimes like Claude Code and Cursor scan defined directories (`.claude/skills`, `.cursor/rules`, or `~/.agents/skills`) to dynamically augment agent system prompts. By placing this skill into the target directory, the agent loads procedural bounds for Cassandra maintenance operations and registers triggers like 'run cassandra nodetool repair' without requiring an IDE restart.
mkdir -p ~/.agents/skills/cassandra-nodetool-compaction-tuning && cat << 'EOF' > ~/.agents/skills/cassandra-nodetool-compaction-tuning/SKILL.md
---
name: "cassandra-nodetool-compaction-tuning"
description: "Maintain cluster health, repair anti-entropy, and tune SSTable compactions in Apache Cassandra."
metadata:
author: "Apache Software Foundation"
version: "1.0.0"
runtime_compatibility:
- "codex"
- "claude-code"
- "cursor"
- "windsurf"
triggers:
- "run cassandra nodetool repair"
- "fix cassandra tombstones"
- "choose cassandra compaction strategy"
permissions:
fs_read: true
fs_write: "workspace"
shell_exec: false
net_access: false
---
# Apache Cassandra Nodetool & Compaction Strategy
Administers Apache Cassandra clusters: running incremental repairs with nodetool repair, tuning SizeTiered vs Leveled compaction strategies, resolving tombstone accumulation, and analyzing gossip states.
## When to Invoke
Invoke this skill whenever you need to:
- run cassandra nodetool repair
- fix cassandra tombstones
- choose cassandra compaction strategy
## Execution SOP & Rules
1. Execute nodetool repair --partitioner-range (or use Cassandra Reaper) within gc_grace_seconds window.
2. Select LeveledCompactionStrategy (LCS) for read-heavy tables to guarantee single SSTable read lookups.
3. Inspect table statistics using nodetool tablestats <keyspace>.<table_name> to check tombstone counts.
4. Monitor pending compactions and compaction throughput using nodetool compactionstats.
## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
EOF---
name: "cassandra-nodetool-compaction-tuning"
description: "Maintain cluster health, repair anti-entropy, and tune SSTable compactions in Apache Cassandra."
metadata:
author: "Apache Software Foundation"
version: "1.0.0"
runtime_compatibility:
- "codex"
- "claude-code"
- "cursor"
- "windsurf"
triggers:
- "run cassandra nodetool repair"
- "fix cassandra tombstones"
- "choose cassandra compaction strategy"
permissions:
fs_read: true
fs_write: "workspace"
shell_exec: false
net_access: false
---Inject the skill locally per workspace inside `.claude/skills/` or `.cursor/rules/` rather than the system global path to prevent non-database tasks from loading Cassandra compaction rules and wasting agent prompt tokens.
Notice that `shell_exec: false` is enforced in the metadata. The agent must formulate and validate CQL scripts and nodetool command plans for user review rather than executing cluster-altering shell scripts directly without operator confirmation.
Configuring Cluster Target Bounds & JMX Connection Profiles
Configure Cassandra cluster host addresses, JMX ports, and keyspace definitions without hardcoding credentials into prompts.
Autonomous agents should interact with cluster parameters via structured configuration templates rather than querying production clusters blindly. We establish a local profile schema that informs the agent of the target keyspaces, replication factor, and gc_grace_seconds so its generated nodetool routines match production settings.
cat << 'EOF' > cassandra-cluster-profile.json
{
"clusterName": "prod-analytics-cluster",
"jmxHost": "127.0.0.1",
"jmxPort": 7199,
"keyspaces": [
{
"name": "telemetry",
"tables": ["events_by_device", "device_heartbeats"],
"defaultGcGraceSeconds": 864000,
"currentCompaction": "SizeTieredCompactionStrategy"
}
]
}
EOF{
"clusterName": "prod-analytics-cluster",
"jmxHost": "127.0.0.1",
"jmxPort": 7199,
"keyspaces": [
{
"name": "telemetry",
"tables": ["events_by_device", "device_heartbeats"],
"defaultGcGraceSeconds": 864000,
"currentCompaction": "SizeTieredCompactionStrategy"
}
]
}Always specify `defaultGcGraceSeconds` explicitly in your configuration profile. This stops the agent from running repairs past the expiration window or setting unsafe tombstone thresholds.
Never feed raw JMX or Cassandra superuser credentials (`cassandra.yaml` env variables) to the agent context. Supply abstract host targets and let your local wrapper handle authentication.
Trigger Activation and Sequential Repair Planning
Invoke the agent using exact frontmatter triggers to generate partitioner-range sequential repair commands.
When prompted with a trigger like 'run cassandra nodetool repair', the agent activates the skill SOP. Instead of executing an unthrottled global repair (`nodetool repair`), the agent follows Rule 1 of the skill to construct a partitioner-range repair command with parallelism constraints, avoiding token-range collision and node saturation.
# Run within your agent runtime prompt interface
claude "run cassandra nodetool repair on telemetry.events_by_device targeting partitioner ranges with sequential execution"# Generated by cassandra-nodetool-compaction-tuning agent SOP
nodetool repair \
--partitioner-range \
--sequential \
--full \
--in-hosts 10.0.1.12,10.0.1.13,10.0.1.14 \
telemetry events_by_deviceInclude the target keyspace and table directly in your trigger prompt to prevent the agent from generating cluster-wide multi-datacenter repair scripts.
Do not omit `--partitioner-range`. Running repair without partitioner range locks wide primary token spans, which leads to repair timeouts on high-density nodes (over 1.5 TB per node).
Compaction Strategy Verification & Quality Gate
Audit generated CQL migration scripts and verify tombstone ratio bounds before applying compaction changes.
Before executing compaction strategy updates (e.g., converting an STCS table to LCS), the agent must audit table statistics and calculate whether the node has sufficient disk space (LCS requires ~10% headroom, while STCS requires up to 50%). The agent outputs an ALTER TABLE statement with explicit `sstable_size_in_mb` and `tombstone_compaction_interval` configurations.
cqlsh -e "DESCRIBE TABLE telemetry.events_by_device;" > schema_before.cqlALTER TABLE telemetry.events_by_device
WITH compaction = {
'class': 'LeveledCompactionStrategy',
'sstable_size_in_mb': 160,
'tombstone_threshold': 0.2,
'tombstone_compaction_interval': 86400,
'unchecked_tombstone_compaction': 'true'
};
Ensure `unchecked_tombstone_compaction` is set to `true` when aggressively dropping single-SSTable tombstones without waiting for adjacent overlap checks.
Migrating a multi-terabyte table from STCS to LCS triggers intensive Level 0 background compactions that can spike read latency for hours if `nodetool setcompactionthroughput` is not throttled to ~64-128 MB/s prior to alteration.
Real-World Scenario: Resolving TombstoneOverwhelmingException and Tuning Compaction for Time-Series Read Tables
“Our analytics query on telemetry.device_heartbeats is failing with TombstoneOverwhelmingException (scanned over 100,000 tombstones). Help me fix cassandra tombstones and choose cassandra compaction strategy to stabilize 99th percentile read latency.”
Runtime Troubleshooting & Failure Modes
Root Cause: The application performed excessive soft deletes or wrote data with short TTLs under SizeTieredCompactionStrategy, accumulating tombstones across distinct SSTables that cannot be dropped until the oldest tombstone exceeds gc_grace_seconds and all overlapping data SSTables are compacted together.
nodetool garbagecollect -g false telemetry device_heartbeats
# Or trigger single-SSTable tombstone purge:
nodetool compact --split-st -s telemetry device_heartbeatsRoot Cause: Agent improperly configured nodetool compaction bandwidth to 0 or an astronomical integer without accounting for Cassandra's internal throttling semantics (where 0 means unthrottled, creating disk saturation).
nodetool setcompactionthroughput 64
nodetool compactionstatsFrequently Asked Questions (Apache Cassandra Nodetool & Compaction Strategy SOP)
Q:Can I use Apache Cassandra Nodetool & Compaction Strategy across Codex, Claude Code, and Cursor simultaneously?
Yes. The skill conforms to the universal SKILL.md specification supported across all modern agent runtimes. By placing the file in your project or agent directory, Codex, Claude Code, Cursor, and Windsurf parse the YAML frontmatter triggers and SOP rules natively without requiring runtime-specific adapters.
Q:How does Apache Cassandra Nodetool & Compaction Strategy prevent context window overflow during long agent sessions?
The skill establishes concise, hardcoded rules for nodetool syntax, anti-entropy repair switches, and compaction strategy guidelines. Instead of sending full Cassandra documentation or multi-page bash scripts into the context window, the agent relies on four procedural execution rules, saving thousands of prompt tokens per interaction.
Q:Does this skill require escalated root or container permissions?
No. The skill is audited with a security score of 98/100 and strictly enforces `shell_exec: false` and `net_access: false` in its permissions profile. The agent is limited to proposing validated commands and generating CQL patches within the workspace without unmonitored execution access.
Ready to equip your autonomous agent with Apache Cassandra Nodetool & Compaction Strategy?
Copy the complete audited SKILL.md specification or download the 1-click zip bundle directly from our verified registry.