# summary

Delete profiling summaries and their child records — use --prune to preserve the latest summary per definition while removing older results.

# description

Every profiling run creates a summary — a result record containing Field Results, Value Results, and KPI Results. Over repeated profiling cycles, summaries accumulate. An org with 20 definitions profiled weekly generates over 1,000 summaries per year. The current profiling posture is the latest summary per definition; older summaries are historical artifacts.

This command deletes summaries and their child records from a Salesforce org. The `--prune` flag implements the standard housekeeping pattern: keep the latest summary per definition while removing older results. This is how Marcus Thompson closes engagement phases and how David Chen configures automated weekly cleanup.

**Cleanup dependency order** — summary purge must happen BEFORE definition purge:

1. `sf cuneiform profile request cancel` — cancel queued requests
2. `sf cuneiform profile request delete` — remove canceled and rejected requests
3. `sf cuneiform summary purge` — remove summaries (cascade-deletes completed requests; resets definition status to NOT PROFILED when all summaries are removed)
4. `sf cuneiform definition purge` — remove definitions (requires zero summaries)

THREE SELECTION MODES:

- **By ID** (`--ids`) — Delete specific summaries by Salesforce record ID. Exclusive mode — filter flags are ignored.
- **By filter** (`--objects`, `--category`, `--is-active`) — Delete summaries matching filters. Summaries are resolved through their parent definitions: the command queries definitions first, then targets their associated summaries.
- **All** (`--all`) — Delete all eligible summaries. Can be combined with filter flags to narrow scope.

ELIGIBILITY: Only summaries with a terminal profiling status (SUCCESS, COMPLETE w/ FAILURES, FAILED, CANCELED) can be deleted. In-progress summaries are automatically excluded and reported with a reason.

SAFETY: Use --dry-run to preview the scope before deleting. The confirmation prompt shows affected summaries before proceeding. Cascade delete automatically removes child Field Results, Value Results, KPI Results, and related profiling requests (original and reprofile). Definition status resets to NOT PROFILED when all summaries for a definition are removed.

**When to run this command:**

- Post-sprint cleanup — prune intermediate results after iterative profiling cycles
- Pre-sandbox-refresh storage reduction — free storage before the refresh window
- Object-targeted cleanup after data model changes — remove stale summaries for redesigned objects
- Before definition purge — clear summaries as a prerequisite for definition deletion

NATURAL LANGUAGE → FLAG MAPPING:
"clean up old summaries, keep latest" → --all --prune
"delete all summaries" → --all
"delete Account summaries" → --objects Account
"delete this specific summary" → --ids a0Bxx0000001234AAA
"what would be deleted?" → --all --dry-run
"clean up old summaries without asking" → --all --prune --no-prompt

COMMAND SEQUENCE:
`profile request cancel` → `profile request delete` → `summary purge` → `definition purge`

# flags.target-org.summary

The Salesforce org to purge summaries from. Specify the org alias or username when you have multiple authenticated orgs.

# flags.all.summary

Target all eligible summaries for deletion. Can be combined with filter flags (--objects, --category, --is-active) to narrow scope. Combine with --prune to preserve the latest summary per definition while removing older results.

# flags.ids.summary

Specific summary record IDs to delete (comma-separated Salesforce record IDs). Exclusive mode — filter flags are ignored when --ids is specified. Use for surgical removal of individual summaries.

# flags.objects.summary

Filter by target object API name (matches the definition's profiled object). Scopes purge to summaries for specific objects (e.g., --objects Account removes only Account-related summaries).

# flags.category.summary

Filter by definition category label (e.g., "Phase 1", "Baseline"). Scopes purge to summaries from a completed engagement phase or functional area.

# flags.is-active.summary

Filter by definition active status. Targets summaries belonging to active or inactive definitions.

# flags.limit.summary

Maximum number of summaries to process per invocation (default: 50). Controls batch size in large cleanup operations. Ignored when --all is specified.

# flags.prune.summary

Preserve the latest summary for each definition and delete only older summaries. This is the standard housekeeping pattern — current profiling evidence is retained while historical results are removed. Combine with --all for org-wide pruning, or with filter flags to prune specific scopes.

# flags.dry-run.summary

Preview what would be deleted, applied to nothing. Shows the same categorization (eligible, skipped by status, preserved by prune) as a real purge. Run this first to verify scope before committing.

# flags.no-prompt.summary

Skip the confirmation prompt and delete immediately. Use in scripts and automation pipelines. The prompt normally shows which summaries (and their child records) will be permanently deleted.

# flags.format.summary

Output format: table (default, human-readable) or json (machine-readable for scripting and automation dashboards).

# examples

- Preview what would be deleted — start here to verify scope:

  <%= config.bin %> <%= command.id %> --target-org myOrg --all --dry-run

- Standard housekeeping — keep the latest summary per definition, remove older results:

  <%= config.bin %> <%= command.id %> --target-org myOrg --all --prune

- Object-targeted cleanup — remove Account summaries after a data model redesign:

  <%= config.bin %> <%= command.id %> --target-org myOrg --objects Account

- Complete cleanup — delete all terminal-state summaries:

  <%= config.bin %> <%= command.id %> --target-org myOrg --all

- Surgical removal — delete specific summaries by record ID:

  <%= config.bin %> <%= command.id %> --target-org myOrg --ids a0Bxx0000001234AAA,a0Bxx0000005678AAA

- Automated weekly prune — for CI pipelines and scheduled jobs:

  <%= config.bin %> <%= command.id %> --target-org myOrg --all --prune --no-prompt --format json

# errors.noSelectionCriteria

No selection criteria specified. Provide --all, --ids, or filter flags (--objects, --category, --is-active).

# errors.mutuallyExclusive

The --ids flag is mutually exclusive with filter flags (--objects, --category, --is-active, --all).

# errors.noEligibleSummaries

No summaries found matching the specified criteria.

# errors.queryFailed

Failed to query summaries: %s

# errors.deleteFailed

Failed to delete summaries: %s

# errors.noTargetOrg

Could not determine target org username.

# output.pruneMode

Prune mode: preserving latest summary per definition.

# prompt.confirm.singular

Delete this Profiling Summary (and its child Field Results, Value Results, and KPI Results)

# prompt.confirm.plural

Delete these %s Profiling Summaries (and their child Field Results, Value Results, and KPI Results)

# output.noDeletable

Purge cancelled — there are no Profiling Summaries that can be deleted.

# output.cancelled

Purge cancelled. No summaries were deleted.

# skippedByStatus.header.singular

Could not delete this Profiling Summary — it has a non-terminal status.

# skippedByStatus.header.plural

Could not delete these Profiling Summaries — they have non-terminal statuses.

# skippedByPrune.header.singular

Preserved this Profiling Summary — it is the latest for its definition.

# skippedByPrune.header.plural

Preserved these Profiling Summaries — they are the latest for their definitions.

# output.noEligible.message

No summaries were found matching the specified criteria.

# output.noEligible.guidance

- Please check your filters and confirm that summaries exist in your Salesforce org.

# output.summary.deleted

Deleted

# output.summary.skipped

Skipped

# output.summary.failed

Failed

# output.summary.total

Total

# output.summaryHeader

Summary

# spinner.status.deleted

deleted

# spinner.status.skipped

skipped

# spinner.status.failed

failed

# warnings.limitIgnoredWithAll

--limit is ignored when --all is specified. All eligible records will be processed.
