The idea is simple: do not hand out more power than a task needs. A cron job that reads one table should not hold a key that can delete the whole database. A support teammate who answers tickets should not be able to export every customer record.
AI coding tools tend to take the shortest path to working code, and the shortest path is often the most powerful credential available: the admin database key, a cloud role with wildcard permissions, an API token with every scope ticked. It works, so nobody revisits it, and a single leaked file then exposes everything.
Apply it in layers. Give each service its own key with only the permissions it uses. Prefer read-only access where writing is not needed. Keep the privileged database key on the server and use the restricted one in the browser. Give people roles instead of shared admin logins, and remove access when someone leaves or a feature is retired. When you cannot explain why a credential needs a permission, take the permission away and see what breaks.