Version Control and Developer Tooling Questions
The everyday toolchain of software work: version control with Git (branching, merging, rebasing, conflict resolution, using git bisect to find a regression), command-line and shell proficiency for day-to-day navigation, log inspection, and troubleshooting, IDE and editor workflows, build systems and package/dependency management (npm, Maven, pip, Gradle, CocoaPods, and embedded/cross-compilation toolchains), and the growing practice of AI-assisted coding: using, reviewing, and verifying AI-generated code and tests. Deliberately generic across languages and stacks; language- and domain-specific frameworks live in their own categories. This topic covers a developer's individual command of these tools, not: writing durable shell automation and glue scripts (Shell Scripting and Automation owns that), producing, versioning, and publishing build artifacts or container images (Build Automation and Artifact Management owns that), release cadence and change governance (Release Management and Change Control owns that), or diagnosing a live production incident end to end (Performance Troubleshooting and Incident Response and the Observability topics own that).
main is protected and requires review plus passing CI before merge, but you need to ship an urgent hotfix to production right now. Walk through how you'd get the fix out safely without bypassing the protections that exist for good reason, and how you'd keep the team informed.
Sample Answer
Direct answer
Don't bypass the protections, compress the same process into a fast, prioritized path instead: branch off main, make the smallest fix that actually addresses the issue, get a real but expedited review, let CI run, merge normally once both pass, and communicate loudly before, during, and after so nobody duplicates the fix or gets surprised by it landing.
Structured elaboration
1. Branch from the right base. git checkout -b hotfix/checkout-500 main (or from the currently-deployed release tag if main has since moved ahead of what's actually in production).
2. Keep the diff minimal. Fix the specific issue only, no drive-by refactoring or cleanup bundled in. A smaller diff is faster to review genuinely well and carries lower regression risk, exactly what you want under time pressure.
3. Get a real review, just an expedited one. Open the PR immediately, mark it clearly (a [HOTFIX] prefix or a dedicated label), and directly page or ping the on-call reviewer rather than letting it sit in the normal queue. If the protected-branch rule requires human approval, get that approval synchronously, a quick screen-share or pairing session, rather than skipping it. The review step is exactly the safeguard you want to keep, not cut, when you're moving fast under pressure.
4. Let CI actually run. If the team has a pre-agreed, legitimately-scoped "critical-path-only" CI profile for genuine emergencies, use it. Don't disable required checks in the branch-protection settings themselves as a shortcut, that's a configuration change that typically needs its own approval and is easy to forget to revert afterward, leaving the branch under-protected long after the emergency has passed.
5. Merge and deploy through the normal path. Once approvals and checks pass, merge the same way any other change does, then deploy via the standard pipeline (or an expedited manual trigger, if one legitimately exists) rather than pushing directly to a server.
6. Communicate at every step. Post in the incident or on-call channel before starting ("working a hotfix for the checkout 500 error, branch is hotfix/checkout-500"), link the PR so it's visible, confirm once it's deployed, and follow up with a short retro note. Back-merge or cherry-pick the fix into any other active release or long-lived branches too, otherwise the bug quietly returns the next time one of those branches ships.
Worked example
An on-call engineer notices checkouts are failing with a 500 error. They branch hotfix/checkout-500 off main, isolate the fix to the one function causing the failure, open a PR tagged [HOTFIX], and page a teammate for immediate review over a quick call rather than waiting for the async review queue. CI runs the same required checks as any other PR. Once approved and green, the PR merges normally and deploys through the standard pipeline. The engineer posts a short update in the incident channel confirming the fix is live, then separately checks whether any active release branch also needs the same fix cherry-picked in.
Trade-offs and pitfalls
The temptation under real pressure is to grant yourself an admin override and push straight to main, "just this once." That erodes the protection for everyone going forward and sets a precedent that the rules are optional when things feel urgent, exactly when they matter most. In practice, an unreviewed hotfix has caused as many outages as the bug it was meant to fix, skipping review to save a few minutes is a bad trade against that risk. The most commonly missed step isn't the fix itself, it's forgetting to back-port it into other active branches (release branches, long-lived version branches), which means the same bug quietly resurfaces at the next release from one of those.
How would you use an AI tool to draft unit tests for a feature preprocessing function, and what edge cases must you add manually so the tests do not create false confidence?
Sample Answer
Direct answer
I would let the AI tool draft the happy-path tests first, the normal, expected-input cases, since that is what it is genuinely good at, and then add the edge cases myself: empty input, missing values across an entire column, out-of-range values, and anything that reveals a design decision the function never actually made explicit. The reason this matters is that AI-generated tests tend to mirror the implementation rather than the specification, so a test suite that only exercises the happy path can pass at 100% while still creating false confidence about what the function actually does when it meets bad input.
Worked example
Take a small preprocessing function that clips an age value into a valid range and fills missing values with the median of the values present in the batch:
def clean_age(records):
"""AI-drafted happy-path preprocessing: clip age to [0, 120] and fill
missing values with the median of the present values. Returns a new list."""
present = sorted(r["age"] for r in records if r.get("age") is not None)
n = len(present)
if n == 0:
median = 0
elif n % 2 == 1:
median = present[n // 2]
else:
median = (present[n // 2 - 1] + present[n // 2]) / 2
cleaned = []
for r in records:
age = r.get("age")
if age is None:
age = median
age = max(0, min(120, age))
cleaned.append({**r, "age": age})
return cleaned
# --- AI-drafted happy-path tests ---
def test_normal_values():
out = clean_age([{"age": 25}, {"age": 40}])
assert out == [{"age": 25}, {"age": 40}]
def test_fills_missing_with_median():
out = clean_age([{"age": 20}, {"age": 30}, {"age": None}])
assert out[2]["age"] == 25 # true median of [20, 30] is (20+30)/2 = 25
# --- Manually added edge cases the draft did not cover ---
def test_empty_input():
assert clean_age([]) == []
def test_all_missing_column():
out = clean_age([{"age": None}, {"age": None}])
assert out == [{"age": 0}, {"age": 0}] # median fallback exposes a real bug
def test_out_of_range_clips():
out = clean_age([{"age": -5}, {"age": 999}])
assert out == [{"age": 0}, {"age": 120}]
for name, fn in list(globals().items()):
if name.startswith("test_"):
fn()
print(f"{name}: PASS")
Running this actually prints:
test_normal_values: PASS
test_fills_missing_with_median: PASS
test_empty_input: PASS
test_all_missing_column: PASS
test_out_of_range_clips: PASS
Every test passes, including the two AI-drafted happy-path tests, so a quick look would suggest the function is solid. But test_all_missing_column is the one that exposes the real problem: when an entire batch has no age values at all, the function silently defaults every row to age 0 rather than raising an error or flagging the column as unusable. That is exactly the kind of false confidence a happy-path-only test suite creates: every test is green, and the function still has a design bug that would quietly corrupt downstream predictions if it ever hit a batch missing that entire column in production.
Edge cases to add manually
- Empty input entirely.
- An entire column of missing values (not just one missing value among many present ones), since that changes the fallback behavior in ways a single missing value never exercises.
- Out-of-range and boundary values, to confirm clipping actually happens where you expect it, including at the exact boundary (0 and 120 themselves).
- Duplicate rows or an unexpectedly missing required column, if the function assumes a fixed schema.
- An aggregate statistic (like a median) computed over an even number of present values, checked against its actual mathematical definition rather than against whatever the first implementation happens to output, since a naive
sorted(x)[len(x)//2]silently returns the upper-middle element instead of the true average for even-length input. - Anything the function does implicitly that was never specified: here, "what happens when there is no data to compute a median from" was never in the spec, and the AI-drafted tests never exercised it.
Trade-offs and pitfalls
Relying only on AI-drafted tests optimizes for coverage of the code as written, which is circular: the tests confirm the implementation matches itself, not that the implementation matches the actual business requirement. Good tests should break when the intended behavior changes, not only when the syntax changes, and that discipline is exactly what the manually added edge cases above are for.
Describe the version control and branching strategies you used (git flow, trunk-based, feature branches). For a project where you were the feature owner, explain the exact workflow from branch creation to release, including PR review rules, CI gates, and merge policies.
Sample Answer
Direct answer
Three strategies cover most real teams: git flow's long-lived branches for slower, versioned releases; trunk-based development's very short-lived branches for continuous deployment; and plain feature branches off main, the common middle ground for most web and SaaS teams. As a feature owner, the workflow is branch, small commits with CI on every push, an early draft pull request, at least one required approval plus green checks, then merge and delete the branch.
Structured elaboration
- Git flow (long-lived
developplusreleaseandhotfixbranches alongsidefeature/*) fits teams shipping versioned, installable software on a slower cadence, for example a desktop application with numbered releases. The overhead of multiple long-lived branches buys a stable release line that can be patched independently of ongoing development. - Trunk-based development (very short-lived branches, often merged within a day or two, incomplete work hidden behind feature flags) fits teams doing continuous deployment. It minimizes merge conflicts by keeping divergence small, at the cost of needing feature flags for anything not ready to ship.
- Plain feature branches off
mainwith pull-request review is the most common real-world default for web and SaaS teams: no formaldeveloporreleasebranches, but a branch can live for the length of a feature, days to a couple of weeks. It avoids git flow's ceremony without demanding trunk-based development's discipline of flagging everything.
Worked example
This is an illustrative, composite account of a typical feature-owner workflow under the "feature branches" strategy, not a specific verifiable metric.
As the owner of a feature to add saved search filters, I branched feature/saved-search off main, aiming to keep it short-lived and merge within about a week. I opened the pull request as a draft on day one so teammates could see the direction early rather than review a finished wall of code. CI ran on every push, type checking, the unit test suite, and a lint gate, and the branch could not merge with a red check. Once the feature was functionally complete, I marked the PR ready for review and requested a teammate familiar with that part of the codebase as the required approver; our policy was at least one approval plus green CI before merge. Review turned up a real edge case, an empty filter set was not handled, and I pushed the fix as a new commit rather than rewriting history mid-review, so the reviewer's earlier comments stayed anchored to the right lines. Once approved, I squash-merged into main, collapsing many small "wip" commits into one clean commit with a summary message, and deleted the branch immediately after merge.
Trade-offs & pitfalls
- Letting a feature branch live too long, weeks instead of days, reintroduces exactly the merge-conflict pain trunk-based development exists to avoid, even under a plain feature-branch strategy. The shorter the branch lives, the smaller the eventual merge or rebase against
main. - Squash-merging trades a clean
mainhistory for losing the granular, commit-by-commit story of how the feature was actually built. Some teams prefer a regular merge commit, or rebase-and-merge, specifically to keep that history; there is no universally right answer, it is a team convention to agree on and enforce consistently. - Skipping a required CI gate "just this once" for a hotfix is how a broken build reaches
main. The gate has to apply uniformly or it stops meaning anything.
You ask an AI assistant to modify a function in an existing codebase, but it quietly changes the function's signature and breaks several callers elsewhere in the code. What safeguards would you put in place to catch this before merging, and how would you preserve interfaces and backward compatibility when accepting AI-generated changes going forward?
Sample Answer
Direct answer
I would put safeguards in place before the change ever lands in the main branch, not rely on catching it in review by eye: an explicit "do not change the signature" constraint in the prompt, a search across the codebase for every caller of the function being touched, and a CI (continuous integration) check that actually exercises those callers. Catching a broken signature by carefully reading a diff does not scale, since the break is often invisible in the diff of the function itself, it only shows up as a failure somewhere else entirely.
Structured elaboration
Preventing it at the prompt level
- Constrain the request explicitly: "modify the internal logic but do not change the function's name, parameter order, parameter names, or return type," rather than a general "improve this function" that leaves the interface up for grabs.
- Provide the function's current callers as context, so the assistant can see what would break, rather than reasoning about the function in isolation.
Catching it before merge
- Search the codebase for every call site of the changed function before approving the change (a simple text or symbol search, or an IDE's find-references), and confirm each one still matches the new signature.
- Run the full test suite, including integration tests that exercise the function through its real callers, not only unit tests that call the function directly with hand-picked arguments a test author already expects to work.
- Add a lightweight contract check where the interface is easy to characterize: a type-checked function signature, or a small test that specifically asserts the function's signature has not changed, so a future AI-assisted change trips this test immediately rather than being caught downstream.
Preserving backward compatibility going forward
- Default to additive changes: add a new optional parameter with a default rather than changing an existing required one, so old call sites keep working unmodified.
- When a breaking change is genuinely necessary, use a wrapper or adapter function that preserves the old signature and forwards to the new one, and version the interface explicitly if it is public.
- Require an explicit compatibility note in any pull request that touches a function with more than a couple of callers: what changed, who is affected, and how it was validated, so a reviewer does not have to reconstruct that from the diff alone.
Preserving behavior after a pure refactor
A pure refactor (same signature, intended to be behavior-preserving, done purely for readability) has its own distinct checklist beyond signature preservation: confirm the output is identical on a representative set of real inputs, not just that the code compiles; check latency has not regressed, since a "cleaner" rewrite can accidentally introduce an expensive operation inside a loop that used to be outside it; and check error handling specifically, since a refactor is a common place for an exception type or an edge-case branch to silently disappear during a rewrite that otherwise looks like a pure simplification.
Worked example
An AI assistant is asked to "clean up" a function parse_config(path) used in six places across the codebase. It returns a cleaner implementation, but the new version returns None on a missing file instead of raising a FileNotFoundError the way the original did, a behavior change with no signature change at all, so a caller relying on the exception (a try/except FileNotFoundError block elsewhere) now gets a silent None instead, and fails later in a way that is much harder to trace back to this change. A signature-only check would miss this entirely, which is exactly why behavior and error-handling checks matter as a separate step from an interface check, and why "did the tests pass" is not sufficient if none of the six callers had a test covering the missing-file case.
Trade-offs and pitfalls
Contract tests and full-codebase caller searches add real time to every review, which can feel excessive for a function with one caller. The safeguards are worth scaling to the function's actual blast radius: a private helper used in one place needs a lighter check than a function called from a dozen places across the codebase, and treating every change with maximum ceremony trains people to skip the ceremony rather than actually protecting the changes that matter most.
Your organization uses forks extensively. Describe a workflow for contributing to an upstream repository from a fork that minimizes merge conflicts and supports CI validation. Include how to keep forks up-to-date, how to create PRs against upstream, and how automation (CI) should be configured to run tests for forked PRs without leaking secrets.
Sample Answer
Direct answer
Add the original project as a second remote, conventionally named upstream, alongside your fork's own remote (origin). Regularly sync your fork's default branch from upstream before branching, keep feature branches short-lived and rebased on the latest upstream branch before opening a pull request, and configure CI so pull requests from forks run tests safely without ever exposing real secrets to code you don't control.
Structured elaboration and worked example
- Set up the remotes once, per clone:
git remote add upstream git@github.com:org/repo.git
git remote -v # confirms origin (your fork) and upstream (the real project)
A common mechanical snag: if you already have a remote called upstream pointing at something else, git remote add upstream ... fails outright. Use a different name (git remote add project-upstream ...) or git remote remove upstream first if the existing one is stale. A second common snag is a differing default branch name: your fork might default to main while upstream still uses master, or the reverse, so always check upstream's actual default branch rather than assuming it matches your fork's.
- Keep your fork's default branch current before branching off it:
git fetch upstream
git checkout main
git merge upstream/main
git push origin main
- Rebase your feature branch onto the latest upstream before opening or updating a pull request, so conflicts surface early and in small pieces instead of all at once at review time:
git fetch upstream
git checkout feature/my-change
git rebase upstream/main
git push --force-with-lease origin feature/my-change
- Open the pull request from your fork's branch against
upstream's default branch, keeping the diff small and focused.
CI for forked pull requests without leaking secrets
Most CI platforms, GitHub Actions among them, already mask or withhold repository secrets from workflows triggered by a pull request originating from a fork, specifically because a forked PR's workflow file is attacker-controlled content that hasn't been reviewed yet. Build on that default rather than fighting it:
- Run a public tier automatically on every forked pull request: unit tests, linting, build, with no privileged secrets available to that job at all.
- Gate anything that genuinely needs credentials, integration tests against a real staging environment or a deploy preview, behind a maintainer action, for example a second workflow that only runs after a maintainer reviews the diff and manually triggers it, so untrusted code never executes with privileged access.
Trade-offs and pitfalls
Forgetting to sync and rebase before opening a pull request is the single biggest source of unnecessary conflicts in a fork-heavy workflow, since a fork's branch quietly drifts from upstream the entire time it sits open. Granting forked-PR workflows broad secret access "just to make CI green" is exactly the mistake that lets an attacker-controlled pull request exfiltrate credentials; the fix is to keep the untrusted tier genuinely unprivileged rather than loosening it under pressure to unblock a contributor.
Unlock Full Question Bank
Get access to all Version Control and Developer Tooling interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.