Csql tracking

From t0ddc3by/claude-for-customer-success · View interactive version

Csql tracking is an AI agent skill from the GitHub repository t0ddc3by/claude-for-customer-success. Manages the lifecycle of Customer Success Qualified Leads (CSQLs) — create, update, close, and query operations — with persistent filesystem storage, status state machine enforcement, and inter-skill contract consumption from csm:expansion-business-case.

How to use this skill

Skill file

[VALIDATED]

Overview

rev-ops:csql-tracking manages the full lifecycle of Customer Success Qualified Leads (CSQLs) — the handoff artifact produced by csm:expansion-business-case [mode=csql] — from CS handoff through closed/won or terminal pipeline states. It provides RevOps with a persistent, queryable portfolio of active and closed CSQLs within the CS plugin's filesystem control plane.

This skill is the downstream consumer in a two-skill inter-skill contract:

csm:expansion-business-case [mode=csql]
        ↓  emits CSQL Qualification Package
rev-ops:csql-tracking [operation=create]
        ↓  persists to context/csql-*.md

Four operations are supported: create, update, close, query.


Pre-flight

Read ~/.claude/plugins/config/claude-for-customer-success/rev-ops/CLAUDE.md and

~/.claude/plugins/config/claude-for-customer-success/company-profile.md.

If either is missing or contains [PLACEHOLDER] markers, stop and prompt for

/rev-ops:cold-start-interview.

Note from config: cs_platform_connected

G-code dependency: All G-code guardrails referenced in this skill (G1–G9) are defined in the CLAUDE.md config loaded above. If Pre-flight halts or config is missing, G-codes are undefined — do not proceed with partial config.


Use When


Do NOT Use For


Typical Activation


Reasoning Protocol

Before generating output, apply these primers:

  1. CLASSIFY: What type of CSQL operation is this?
  1. CONSTRAINTS: What limits the solution space?

1. Confirm activation — user requesting CSQL lifecycle management or retrieval

2. Resolve the target CSQL record(s) from filesystem; declare file path and data-as-of context

3. Apply G9 — all filesystem write operations (create, update, close) require explicit user confirmation before execution; surface as draft and await approval

4. Enforce immutable field lock — csql_id, created_at, csm_owner, and source_skill fields cannot be modified after record creation under any circumstance

5. Enforce terminal state immutability — records in won, lost, or stalled status cannot be reopened, updated, or re-staged; surface the block explicitly if attempted

6. Validate status transitions against the state machine before proposing any update; reject invalid transitions with a clear explanation

7. Confirm output destination before delivering — inline summary vs. formatted table vs. full record dump

  1. EXPERT CHECK: What would a veteran RevOps CSQL lifecycle analyst verify before executing?
  1. ANTI-PATTERNS: Common mistakes to avoid:

After execution, verify:


Operations

create

Purpose: Ingest a completed CSQL Qualification Package and persist a new CSQL record to the filesystem.

Parameters:

| Field | Type | Required | Description |

|-------|------|----------|-------------|

| operation | string | Yes | Must be "create" |

| account_name | string | Yes | Account name — matches the Account field in the CSQL package. Locked at creation (immutable). |

| csql_package | string | Yes | Full CSQL Qualification Package content from csm:expansion-business-case [mode=csql]. Stored verbatim. |

| csm_name | string | Yes | CSM who owns this CSQL. |

| expansion_product | string | Yes | Product, tier, or capability being proposed. |

| expansion_amount | string | No | Estimated expansion ARR (e.g., "~$42,000 ARR"). |

| ae_owner | string | No | Assigned AE. Defaults to [Unassigned] if not provided. |

| target_close_date | string | No | ISO date — expected decision date. |

Auto-generated fields (immutable after creation):

| Field | Generation rule |

|-------|----------------|

| csql_id | CSQL-[ACCT]-[YYYYMMDD]-[SEQ] — see Filesystem Architecture |

| created_at | ISO 8601 datetime at time of create call |

| created_by | Session user identity |

| account_name | Captured from input; locked — cannot be modified via update |

Behavior:

  1. Sanitize account_name via safe_account() for filesystem path derivation.
  2. Derive csql_id using Auto-ID generation rules (see Filesystem Architecture).
  3. Write context file: context/csql-[safe_account]-[YYYY-MM-DD]-v1.md
  4. Append initial transition log entry: [created]
  5. Set initial status to new.

