ਇੱਕ ਕੋਡਿੰਗ ਏਜੰਟ ਤੁਹਾਡੀ ਰੈਪੋਜ਼ੀਟਰੀ (repository) ਵਿੱਚ ਮਜ਼ਬੂਤ ਰਾਏ ਲੈ ਕੇ ਨਹੀਂ ਆਉਂਦਾ। ਇਹ ਜੋ ਪਹਿਲਾਂ ਤੋਂ ਉੱਥੇ ਹੈ ਉਸਨੂੰ ਪੜ੍ਹਦਾ ਹੈ, ਤਰਕ (logic) ਨੂੰ ਸਮਝਦਾ ਹੈ, ਅਤੇ ਜੋ ਰੂਪ ਉਹ ਲੱਭਦਾ ਹੈ, ਉਸੇ ਨੂੰ ਦੁਹਰਾਉਂਦਾ ਹੈ। ਜੇਕਰ ਤੁਹਾਡਾ ਡਾਟਾ ਐਕਸੈਸ ਲੇਅਰ (data access layer) ਰੋਅ SQL (raw SQL) ਅਤੇ ਡੁਪਲੀਕੇਟ ਕੁਏਰੀਆਂ ਦਾ ਇੱਕ ਗੁੰਝਲਦਾਰ ਜਾਲ ਹੈ, ਤਾਂ ਏਜੰਟ ਖੁਸ਼ੀ-ਖੁਸ਼ੀ ਇੱਕ ਹੋਰ ਗੰਢ ਲਗਾ ਦੇਵੇਗਾ। ਜੇਕਰ ਤੁਹਾਡੀ ਟੈਸਟ ਕਵਰੇਜ (test coverage) ਘੱਟ ਹੈ, ਤਾਂ ਇਹ ਘੱਟ ਟੈਸਟ ਬਣਾਏਗਾ। ਇਹ ਆਲਸ ਜਾਂ ਅਯੋਗਤਾ ਨਹੀਂ ਹੈ। ਇਹ ਪੈਟਰਨ ਮੈਚਿੰਗ (pattern matching) ਹੈ ਜੋ ਬਿਲਕੁਲ ਉਮੀਦ ਅਨੁਸਾਰ ਕੰਮ ਕਰ ਰਹੀ ਹੈ।

ਜੋ ਤੁਸੀਂ ਕਲਪਨਾ ਕਰਦੇ ਹੋ ਅਤੇ ਜੋ ਏਜੰਟ ਬਣਾਉਂਦਾ ਹੈ, ਉਸ ਵਿਚਕਾਰਲੇ ਪਾੜੇ ਨੂੰ ਘਟਾਉਣ ਲਈ ਸੰਦਰਭ (context) ਅਤੇ ਸੀਮਾਵਾਂ (constraints) ਦੀ ਲੋੜ ਹੁੰਦੀ ਹੈ, ਨਾ ਕਿ ਉੱਚੀ ਪ੍ਰੋਂਪਟ (prompts) ਜਾਂ ਸਮਾਰਟ ਮਾਡਲ ਦੀ ਇੱਛਾ ਦੀ। ਤੁਸੀਂ ਉਸ ਸਾਧਨ ਨੂੰ ਉਸ ਵਾਤਾਵਰਣ ਨੂੰ ਇੰਜੀਨੀਅਰ ਕਰਕੇ ਅਨੁਕੂਲ ਬਣਾਉਂਦੇ ਹੋ ਜਿਸ ਵਿੱਚ ਇਹ ਕੰਮ ਕਰਦਾ ਹੈ। ਇਸ ਨੂੰ ਕਰਨ ਦੇ ਛੇ ਵਿਹਾਰਕ ਤਰੀਕੇ ਇੱਥੇ ਹਨ।

ਨਕਲ ਲਈ ਰੀਫੈਕਟਰ (Refactor) ਕਰੋ

