Guide · Duplicates
Find the same API key in many projects
Over time one key gets pasted into several projects, and the production key often ends up in a development file too. Latchkey can tell you where the same value is stored twice.
In shortRun lk duplicates. It compares values inside Latchkey, groups the items that hold the same one, and prints what to do about each group, with the command to run where one applies: give production its own key, or combine the rest with lk combine.
Why it matters
Copies pile up. You import a second project and reuse the key. When production shares a key with development, every place that holds the development copy holds the production key too, and rotating it means finding every copy.
Latchkey stores each key as an item, so it can compare them. The comparison happens inside the app. You are never shown a value.
Find and fix them
-
Run the check
Terminal lk duplicatesIt asks for approval every time, and the approval says it is comparing values. Grants and agent-safe settings do not stand in, and agents cannot ask. Plain values and values shorter than 8 characters are left out. The result is counted by kind at the top, then one group per shared value, each with advice and, where one applies, the command to run. The app does the same under Review › Find Duplicates….
-
Give production its own key
When production shares a value with another environment, make a new key for production in the service's own dashboard. Latchkey cannot issue it for you. Then save it over the production item. The value is read from standard input or a hidden prompt, and the old one stays as a version.
Terminal lk set shop/production/STRIPE_KEYDevelopment keeps the old key, and production now has one of its own.
-
Combine a key used across projects
When the same key sits in several projects, combine the items into one shared item. The IDs here are examples.
Terminal lk combine shop/development/OPENAI_API_KEY,blog/development/OPENAI_API_KEY --into OPENAI_API_KEYOne approval does the work. Environment records point at the shared item, references are updated in the files the items were imported from, and the originals go to Recently Deleted for 30 days. If the values differ, nothing changes. The suggested name gets the first project as a prefix, such as
MANAGER_DATABASE_URL, when another group suggests the same name or a shared item already has it. -
Tidy the rest
The advice also covers two other cases. Several names for one value in one environment, such as
PGHOSTandPOSTGRES_HOST, should be one item. Identifiers rather than secrets, such as IDs, hosts and public keys, should be marked as plain values. The command for each is printed with the group.
Check the result
Run lk duplicates again to see what is left. For the projects you have not imported yet, lk import --scan ~/Projects --share-identical --dry-run shows which names hold the same value in every file that has them. It needs at least two files.
What this doesn't do
- It finds what Latchkey has stored. An env file that has not been imported is not compared; the scan check covers those.
- Combining reduces the copies. It does not make the key any less shared, so rotating it still affects every project that uses it.
- Latchkey cannot create the new production key. Stripe, GitHub, OpenAI and most services only issue keys in their own dashboards.
combinechanges nothing when the values differ, and agents cannot run it.
The duplicates and combine reference has the full option list.