The phase behavior of shale fluids is different from conventional reservoir fluids due to fluid adsorption and capillary pressure. The miscibility phenomenon between CO 2 and oil in nanopores is also changed during CO 2 injection for enhanced shale oil recovery (EOR). The objective of this work is to develop a general framework of a theoretical algorithm and model to study the phase behavior and miscibility of CO 2 −hydrocarbon mixtures in shale formations. First, an improved vapor−liquid equilibrium calculation model is proposed to determine the phase behavior of confined fluids by incorporating capillary pressure with an adsorption-dependent equation of state. Second, by introducing the critical point judgment, a novel vanishing interfacial tension algorithm is developed to calculate the minimum miscibility pressure (MMP) of the CO 2 −Bakken oil system in bulk and nanopores. The effect of fluid adsorption and critical property shifts is considered in nature in the model and algorithm. Results show that the nanopore confinement decreases the vapor−liquid composition and density difference, and thus induces the reduction of interfacial tension (IFT). With the decrease of pore size, the IFT decreases sharply, while the capillary pressure first increases under larger pore sizes and then decreases under smaller pore sizes. When fluid adsorption is considered, the IFT and capillary pressure will be further reduced. The MMP of Bakken oil and CO 2 is reduced from 20.2 MPa at 50 nm pores to 17.5 MPa at 20 nm pores. Hence, the reduction of pore size leads to a decrease in MMP, which is beneficial for CO 2 -EOR.