CPIC: a curvilinear Particle-In-Cell code for spacecraft-plasma interaction studies. We describe a new electrostatic particle-in-cell (PIC) code in curvilinear geometry called curvilinear PIC (CPIC). The code models the microscopic (kinetic) evolution of a plasma with the PIC method, coupled with an adaptive computational grid that can conform to arbitrarily shaped domains. CPIC is particularly suited for multiscale problems associated with the interaction of complex objects with plasmas. A map is introduced between the physical space and the logical space, where the grid is uniform and Cartesian. In CPIC, most of the operations are performed in logical space. CPIC was designed following criteria of versatility, robustness, and performance. Its main features are the use of structured meshes, a scalable field solver based on the black box multigrid algorithm and a hybrid mover, where particles’ position is in logical space while the velocity is in physical space. Test examples involving the interaction of a plasma with material boundaries are presented.