ਭਾਸ਼ਾ ਮਾਡਲ (Language models) ਜ਼ਬਾਨੀ ਹਦਾਇਤਾਂ ਦੀ ਪਾਲਣਾ ਕਰਨ ਨਾਲੋਂ ਉਦਾਹਰਣਾਂ ਤੋਂ ਬਹੁਤ ਬਿਹਤਰ ਤਰੀਕੇ ਨਾਲ ਸਿੱਖਦੇ ਹਨ। ਜੇਕਰ ਤੁਸੀਂ Claude ਨੂੰ ਪੰਜ ਵੱਖ-ਵੱਖ ਮੋਡਿਊਲ (modules) ਵੱਲ ਇਸ਼ਾਰਾ ਕਰਦੇ ਹੋ, ਜਿਨ੍ਹਾਂ ਵਿੱਚੋਂ ਹਰ ਇੱਕ ਆਪਣੇ ਖਾਸ ਤਰੀਕੇ ਨਾਲ ਡਾਟਾ ਐਕਸੈਸ ਨੂੰ ਸੰਭਾਲਦਾ ਹੈ, ਤਾਂ ਤੁਸੀਂ ਉਸਨੂੰ ਇਹ ਅੰਦਾਜ਼ਾ ਲਗਾਉਣ ਲਈ ਕਹਿ ਰਹੇ ਹੋ ਕਿ ਤੁਸੀਂ ਅਸਲ ਵਿੱਚ ਕਿਹੜਾ ਪੈਟਰਨ ਚਾਹੁੰਦੇ ਹੋ। ਨਤੀਜਾ ਆਮ ਤੌਰ 'ਤੇ ਸਾਰੇ ਪੰਜਾਂ ਦਾ ਇੱਕ ਮੱਧਮ ਮਿਸ਼ਰਣ ਹੁੰਦਾ ਹੈ।

ਇਸ ਦੀ ਬਜਾਏ, ਇਸਨੂੰ ਇੱਕ ਸਾਫ਼ ਰੈਫਰੈਂਸ (reference) ਦਿਓ। ਇੱਕ ਅਜਿਹਾ ਮੋਡਿਊਲ ਚੁਣੋ ਜੋ ਤੁਹਾਡੇ ਆਦਰਸ਼ ਢਾਂਚੇ ਦੀ ਪ੍ਰਤੀਨਿਧਤਾ ਕਰਦਾ ਹੋਵੇ। ਇਸਨੂੰ ਬੇਲੋੜੀ ਸ਼ੋਰ-ਸ਼ਰਾਬੇ ਤੋਂ ਮੁਕਤ ਕਰੋ ਤਾਂ ਜੋ ਆਰਕੀਟੈਕਚਰ (architecture) ਸਪਸ਼ਟ ਹੋ ਜਾਵੇ। ਜਦੋਂ ਤੁਸੀਂ ਕਿਸੇ ਨਵੇਂ ਫੀਚਰ ਦੀ ਮੰਗ ਕਰਦੇ ਹੋ, ਤਾਂ ਸਿੱਧਾ ਉਸ ਫਾਈਲ ਦਾ ਹਵਾਲਾ ਦਿਓ: "/src/orders/repository.py ਵਿੱਚ ਦਿੱਤੇ ਪੈਟਰਨ ਦੀ ਪਾਲਣਾ ਕਰੋ।" ਇੱਕ ਚੰਗੀ ਤਰ੍ਹਾਂ ਬਣਿਆ ਹੋਇਆ ਉਦਾਹਰਣ ਅਮੂਰਤ ਨਿਯਮਾਂ ਦੇ ਇੱਕ ਪੈਰੇ ਨਾਲੋਂ ਵੱਧ ਸੰਚਾਰ ਕਰਦਾ ਹੈ ਕਿਉਂਕਿ ਕੋਡ ਵਿਆਖਿਆ ਦੀ ਕੋਈ ਗੁੰਜਾਇਸ਼ ਨਹੀਂ ਛੱਡਦਾ। ਜੇਕਰ ਤੁਹਾਡੀ ਰੈਪੋਜ਼ੀਟਰੀ ਵਿੱਚ ਇੱਕ ਵੀ ਸਾਫ਼ ਉਦਾਹਰਣ ਨਹੀਂ ਹੈ, ਤਾਂ ਇੱਕ ਲਿਖੋ। ਇੱਕ ਸੰਖੇਪ ਰੈਫਰੈਂਸ ਇੰਪਲੀਮੈਂਟੇਸ਼ਨ (reference implementation) ਇੱਕ ਵਾਰ ਦਾ ਨਿਵੇਸ਼ ਹੈ ਜੋ ਹਰ ਅਗਲੀ ਬੇਨਤੀ 'ਤੇ ਫਾਇਦਾ ਦਿੰਦਾ ਹੈ। ਏਜੰਟ ਢਾਂਚੇ, ਐਰਰ ਹੈਂਡਲਿੰਗ ਸ਼ੈਲੀ (error handling style), ਅਤੇ ਸਪਰੇਸ਼ਨ ਆਫ ਕੰਸਰਨ (separation of concerns) ਦੀ ਨਕਲ ਕਰੇਗਾ ਕਿਉਂਕਿ ਇਹ ਇਕਲੌਤਾ ਬਲੂਪ੍ਰਿੰਟ (blueprint) ਹੈ ਜੋ ਤੁਸੀਂ ਦਿਖਾਇਆ ਹੈ।

ਪਹਿਲਾਂ ਪਲਾਨ ਮੋਡ (Plan Mode) ਦੀ ਵਰਤੋਂ ਕਰੋ

