Proof that $\frac{1}{T}$ is the integrating factor for $dq$ Consider the first law of thermodynamics,
$$ dU = dq +dw$$
simplfying,
$$ dU + P_{\text{ext}} dV = dq$$
Now we can say that $ q $ is a function of $ U$ and $V$
$ dq(U,V) = dU + P_{\text{ext}} dV$

For a differential $dF(x,y) = A\, dx + B\, dy $ to be exact,
$$ \frac{\partial A}{\partial y} = \frac{\partial B}{\partial x}$$ is a necessary  condition.

Clearly the  function $q(U,V)$ doesn't obey this definition, and hence, let us multiply both sides by an integrating factor $ \phi(U,V)$ such that the condition of exact differential is satisfied.
$$  \phi(U,V) \, dq = \phi(U,V) \, dU + \phi(U,V) P_{\text{ext}} \, dV$$
For this to be exact,
$$ \frac{ \partial \phi(U,V) P_{\text{ext}} }{\partial U} = \frac{\partial \phi(U,V) }{\partial V}$$
Which leads to:
$$ \left( \frac{\partial P_{\text{ext}} }{ \partial U} \right)_V \phi + P_{\text{ext}}(\frac{\partial \phi}{\partial U})_V =(\frac{\partial  \phi}{\partial V})_U $$
Now, I'm not sure how to get a general solution for the above partial differential equation...

My real goal is to derive the expression for entropy at end and prove that $ \frac{1}{T}$ is the integrating factor but I'm a bit stuck. I've seen the proof that $ \frac{1}{T}$ is the integrating factor by people pointing to carnots theorem that the circulation of the differentials over a loop is zero but I wanted to derive it using differential equations.
Now, I'm thinking of how I can include the assumption that the process is reversible because the entropy definition is written used $ dq_{\text{rev}}$; also maybe derive the entropy generation term.
Any hints?

Reference for integrating factors
 A: The choise of the extensive quantities $(U,V)$ as state variables is appropriate,
but of course $Q$ is not a state function.
It is better to start from the equation of a reversible adiabatic transformation:
$$ dU + p(U,V) dV = 0 $$
If $p(U, V)$ is a known state function of the thermodynamic system the differential equation is integrable and
the integration can be carried out with the method of the integrating factor $F(U,V)$:
$$ {{dU + p(U,V)dV} \over {F(U,V)}} = dS(U,V) \qquad {where:} \quad
 {\partial{}\over \partial{V}}  \left({1}\over{F}\right) = {\partial{}\over\partial{U}} \left({p}\over{F}\right) $$
The differential calculus asserts that integrating factors can always be found and therefore
the equation of a reversible adiabatic transformation can be written in the form:
$$ S(U,V) = const $$
where S is a state function such that:
$$ {\partial{S}\over\partial{U}} = {{1}\over{F}} \qquad {\partial{S}\over\partial{V}}={{p}\over{F}} $$
Now stop with math! Physical arguments allow to prove that exists
an universal integrating factor (independent of the particular system considered!)
called absolute thermodynamic temperature $T$ and that this factor is directly proportional to the absolute temperature
defined by the gas thermometer.
For this discussion I must refer to the section 6 of an italian link
(unfortunately I haven't had time to translate the pdf into English so far):
http://pangloss.ilbello.com/Fisica/Termodinamica/lavoro_calore.pdf
In this way the goal of defining entropy by differential means is achieved:
$$ dS(U,V) = {{dU + p(U,V)dV}\over{T}} = {dQ \over T} $$