Output: Returns csql_id and the path of the created context file.

Error conditions:


update

Purpose: Partially modify a non-terminal CSQL record — status progression, AE assignment, close date update, or note append.

Parameters:

| Field | Type | Required | Description |

|-------|------|----------|-------------|

| operation | string | Yes | Must be "update" |

| csql_id | string | Yes | Target CSQL ID (e.g., CSQL-ACME-20260516-001) |

| status | string | No | New status — must pass transition guard (see Status State Machine) |

| ae_owner | string | No | Assign or reassign AE |

| target_close_date | string | No | Update expected close date (ISO date) |

| notes | string | No | Append-only — new note is appended to the Notes section, not replaced |

| meddic_updates | object | No | Updated MEDDIC field values |

| override | boolean | No | true permits backward status transitions on non-terminal records (admin correction only) |

Immutable fields — rejected if included in update payload:

| Field | Error response |

|-------|---------------|

| csql_id | Immutable field error: csql_id cannot be modified after creation. |

| created_at | Immutable field error: created_at cannot be modified after creation. |

| created_by | Immutable field error: created_by cannot be modified after creation. |

| account_name | Immutable field error: account_name cannot be modified after creation. |

Behavior:

  1. Locate the latest version file for the target csql_id.
  2. Verify record is not in a terminal state (won, lost, stalled). If terminal → reject with: Update rejected: CSQL-[ID] is in terminal state [status] and cannot be modified.
  3. If status is provided, validate against the transition guard. Reject invalid transitions.
  4. Write new version file (v[N+1]). Prior version is preserved — never overwritten.
  5. Append transition log entry if status changed.
  6. Append note if notes provided.

Output: Returns updated csql_id, new version path, and transition log entry (if status changed).

Error conditions:


close

Purpose: Set a CSQL to a terminal state and lock the record.

Parameters:

| Field | Type | Required | Description |

|-------|------|----------|-------------|

| operation | string | Yes | Must be "close" |

| csql_id | string | Yes | Target CSQL ID |

| terminal_status | string | Yes | One of: won, lost, stalled |

| close_reason | string | Yes | Free-text reason for closure |

| close_date | string | No | ISO date — defaults to today if not provided |

| won_amount | string | Conditional | Required when terminal_status == won |

Behavior:

  1. Locate the latest version file for the target csql_id.
  2. Verify record is not already in a terminal state. If already terminal → reject.
  3. Validate terminal_status is one of won, lost, stalled.
  4. If terminal_status == won and won_amount is absent → reject with: won_amount is required when terminal_status is won.
  5. Set status to terminal state. Write final version file (v[N+1]). Prior version preserved.
  6. Append terminal transition log entry.
  7. Record is now locked — no further update operations will be accepted.

Output: Returns closed record summary with csql_id, terminal_status, close_date, and close_reason.

Error conditions:


query

Purpose: Read-only portfolio view of CSQL records with filtering and sorting. No filesystem writes.

Parameters:

| Field | Type | Required | Description |

|-------|------|----------|-------------|

| operation | string | Yes | Must be "query" |

| filter_status | string or list | No | Filter by status(es). Accepts single value or list. |

| filter_csm | string | No | Filter by CSM name (exact or substring match) |

| filter_ae | string | No | Filter by AE name (exact or substring match) |

| filter_account | string | No | Substring match on account_name |

| created_after | string | No | ISO date — include only CSQLs created on or after this date |

| created_before | string | No | ISO date — include only CSQLs created on or before this date |

| sort_by | string | No | Sort field: created_at (default), target_close_date, status, account_name |

| sort_order | string | No | asc (default) or desc |

| include_closed | boolean | No | Include won, lost, stalled records. Default: false |

| limit | integer | No | Max records returned. Default: 20. Max: 100. |

| offset | integer | No | Skip first N matching records (for pagination). Default: 0. |

Behavior: Scan context/csql-* files (latest version per account-date only). Apply filters using AND logic across all provided parameters. Sort. Return formatted table or structured list.

Output: Formatted table of matching CSQL records. Includes csql_id, account_name, status, csm_name, ae_owner, expansion_amount, target_close_date, created_at. Read-only — no filesystem writes occur.

