What the agent does
The agent counts log calls by shape before it picks a mapping, because Pino accepts Winston's method names and then does something different with the arguments. In a service like santiq/bulletproof-nodejs the logger is built in src/loaders/logger.ts with winston.createLogger: npm levels, a timestamp formatted as YYYY-MM-DD HH:mm:ss, errors({ stack: true }), splat() and json(), plus a colourised console format when NODE_ENV is development. It is registered in the typedi container as 'logger' and read back in four other files that import the Logger type from winston. Across src there are eight silly calls, four debug, five info, no warn and nine error.
Two of those shapes break under Pino, and neither raises an error at build time here. The first is the level. src/config/index.ts defaults the level to 'silly', which Pino does not have: pino({ level: 'silly' }) throws default level:silly must be included in custom levels, and calling logger.silly(...) on a default Pino logger is a TypeError. The agent maps silly to trace in the eight calls and in the config default, and accepts the old value from LOG_LEVEL for one release so an existing .env keeps working.
The second is the error calls, and it is the one that costs a team its incident data. Seven of the nine look like Logger.error('... %o', e). Winston's splat formats the error into the message, so the line reads error: Error: boom. Pino formats %o as JSON, and an Error has no enumerable fields, so the same call logs "msg":"error: {}". The message, the type and the stack are all gone, and nothing fails. The agent rewrites each of the seven as logger.error({ err: e }, 'text'), which puts type, message and stack under an err key. The two calls that pass only the error already work that way in Pino.
Reading the calls also turns up a problem that is not Pino's doing. Three debug lines in src/api/routes/auth.ts log the request body of sign-up, sign-in and sign-out with %o, password included, and the default level lets them through. Pino's redact option can hide body.password, but only when the body is passed as an object: interpolated into the message it is printed whole. So the agent changes those three calls to logger.debug({ body: req.body }, 'Calling Sign-Up endpoint') and sets redact: ['body.password']. It adds pino-pretty as a development dependency for readable local output, then runs npm test and the type check and reports both.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Replace winston with pino in this Node.js service. Read package.json, the module that creates the logger, the config that sets its level, and every file that logs or imports a winston type. Count the calls per level and per argument shape: plain string, printf-style placeholders with an object, placeholders with an Error, and an Error alone. Before porting, write a small script that builds the existing logger with its real options and makes one call of each shape; save its output. Port the logger module to pino with the same level source, JSON to stdout in production and pino-pretty only in development. Map levels pino lacks to the nearest pino level and keep accepting the old names from the environment. Rewrite every call that passes an Error through a placeholder as logger.error({ err }, message), because pino prints {} for it. Where a call logs a request body or credentials, pass the object as a field and add a redact path; list each such call. Replace winston type imports. Remove logging packages nothing imports. Run the script against the new logger, then npm test and the TypeScript check, and compare the check with its result on the unchanged branch. Open a pull request with both outputs side by side and a table of old and new field names.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
A pull request that rewrites src/loaders/logger.ts, touches the config default, changes the type import in four files, and edits eighteen call sites: eight silly, seven error and three debug. package.json gains pino and pino-pretty and loses winston. It can lose morgan too, which is listed as a dependency and imported nowhere under src. The description shows one line per call shape from each logger, so the format change is visible: Winston's {"level":"silly","message":...,"timestamp":"<date and time>"} becomes Pino's {"level":10,"time":<epoch milliseconds>,"pid":...,"hostname":...,"msg":...}.
That table of field names is what a reviewer takes to whoever owns the log pipeline. message is now msg, timestamp is now a numeric time, and level is a number instead of a word, so saved searches and alerts that filter on level:error need level:50 or a formatters.level function that keeps the label. The agent leaves that choice to the prompt and states which one it made.
The type check needs honest reading. On the unchanged repository npx tsc --noEmit already reports 99 errors, every one of them in a file under node_modules, and the lockfile resolves TypeScript 4.0.3, which cannot parse the type definitions the current Pino ships. So the compiler cannot be the proof here, and the description says so and relies on the before and after script. npm test passes, though the suite is a single placeholder test that adds two numbers.
Run it on every Linear issue labelled pino
Logging changes are filed per service and wait for a quiet week. Connect Linear under Settings → Connections and add an automation to the service's Project with a linear trigger on linear.issue.labeled, the label of your choice in labels, and the prompt above. A label added by someone in your Rush org starts a run in the Project's repository, with the issue text placed after the prompt. That is the right place for per-service facts: which fields the log platform indexes, or whether level labels must stay words.
Each automation has a cap of 1 to 30 runs per hour. A label that arrives past the cap still creates its run, as queued, and it starts when the hour has room.
The use case this job follows, with its automation and trigger: Turn a Linear label into a PR.
Why run it on Rush?
A logger swap is easy to do and hard to do safely, because its failures are silent. The service starts, requests succeed, and weeks later someone opens an incident and finds error: {} where a stack trace used to be. Catching that needs every call shape to be exercised against both libraries and the outputs compared, which is dull work that the agent does in its own sandbox with each command and its output kept in the transcript.
It is also work where reading everything pays. The password in the debug line was not part of the task, and a person changing imports file by file could pass it three times. An agent told to classify every call by what it logs reports it, and the pull request fixes it in the same change that makes redaction possible.
Frequently asked questions
Why does Pino log {} for my errors?
Because the error was passed through a placeholder such as %o. Pino serialises that argument as JSON, and an Error has no enumerable properties. Pass it as logger.error({ err }, 'message') or as the only argument, and Pino's error serializer writes its type, message and stack.
What happens to Winston's silly, verbose and http levels?
Pino's defaults are trace, debug, info, warn, error and fatal. The agent maps silly to trace and verbose and http to debug, or declares them with customLevels if you want to keep the names. A level name Pino does not know makes the logger throw at start-up, so the config default is part of the change.
Can I keep the old field names?
Yes. Pino's messageKey, timestamp and formatters.level options can produce message, a formatted timestamp and a word for the level. Say so in the prompt. The agent then shows that the new lines match the old ones field for field, which makes the migration invisible to the log platform.
Does the agent need the database to do this?
No. This service needs MongoDB to start, and the agent does not start it. It builds the logger on its own with the project's real options and calls it directly, which is enough to compare output. Routes are not exercised, and the pull request says that.
Will redaction slow logging down?
Pino compiles redact paths once when the logger is created, and a fixed path such as body.password is cheap. Wildcard paths cost more. The agent uses explicit paths for the fields it found and lists them, so the set can be reviewed.