CCContextCleanLocal-first log cleaner

Annotated examples

Before-and-after logs with the reasoning behind every reduction

Shorter is not automatically better. Each example below explains which evidence remains useful, which lines are low-signal for the first diagnosis, and when the removed context should be restored.

CASE 1

Node.js module resolution

A local server fails immediately after a dependency change.

Raw excerpt

npm warn deprecated inflight@1.0.6
Starting server on port 3000
Error: Cannot find module 'express'
Require stack:
- C:\app\server.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Object.<anonymous> (C:\app\server.js:3:17)

Reviewed excerpt

Error: Cannot find module 'express'
Require stack:
- C:\app\server.js
    at Object.<anonymous> (C:\app\server.js:3:17)

Why these lines stay

The missing package name, require stack, and first application frame locate the failure.

Why other lines leave

The deprecation warning and Node internal loader frames do not change the first dependency check.

When to restore context

Keep the full require stack when several local packages or workspaces can resolve the same module.

CASE 2

GitHub Actions test failure

A test job completes setup successfully and then fails in one suite.

Raw excerpt

Run actions/checkout@v4
Cache restored from key: npm-windows
Run npm test
FAIL src/user.test.ts
Expected: 200
Received: 500
TypeError: Cannot read properties of undefined
    at getUser (src/user.ts:18:10)
Error: Process completed with exit code 1.
Post job cleanup.

Reviewed excerpt

Command: npm test
FAIL src/user.test.ts
Expected: 200
Received: 500
TypeError: Cannot read properties of undefined
    at getUser (src/user.ts:18:10)
Exit code: 1

Why these lines stay

The failing command, assertion, exception, application frame, and exit code form a complete handoff.

Why other lines leave

Checkout, cache, and cleanup messages show pipeline activity but not the test cause.

When to restore context

Keep setup output when dependency installation, environment variables, or generated files may explain the failure.

CASE 3

Python exception chaining

An API wrapper converts a parsing error into a domain-specific exception.

Raw excerpt

Traceback (most recent call last):
  File "/app/parser.py", line 24, in parse_user
    age = int(payload["age"])
ValueError: invalid literal for int() with base 10: 'unknown'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/api.py", line 61, in create_user
    user = parse_user(payload)
  File "/app/parser.py", line 27, in parse_user
    raise InvalidUser("age must be numeric") from error
InvalidUser: age must be numeric

Reviewed excerpt

ValueError: invalid literal for int() with base 10: 'unknown'
    at /app/parser.py:24 in parse_user
Caused by:
InvalidUser: age must be numeric
    at /app/parser.py:27 in parse_user
    called from /app/api.py:61 in create_user

Why these lines stay

Both exception names and their causal relationship are essential. The application frames show where conversion and wrapping occur.

Why other lines leave

Only formatting and repeated traceback narration were compressed.

When to restore context

Never remove the earlier exception in a chained traceback; the wrapper message may hide the real input failure.

CASE 4

Next.js hydration mismatch

A component renders different text on the server and the first client render.

Raw excerpt

Warning: Text content did not match.
Server: "June 8, 2026"
Client: "June 7, 2026"
Error: Hydration failed because the initial UI does not match.
    at throwOnHydrationMismatch (react-dom-client.development.js:...)
    at prepareToHydrateHostInstance (react-dom-client.development.js:...)
    at DateLabel (src/components/DateLabel.tsx:14:3)
    at Header (src/components/Header.tsx:22:5)

Reviewed excerpt

Hydration mismatch
Server text: "June 8, 2026"
Client text: "June 7, 2026"
First application component:
DateLabel (src/components/DateLabel.tsx:14:3)
Parent:
Header (src/components/Header.tsx:22:5)

Why these lines stay

The server/client values and first application component directly support a timezone or nondeterministic-render diagnosis.

Why other lines leave

React DOM hydration internals repeat the mechanism without identifying the component decision.

When to restore context

Keep framework frames when investigating a framework regression rather than an application rendering difference.

A practical stopping rule

Stop trimming when the excerpt answers four questions: what failed, where it failed, what input or condition triggered it, and what causal error preceded the final message. If any answer disappears, the cleaned version is too aggressive.

Turn an excerpt into a complete debugging report