Reference: See reference/query-filter-patterns.md for filter combination examples, sort behavior, and output format specification. Load on demand when query behavior details are needed.

Error conditions:


Status State Machine

Reference: See reference/csql-status-transitions.md for the full state diagram, transition table, override rules, and log format examples. Load on demand.

Valid States

| State | Type | Description |

|-------|------|-------------|

| new | Active | CSQL created; not yet reviewed by AE |

| qualified | Active | AE has reviewed and confirmed qualification |

| in_negotiation | Active | Active deal in negotiation |

| won | TERMINAL | Deal closed won — record locked |

| lost | TERMINAL | Deal closed lost — record locked |

| stalled | TERMINAL | Deal stalled; no near-term path — record locked |

Valid Transitions

| From | To | Override required? |

|------|----|--------------------|

| new | qualified | No |

| new | stalled | No (early disqualification) |

| qualified | in_negotiation | No |

| qualified | stalled | No (disqualified post-AE review) |

| in_negotiation | won | No |

| in_negotiation | lost | No |

| in_negotiation | stalled | No |

| in_negotiation | qualified | Yes (admin correction, backward) |

| qualified | new | Yes (admin correction, backward) |

Terminal State Rules (IMMUTABLE)

won, lost, and stalled are terminal and immutable. Once set:

This is a design decision, not a limitation. Stalled records must never be mutated. To re-pursue: invoke rev-ops:csql-tracking [operation=create] with the same account and a fresh CSQL package.

Override Flag Rules

Transition Log Format

Every status change appends a log entry to the CSQL record's Transition Log section:

[YYYY-MM-DDTHH:MM:SSZ] [from_status] → [to_status] | [notes or "no note"] | [override: true/false]

Examples:

[2026-05-16T14:23:00Z] created | status: new | no note | override: false
[2026-05-17T09:11:00Z] new → qualified | AE confirmed after discovery call | override: false
[2026-05-20T15:44:00Z] in_negotiation → qualified | Reverting — deal not yet in negotiation | override: true
[2026-05-28T10:00:00Z] in_negotiation → won | Closed at $42,000 ARR | override: false

Filesystem Architecture

Context File Naming

context/csql-[sanitized_account]-[YYYY-MM-DD]-v[N].md

Examples:

context/csql-acme-corp-2026-05-16-v1.md     ← created
context/csql-acme-corp-2026-05-16-v2.md     ← after update
context/csql-acme-corp-2026-05-16-v3.md     ← after close

safe_account() Sanitization Algorithm

def safe_account(account_name: str) -> str:
    """
    Derive filesystem-safe account slug from raw account_name.
    Used for path construction only — NEVER for display output.
    """
    result = account_name.lower()
    result = re.sub(r'[^a-z0-9]', '-', result)   # replace non-alphanumeric with hyphen
    result = re.sub(r'-{2,}', '-', result)         # collapse consecutive hyphens
    result = result.strip('-')                      # trim leading/trailing hyphens
    return result[:30]                              # trim to 30 chars

Examples:

Auto-ID Generation

Format: CSQL-[ACCT]-[YYYYMMDD]-[SEQ]

| Component | Rule |

|-----------|------|

| ACCT | First 4 alphabetic characters of account_name, uppercased, non-alpha stripped. If fewer than 4 alpha characters exist, pad with X to reach 4. |

| YYYYMMDD | Creation date |

| SEQ | 3-digit sequence: scan context/csql-[safe_account]-[YYYY-MM-DD]-*.md for existing files with same account + same date; take highest SEQ found and increment by 1. Default to 001 if no prior files exist. |

ACCT derivation examples:

| account_name | Alpha chars extracted | ACCT |

|---|---|---|

| "Acme Corp" | A, c, m, e → ACME | ACME |

| "123 Widgets" | W, i, d, g → WIDG | WIDG |

| "TechCo" | T, e, c, h → TECH | TECH |

| "IT Services" | I, T, S, e → ITSE | ITSE |

| "IT" | I, T → only 2 alpha chars | ITXX (padded) |

| "A1" | A → only 1 alpha char | AXXX (padded) |

| "123" | no alpha chars | XXXX (all padded) |

X-padding rule: When account_name yields fewer than 4 alphabetic characters after stripping non-alpha, pad the ACCT component with X characters on the right until 4 characters are reached.

Auto-ID examples:

