| name | clean-rebuild |
| description | Cleans the SQUANDER repository of build artifacts and rebuilds from scratch. Use when switching branches, after CMakeLists.txt or C++ header changes, when the build state is broken, or before full validation runs. |
SQUANDER Clean and Rebuild
When to Use
Use this skill when:
- switching branches;
- after
CMakeLists.txt changes;
- after C++ header/interface changes;
- a build/install/import state is broken or inconsistent;
- before a full validation run.
Artifact Inventory (What Must Be Removed)
Remove these artifact categories from the repository root:
_skbuild/ (scikit-build CMake build tree)
squander.egg-info/ (editable-install metadata)
compile_commands.json (regenerated by build)
squander/**/*.so (compiled extension modules, including libqgd.so)
**/__pycache__/ (Python bytecode caches)
build/ and dist/ (packaging directories)
Do not remove squander/src-cpp/gates/squander.egg-info/ from this workflow,
because those files are tracked in git in this repository.
Full Clean Command
Run from repository root:
shopt -s globstar nullglob && rm -rf _skbuild build dist squander.egg-info compile_commands.json && rm -f squander/**/*.so && rm -rf **/__pycache__ && shopt -u globstar nullglob
Rebuild Command
Use the standard build/install sequence:
conda activate qgd
export TBB_INC_DIR=~/.conda/envs/qgd/include
export TBB_LIB_DIR=~/.conda/envs/qgd/lib
python setup.py build_ext
python -m pip install -e .
Verification (Smoke Check)
python - << 'EOF'
from squander.density_matrix import DensityMatrix, NoisyCircuit
import numpy as np
rho = DensityMatrix(qbit_num=2)
circuit = NoisyCircuit(2)
circuit.add_H(0)
circuit.add_CNOT(1, 0)
circuit.apply_to(np.array([]), rho)
print("Clean rebuild smoke test: OK")
print("Purity:", rho.purity())
EOF
Safety Notes
This cleanup removes build/runtime artifacts only. It does not remove:
- source files;
- documentation files;
- git history, branches, or commits;
- conda environments.
Canonical Reference
For dependency installation, full verification flow, and troubleshooting, use:
docs/density_matrix_project/SETUP.md