Vague definitions of work and heat I have seen several posts discussing difference between heat and work on this website, e.g. (link 1) and (link 2). However, none of them gives a clear picture to me.
The posts and Callen's textbook distinguish heat from work as follows:
$$dU =dE_{\,macroscopic}+TdS$$.
In other words, while both work and heat represent a flow of energy,

Work: coherently transferred & accompanies changes in macroscopic degrees of freedom
Heat: incoherently transferred & related with atomic (hidden) degrees of freedom

However, I think I need more than those explanations to distinguish heat from work. Let me give you an example.
Think of an isolated box containing dielectric particles that do not move. If we apply external electric field on the box, we may observe electric polarization.
Since the field affect all the particles coherently (as a surrounding coherently compresses volume of ideal particles during an adiabatic compression) and we can detect a macroscopic change (electric polarization), the field transfers energy in a form of work, i.e. electric work.
Is that mean $TdS=0$? No, because the number of possible microstates increases; each particle can have more diverse polarization states. If you are not convinced, think of $N$ quantum harmonic oscillators. If we give more energy to them, the entropy of oscillators increases, since each oscillator can have more diverse modes.
Then, we have a paradox here. The external field transferred electric work to the system,
$$dU=dE_{\,electrical}$$
, but
$$TdS\neq 0$$. Which form does the energy transferred by the field have? Heat or work? How can I distinguish work from heat?

For those who think the paradox is related with possible irreversibility of work:
In an adiabatic compression of ideal gas particles, heat is zero ($dS=0$), since

Increase of momentum phase space volume = decrease of coordinate phase space volume.

Similarly, if we apply generalized work $fdX$ (e.g. electric work, $\vec{E} \cdot d\vec{P}$) on a system both reversibly and adiabatically,

Increase/decrease of phase space volume due to the change in coordinate $X$ should be compensated by "something".

Otherwise, $fdX$ changes entropy, i.e. $fdX$ can be both heat and work. Then, what is "something"?
 A: To avoid cyclic-thinking, one need to go back to the basics, and there is nothing more basic to me in physics than mechanics. It is probably the most self explanatory branch of physics, maybe because we are overwhelmingly merged with it in our everyday life.
There we have a concept called work, which has being defined as
$$\mathrm{d}W=F\mathrm{d}x \tag{1}$$
A good thing about physics is that almost every branch of it, with proper arrangement, has an equivalent to equation (1). It is not really hard to show (as I did it here), that for an isolated thermodynamic system, the equivalent of (1) is
$$\mathrm{d}W_{expanding}=p\mathrm{d}V \tag{2}$$
Where, $p$ and $V$ are the system's pressure and volume. What I didn’t mention there is that equation (2) only works when the systems is allowed to expand. However, an isolated non-expanding system can perform work as well; just imagine the case of a boiler, a turbine and a condenser connected to the boiler, spilling the condensed water into it in a cyclic way. The turbine will perform rotational work. It can be mathematically and experimentally proven that the work performed by such a system is 
$$\mathrm{d}W_{shaft}=V \mathrm{d}p \tag{3}$$
Where $\mathrm{d}p$ is the drop in pressure at the opposite sides of the turbine. This is the thermodynamics equivalent to mechanical rotational work.
So, you can stick with those for the thermodynamic work performed by an isolated system. In (link 2) and in your question, it seems that you guys are trying to identify the thermodynamic work at an atomic level. Please notice that thermodynamics explicitly is about not knowing the atomic level details as Danu’s comment in (link 1).
Now that work has been defined from mechanical basis, lets proceed to heat. Again, other good thing about physics is that every process seems to have a definite amount of work budget. In other words the amount of work that any process performs seems to be pre-defined. This pre-defined budged of work, is what we call energy, so if work is the final project, energy is the budget approved to build it.
If we derivate the ideal gas equation
$$pV=Nk_BT \tag{4}$$
We get 
$$\mathrm{d}(pV)=p \mathrm{d}V+V \mathrm{d}p= \mathrm{Nk_Bd}T  \tag{5}$$
Equation (5) solves our problem, because the left side of that equation can be clearly identified as change in work, so the right side should mean change in energy just like everywhere else in physics. Now that we identified temperature to some sort of energy and that by experience we now that to increase the temperature of a system we must heat it up, we can easily define heat as
$$\mathrm{d}Q=c \mathrm{d}T \tag{6}$$
Where $c$ is a proportionality constant between heat and temperature to account for the experimental fact that different materials have different work budgets for the same change in temperature and that $k_B$ don’t take into account.
The problem with $W_{shaft}$ is that it is not reversible. For a clear definition of entropy using a Carnot type machine one needs a simplified system that only uses reversible work-energy balance, so
$$δQ_{rev}=dU+p \mathrm{d}V=T\mathrm{d}S \tag{7}$$
However, the total energy-work conservation equation is 
$$ δQ_{total}=dH=dU+ p \mathrm{d}V+ V \mathrm{d}p= T \mathrm{d}S+ V \mathrm{d}p \tag{8}$$
So now, you have consistent definitions for work, heat and entropy.
