This is huge. If you move out of the marital/joint residence and leave your child with the other spouse, you are essentially giving away custody. This sounds so simple but many people make this mistake. You can't move out without your child--period. No matter how bad the situation with your partner, you need to maintain your living arrangement with the child(ren). Find a way to make it work. Sleep in another room or on the couch. Not only does this make the most sense from a custody stand point, but it saves you money by not having to rent another apartment. If you have decided that moving out of the joint residence is what you need to do, make sure you get the other's spouse's consent in writing to do so. You don't have to write up a formal agreement they will sign (because they likely will not due to everyone's skepticism in signing documents). However, you can ask them in an email to respond to your request to move out with the children. If they email or text you that it o
Don't let the child(ren) leave
This is more difficult to control than your ability to stay in the marital/joint residence with your partner and children. First, if it is clear that you are getting divorced or separating from your spouse/co-parent, then make it very clear to them that they cannot leave your joint residence without your permission. Make this clear in several emails that you do not consent to the children's removal. Your partner/spouse, can move out, but the kids need to stay until at least the case is resolved. You should also file a Petition for Dissolution of your marriage or Petition for Custody (for unmarried couples) right away and have your spouse served. If your spouse moves out with the children behind your back, then you will have a good case for a court to bring them back on an emergency basis. You will have an email stating you don't agree for them to leave and you will also have a case pending which will allow you to go to court immediately and not have to wait and file a case. Fail
Don't defer to the other parent
Why would a court want to give custody to a parent who defers to the other spouse in regard to the children's needs? You're right, they won't. Have you spoke to the children's teachers? Do you schedule doctor's appointments? Do you sign the children up for activities? Do you spend time with your children? Do you take them to buy clothes? Do you take them to buy school supplies? Do you attend their school events/extra-curricular activities? If you answered "no" to any of these questions, then you have a problem and are probably not going to be the primary parent.
Don't alienate or try to cut out the other parent
Discuss the children's issues with the other parent. Do it via email if you have to. You two may not agree, but at least you have a record that you tried. Courts don't like parents who try to become "super mom or super dad" during the case by taking total control of the children's life without involving the other parent. This does not mean that you shouldn't be taking control, but you should also remember that there are always two parents and both deserve input into the children's lives and this is good for the children. A court will appreciate a parent who is not trying to box out the other. Nobody likes to see that. Domestic violence is one caveat to this point, but if the other spouse has an order of protection against them or domestic battery, you don't really need to be worrying to much about custody at that point.
Don't be a bad parent
Finally, don't be a bad parent. This is good advice for anyone even if you never get divorced or separated. If you don't take an interest in your child's life until a Petition for Custody case is on file or a divorce, then you are unlikely to be able to turn it around in time to become the residential parent. In my experience custody needs to be earned from day one of the child's life. If you were absent from the child's life or took a back seat to the other parent, then your hopes for custody are pretty unrealistic.