ਕੋਈ ਵੀ ਫਾਈਲ ਬਣਾਉਣ ਜਾਂ ਸੋਧਣ ਤੋਂ ਪਹਿਲਾਂ, Claude ਨੂੰ ਇੱਕ ਯੋਜਨਾ (plan) ਪ੍ਰਸਤਾਵਿਤ ਕਰਨ ਲਈ ਕਹੋ। ਇਸਨੂੰ ਠੋਸ ਬਣਾਓ: ਕਿਹੜੀਆਂ ਫਾਈਲਾਂ ਬਦਲਣਗੀਆਂ, ਕਿਹੜੇ ਫੰਕਸ਼ਨ (functions) ਜੋੜੇ ਜਾਣਗੇ, ਕਿਹੜੀਆਂ ਡਿਪੈਂਡੈਂਸੀਆਂ (dependencies) ਇੰਪੋਰਟ ਕੀਤੀਆਂ ਜਾਣਗੀਆਂ, ਅਤੇ ਨਵੇਂ ਹਿੱਸੇ ਮੌਜੂਦਾ ਗ੍ਰਾਫ (graph) ਵਿੱਚ ਕਿਵੇਂ ਫਿੱਟ ਹੁੰਦੇ ਹਨ।

ਇਹ ਕਦਮ ਇੱਕ ਮੁਫ਼ਤ ਵਿਰੋਧ-ਪਛਾਣਕਰਤਾ (contradiction detector) ਵਜੋਂ ਕੰਮ ਕਰਦਾ ਹੈ। ਜੇਕਰ Claude ਦੀ ਯੋਜਨਾ ਐਪਲੀਕੇਸ਼ਨ ਡਿਪਲਾਈਮੈਂਟ ਪਾਈਪਲਾਈਨ (application deployment pipeline) ਦੇ ਅੰਦਰ ਡਾਟਾਬੇਸ ਮਾਈਗ੍ਰੇਸ਼ਨ (database migration) ਜੋੜਨ ਦਾ ਪ੍ਰਸਤਾਵ ਦਿੰਦੀ ਹੈ, ਜਦੋਂ ਤੁਹਾਡੀ ਟੀਮ ਵੱਖਰੇ ਆਰਕੈਸਟ੍ਰੇਟਡ ਜੌਬ (orchestrated job) ਰਾਹੀਂ ਮਾਈਗ੍ਰੇਸ਼ਨ ਚਲਾਉਂਦੀ ਹੈ, ਤਾਂ ਤੁਸੀਂ ਕੋਡ ਰਿਵਿਊ (code review) ਦੌਰਾਨ ਨਹੀਂ ਬਲਕਿ ਕੁਝ ਹੀ ਸਕਿੰਟਾਂ ਵਿੱਚ ਇਸ ਗਲਤੀ ਨੂੰ ਫੜ ਲੈਂਦੇ ਹੋ। ਜੇਕਰ ਇਹ ਕਿਸੇ ਪੁਰਾਣੇ (deprecated) ਯੂਟੀਲਿਟੀ ਦੀ ਮੁੜ ਵਰਤੋਂ ਕਰਨ ਦੀ ਯੋਜਨਾ ਬਣਾਉਂਦਾ ਹੈ, ਤਾਂ ਤੁਸੀਂ ਅੱਧਾ ਫੀਚਰ ਲਿਖਣ ਤੋਂ ਪਹਿਲਾਂ ਹੀ ਇਸਨੂੰ ਰੋਕ ਸਕਦੇ ਹੋ। ਯੋਜਨਾ ਮਾਡਲ ਨੂੰ ਤੁਹਾਡੇ ਆਰਕੀਟੈਕਚਰ ਬਾਰੇ ਉਸਦੇ ਅਨੁਮਾਨਾਂ ਨੂੰ ਸਾਹਮਣੇ ਲਿਆਉਣ ਲਈ ਮਜਬੂਰ ਕਰਦੀ ਹੈ। ਇਸ ਨੂੰ ਉਸੇ ਤਰੀਕੇ ਨਾਲ ਚੁਣੌਤੀ ਦਿਓ ਜਿਵੇਂ ਤੁਸੀਂ ਇੱਕ ਜੂਨੀਅਰ ਡਿਵੈਲਪਰ ਦੇ ਡਿਜ਼ਾਈਨ ਦਸਤਾਵੇਜ਼ ਨੂੰ ਚੁਣੌਤੀ ਦਿੰਦੇ ਹੋ। ਇਸ ਵਿੱਚ ਕੁਝ ਮਿੰਟ ਲੱਗਦੇ ਹਨ ਅਤੇ ਇਹ ਨਿਯਮਤ ਤੌਰ 'ਤੇ ਖਰਾਬ ਕੋਡ ਨੂੰ ਸੁਧਾਰਨ ਦੇ ਇੱਕ ਘੰਟੇ ਦੀ ਬਚਤ ਕਰਦਾ ਹੈ।

