---
id: TASK-4.1
title: Implement compile_commands.json symlink creation for default build profile
status: Done
assignee:
  - codex
created_date: '2026-01-30 09:02'
updated_date: '2026-01-30 09:09'
labels:
  - build
  - profiles
  - lsp
  - compile-commands
dependencies: []
references:
  - lua/zync/
  - bin/zync
parent_task_id: TASK-4
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
Add behavior to ensure a compile_commands.json symlink exists in root/build when build profiles are configured, using the default/first profile, and only for commands other than init/boards/runners/profiles.
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 When build profiles are configured, running any command other than init, boards, runners, or profiles ensures a compile_commands.json symlink exists under root/build pointing to the default/first profile's compile_commands.json.
- [x] #2 If the symlink already exists under root/build, it is left unchanged (idempotent behavior).
- [x] #3 If build profiles are not configured, no compile_commands.json symlink is created in root/build.
<!-- AC:END -->

## Implementation Plan

<!-- SECTION:PLAN:BEGIN -->
- Identify the command entrypoint/dispatcher and where non-excluded commands run (likely bin/zync or a central runner module).
- Trace build profile configuration to find how the default/first profile and its build directory are derived.
- Implement a helper to ensure root/build/compile_commands.json is a symlink to <default_profile_build_dir>/compile_commands.json when profiles are configured; keep it idempotent and no-op when profiles are absent.
- Invoke the helper for all commands except init, boards, runners, and profiles.
<!-- SECTION:PLAN:END -->

## Implementation Notes

<!-- SECTION:NOTES:BEGIN -->
Plan approved by user on 2026-01-30.

Implemented compile_commands.json symlink creation in `lua/zync/api.lua`, guarded by profile configuration and excluded commands. Ensures link uses default/first profile and is idempotent.
<!-- SECTION:NOTES:END -->
