Skip to content

Cognee CLI - delete, add breakdown of affected data #1366

@daukadolt

Description

@daukadolt

Delete Command Preview (Enhancement)

NOTE: This issue is part of Contribute-to-Win. Please comment first to get assigned. Read the details here

Problem Statement

The cognee delete command currently removes data as requested (all data, by dataset, or by user). While it works as intended, users don’t get a clear overview of what will be affected before confirming the action.

Adding a preview step would improve usability and safety by helping users understand the scope of deletion before proceeding.

Proposed Solution

Enhance the delete command to include a preview step that summarizes what will be deleted.

The preview should display key metrics so the user can make an informed decision before confirming.

Preview metrics

When the user runs cognee delete (with any argument), we should show a breakdown like:

  1. Datasets: How many datasets will be removed
  2. Data entries: How many individual data items are affected
  3. Other relevant metrics (e.g., users affected, chunks, embeddings)

Example:

You are about to delete:
- 3 datasets
- 152 data entries
- 1 user

~~~~~

Then confirm before proceeding:

Proceed? (y/N)

Cases

  • Delete all
    • Show counts across the entire system
  • Delete by dataset
    • Show counts scoped to that dataset
  • Delete by user_id
    • Show counts of all datasets and data entries owned by that user

Non-Functional

  • If nothing is found to delete → show No data found to delete. and exit
  • Must run efficiently (counts only, not full data scan)
  • If metrics can’t be retrieved → log warning and fallback to direct delete
  • Default confirmation = No unless explicitly confirmed
  • Add --force flag to skip preview and delete immediately (useful for automation/CI)

Integration

  • Update cognee delete command in CLI
  • Add preview logic before actual delete execution
  • Extend tests to cover preview outputs for different argument combinations

Acceptance Criteria

  1. Running cognee delete shows preview metrics before deletion
  2. Preview correctly reflects counts for all, dataset, and user-specific deletes
  3. Empty or invalid targets return No data found to delete.
  4. --force skips preview and deletes immediately
  5. Confirmation prompt defaults to safe (abort unless explicitly confirmed)
  6. Metrics are logged before deletion begins

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions