Using notions of metric derivative and local Lipschitz constant, we define action integral and Hamiltonian operator for a class of optimal control problems on curves in metric spaces. We require the space to have a geodesic property (or more generally, length space property). Examples of such space includes space of probability measures in R^d and Banach spaces which are not necessarily separable, among others. A well-posedness theory is developed for first order Hamilton-Jacobi equation in this context. Time permitting, I will explain an application which relates to variational formulation of a compressible Euler equation. Using a metric version of tangent cone concept, I will explain why earlier attempts failed on well-posedness of an associated Hamilton-Jacobi equation in space of probability measures. Such result is now established as a consequence of the metric result. This is joint work with Luigi Ambrosio.