A computational nanophotonic design library for gradient-based optimization called SPINS is presented. Borrowing the concept of computational graphs, SPINS is a design framework that emphasizes flexibility and reproducible results. The mathematical and architectural details to achieve these goals are presented, and practical considerations and heuristics for using inverse design are discussed, including the choice of initial condition and the landscape of local minima.