ਜਲਦੀ ਪੂਰਾ ਸੰਦਰਭ (Context) ਪ੍ਰਦਾਨ ਕਰੋ

ਜ਼ਿਆਦਾਤਰ ਅਲਾਈਨਮੈਂਟ ਫੇਲ੍ਹ ਹੋਣ ਦੇ ਕਾਰਨ ਏਜੰਟ ਦੁਆਰਾ ਕੰਮ ਨੂੰ ਗਲਤ ਸਮਝਣਾ ਨਹੀਂ ਹੁੰਦਾ, ਸਗੋਂ ਇਸ ਲਈ ਹੁੰਦਾ ਹੈ ਕਿਉਂਕਿ ਇਹ ਗਲਤ ਸੀਮਾਵਾਂ (constraints) ਲਈ ਆਪਟੀਮਾਈਜ਼ ਕਰ ਰਿਹਾ ਸੀ। ਇੱਕ ਹੱਲ ਤਕਨੀਕੀ ਤੌਰ 'ਤੇ ਸੰਪੂਰਨ ਹੋ ਸਕਦਾ ਹੈ ਅਤੇ ਫਿਰ ਵੀ ਵਰਤੋਂ ਅਯੋਗ ਹੋ ਸਕਦਾ ਹੈ ਜੇਕਰ ਇਹ ਬਜਟ, ਲੇਟੈਂਸੀ ਦੀ ਲੋੜ (latency requirement), ਜਾਂ ਕਿਸੇ ਅਨੁਪਾਲਨ ਸੀਮਾ (compliance boundary) ਦੀ ਉਲੰਘਣਾ ਕਰਦਾ ਹੈ ਜਿਸਦਾ ਤੁਸੀਂ ਜ਼ਿਕਰ ਕਰਨਾ ਭੁੱਲ ਗਏ ਹੋ।

ਪਹਿਲੀ ਪ੍ਰੋਂਪਟ ਵਿੱਚ ਹੀ ਆਪਣੀਆਂ ਸੀਮਾਵਾਂ ਦੱਸੋ। ਜੇਕਰ ਤੁਹਾਡਾ ਐਂਡਪੁਆਇੰਟ (endpoint) 99ਵੇਂ ਪਰਸੈਂਟਾਈਲ (99th percentile) 'ਤੇ 200 ਮਿਲੀਸਕਿੰਟ ਤੋਂ ਘੱਟ ਰਹਿਣਾ ਚਾਹੀਦਾ ਹੈ, ਤਾਂ ਅਜਿ

Documentation helps, but documentation can be missed. When a rule is truly critical, move it from advice to enforcement. Use hooks, pre-commit checks, CI gates, or custom validation scripts to make hard rules impossible to break.

If every new module must have corresponding unit tests, do not just mention that in CLAUDE.md. Configure a coverage gate that fails the build when a file in /src lands without a matching test. If your security policy forbids committing secrets, run a scanner that blocks the push. If your team requires specific import ordering or lint rules, automate the fix with a pre-commit hook. These mechanisms catch Claude's output the same way they catch yours. They remove the possibility of human oversight or model drift and replace "please remember" with "cannot proceed." A rule that is not enforced is merely a suggestion.

Run Independent Reviewers

Self-review is unreliable. When Claude checks its own work, it often confirms its own assumptions because it generated them in the first place. The fix is to bring in fresh eyes, even if those eyes belong to the same model running under a different charter.

Spin up separate reviewer agents with narrow, explicit focus. Ask one to audit strictly for security: are there injection risks, exposed internal endpoints, or unsafe deserializations? Ask another to evaluate test coverage and edge cases. A third might verify that the change respects the rules defined in CLAUDE.md. These reviewers do not need complex custom models. They simply need independence from the original generation step. The friction of asking someone—or something—else to look at the code catches assumptions that felt obvious to the builder. The extra token cost is negligible compared to the price of a bug reaching production.

The Loop

Alignment is not a project you finish. It is a loop you maintain. Every time you correct Claude's output, ask whether that correction could become a new entry in your CLAUDE.md or a new gate in your tooling. If you make the same fix twice, you have found a gap in your system. Plug it permanently.

Over weeks, this practice compounds. The agent stops guessing and starts following the grooves you have carved. The codebase begins to feel like it codes itself because the constraints are clear, the examples are clean, and the rules are mechanical. Your job shifts from correction to curation.

Source: https://dev.to/az365ai/how-to-align-claude-code-with-your-codebase-6-techniques-2026-3k28

Optional learning community: https://t.me/GyaanSetuAi