CSQL-ACME-20260516-001   ← first Acme Corp CSQL on 2026-05-16
CSQL-ACME-20260516-002   ← second Acme Corp CSQL same day
CSQL-WIDG-20260510-001   ← first 123 Widgets CSQL on 2026-05-10
CSQL-ITXX-20260517-001   ← first "IT" account CSQL (padded)

Versioning Rules


Immutable Fields

The following fields are locked at create and cannot be modified by any subsequent operation:

| Field | Reason |

|-------|--------|

| csql_id | Identity key — must remain stable for cross-skill reference |

| created_at | Audit timestamp |

| created_by | Audit identity |

| account_name | Account identity — changes would corrupt query filter behavior |

Any update request that includes an immutable field in its payload must return an explicit error. Rejection is not silent:

Immutable field error: [field_name] cannot be modified after creation.

Examples:

Immutable field error: account_name cannot be modified after creation.
Immutable field error: csql_id cannot be modified after creation.

Inter-Skill Contract

Upstream Producer

Skill: csm:expansion-business-case [mode=csql]

The CSQL Qualification Package emitted by the upstream skill serves as the primary input to rev-ops:csql-tracking [operation=create].

Field mapping:

| Producer field | Consumer parameter | Notes |

|----------------|-------------------|-------|

| Account header field | account_name | Non-empty string required |

| Prepared by CSM name | csm_name | Non-empty string required |

| Full package document | csql_package | Stored verbatim; content integrity not validated at MVP |

| Proposed expansion line | expansion_product | Non-empty string required |

| Estimated expansion value | expansion_amount | Optional |

| Handoff to AE field | ae_owner | Optional; defaults to [Unassigned] |

Contract validation at create:

Reference template: csm/skills/expansion-business-case/reference/csql-package-template.md


Output

Each operation surfaces a structured confirmation or result. Output formats are documented inline within each ## Operations subsection. Summary:

All write operation outputs are presented as drafts requiring G9 confirmation before filesystem execution.


Reference Files

Load these files on demand — do not load at skill invocation start.

| File | Path | Load when |

|------|------|-----------|

| csql-record-schema.md | reference/csql-record-schema.md | Viewing or validating the canonical CSQL record format, field definitions, validation rules, or Auto-ID/sanitization algorithms |

| csql-status-transitions.md | reference/csql-status-transitions.md | Reviewing the full state machine diagram, valid transition table, override rules, or transition log format |

| query-filter-patterns.md | reference/query-filter-patterns.md | Reviewing query filter syntax, sort options, output format, include_closed behavior, or limit/offset patterns |

| reasoning-blueprint.md | references/reasoning-blueprint.md | Problem classification taxonomy, domain heuristics, common failure modes, and expert judgment patterns for this skill |


Security & Permissions

Network access: None — skill operates on provided parameters and local filesystem only. No external API calls.

Filesystem scope: Read and write limited to context/csql-* only. No reads or writes outside this path prefix are permitted.

Subprocess execution: None.

Dynamic code execution: None — pseudocode in this skill represents the logic contract and is not executed at runtime.

Data sensitivity: Inputs may contain account names, deal data, MEDDIC qualification details, and customer outcome metrics. All user-provided string inputs are sanitized before filesystem path use.


Trust & Verification

Input trust model: All user-provided string parameters are treated as untrusted at intake. No parameter is trusted by virtue of its name or position.

safe_account() contract: account_name and all values interpolated into filesystem paths are sanitized via safe_account() before any path construction. Raw account_name (display value) is used only in document content — never in path construction.

display_account / safe_account separation:

csql_package handling: The CSQL Qualification Package is stored verbatim in the context file body. It is never executed, evaluated, or interpolated into skill logic paths.

Free-text inputs: notes, close_reason, meddic_updates values — sanitized for filesystem path use when they appear in filenames or log entries. Raw values are written to document body only.

Immutability enforcement: Immutable field violations return an explicit error message — rejection is never silent. Terminal state lock is enforced at runtime before any write operation.

SEQ collision note: Auto-ID sequence generation uses a scan-and-increment pattern assuming single-writer access. Parallel create calls for the same account on the same date may produce SEQ collisions. This is a known limitation; single-writer assumption is documented. Post-MVP resolution is OQ-4.


Open Questions (Post-MVP)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.