Use context engineering to troubleshoot online issues.
I recently dealt with a production issue on a legacy project, which gave me some insights into how AI coding tools like Claude and Codex can be used to diagnose problems in online environments.
Background: An old project I'm not familiar with
This issue stems from a project that was completed several years ago. The project itself is no longer the team's primary focus, but some clients continue to use it.
These types of projects have several typical characteristics:
- The front-end, back-end, app, and firmware all have their own code and logic.
- The deployment methods and operating environments may no longer be the ones the team is most familiar with on a daily basis.
- The original developers may not be readily available for questioning.
- The document may be incomplete or may have deviated from the current online status.
- The customer is still using it, so the problem must be located and resolved as soon as possible.
I'm not familiar with this project myself, and I don't have the time to learn its complete architecture and basic principles from scratch. The client's problem: a user could use it the day before, but the next day the operation buttons stopped appearing on the page. The backend configuration looks normal, and there are no obvious errors in the server-side API. Ideally, I should quickly review the on-site video, check the logs, understand the process flow, and then provide a diagnosis as soon as possible.
This is also the point I most want to share: how to quickly get AI coding tools like Claude/Codex up and actually help when you're unfamiliar with the project.
First thing: Provide as much complete code context as possible.
For complex systems, simply providing backend code is usually insufficient.
If the problem involves an end-to-end link, it's best to let the AI see all the relevant code:
- Front-end code
- Backend code
- App code
- SDK code
- Firmware or device-side protocol code
Don't worry about the AI reading all the code at once; its capabilities are sufficient for deep searching, navigation, and correlation when necessary. Deployment scripts, configuration files, API documentation, and historical investigation records—these are actually unnecessary. Because the conclusions can be drawn from the code itself. Using code as a Single Source of Truth is better.
The second thing: Provide the client with the project background and deployment method.
Beyond the code, business logic and deployment context are also needed. This includes information such as the customer's tenant name, account list, and permission configuration. However, providing this information is cumbersome because I'm not entirely sure whether the customer's specific configurations are standardized or customized. The only information I can provide is the customer's tenant ID and the affected user IDs. The AI needs to retrieve the rest from the backend or database based on the code's usage path. At the time, there were roughly three options.
The first method is to allow the AI to directly access the production database. The second method is to call the production environment API. The third method is to allow the AI to log in to the browser using my account and directly view the customer's project configuration.
I ultimately chose the third option, not because any particular option was better, but because this method was the simplest. It didn't require an API key or a read-only database account.
This uses Chrome Dev Tools MCP.
The third thing: Tell the AI where the logs are and give it CLI.
This time I used the CLI for observing clouds.
When troubleshooting production issues, log locations are crucial. It's best to clearly tell the AI where the backend API logs, App logs, frontend monitoring logs, device or firmware logs, and third-party call logs are located, what the key fields in these logs are, and request id how user id they device id are related.
If the log volume is small, it can be directly exported to the AI. However, real production logs are often very large and cannot be stuffed into the chat window all at once. This is where CLI becomes crucial.
The value of CLI lies in the fact that AI doesn't need me to manually copy large amounts of logs for it; instead, it can directly query the cloud log repository. This transforms AI from passively reading to actively querying.
The effectiveness of AI-assisted automatic screening:
It meticulously examined every log entry: whether permission prefetching was successful, whether the app went offline, whether Bluetooth scanning occurred, whether the target device was detected, whether a local session was created, whether a connection was established, whether a token was written, and whether the final event was reported. I condensed several days' worth of work into half an hour and provided very accurate conclusions.
After an investigation is completed, if all conclusions are only kept in chat logs, they will be quickly lost. Compound Engineering's SKILL tool can be used to document solutions and create reusable experience.
Key takeaways
First, AI needs complete context: code, project background, deployment method, business scenario, key concepts, and time window. Second, provide AI with tools to access the site, especially a log query CLI. Without log entry points, AI can only guess; with a CLI, it can systematically eliminate possibilities. Third, when direct database access is not possible, allow AI to view backend pages via Chrome DevTools MCP. The backend itself is an interpretation layer of business configurations. Fourth, use visual models whenever possible. Many backend configurations are not JSON but tables, labels, statuses, buttons, and pop-ups. Fifth, the human role is not to manually check every line of logs, but to fill in the context and review the AI's action path. Finally, after the investigation, the conclusions should be documented in a solution document, turning this context into reusable experience for future use.
