Getting the good ending in Fallout 4 without starting World War Three again
The Minutemen route is the one most people miss when they first play through this. You can get a full peaceful resolution where none of the major factions wipe each other out, but it requires you to actually use them before the story starts treating them as optional. I spent about six hours on my first run just realizing I had accidentally made myself incapable of the peaceful ending because I finished the Brotherhood questline too fast and never bothered recruiting Piper for the newspaper side stuff. That wasted a solid chunk of time I wish I had back. You need to have three things happening at once before you trigger the final act: the Minutemen need to be established as a real faction with a base, the Institute needs to still exist (which means you haven't killed everyone in it yet), and you need to be on friendly terms with at least two other factions. The game checks these conditions silently, so if any one of them is missing when you reach the point where you would normally start the endgame, it just auto-picks the worst ending for you. The quiet workaround most guides don't mention is timing. Complete the Minutemen quest "Defend Castle" before you finish any major faction quest that forces you to pick a side. I ran into a specific bug where if I completed "Shadow of Steel" with the Brotherhood first, then tried to do the Minutemen storyline, the game would flag the Minutemen as a failed faction even though the quest markers were still green. The fix was restarting from before that Brotherhood quest and doing the Minutemen stuff first. Worked perfectly after that.
When you reach the point where the final conflict starts, do not attack anyone until you have at least 20 settlers assigned to your settlement. The Minutemen get a bonus to their military strength based on settler count, and without enough settlers they just dissolve during the final battle. I learned this the hard way after losing the fight because I had built a castle but left it empty except for three settlers who couldn't hold the line.
What most people get wrong about this route
You can still side with the Brotherhood or the Institute after securing the Minutemen base, and it won't break the peaceful ending. The game does not require you to destroy either of those factions. You just need to talk your way out of combat when the final dialogue choices appear. There is a specific moment where Kellogg gives you a choice between attacking the Institute or retreating, and if you select retreat, the game locks you into the Minutemen victory path regardless of what you told the Brotherhood earlier. The downside to this route is that it takes significantly more playtime than the easy destruction endings. You have to maintain relationships with multiple factions simultaneously, which means you will miss some quest chains if you are not careful. I personally lost the Railroad questline because I was trying to keep the Minutemen and Institute both happy at the same time, and the game silently marked the Railroad as hostile. Nothing I did could bring them back, and I had to reload a save from about ten hours earlier. Another limitation is that the peaceful ending locks you out of several unique weapons and power armor sets. The Institute has the best energy weapons, and the Brotherhood has the best power armor. If you are playing on a new game and want the full Minutemen ending, you will need to decide early whether you want the loot or the story resolution. I usually pick the story on my first playthrough and accept that I will never get the Prydwen's unique armor set.
Get the Full Details

Step by step for the actual final sequence
When you get the call to defend the Castle, go there immediately and assign at least 15 settlers to the walls. Then talk to Preston Garvey and accept the quest. Do not progress past "The Earths Last Stand" until you have completed at least one major quest for both the Brotherhood and the Institute, because the game uses those as hidden flags for whether those factions will support you in the final battle. During the final assault, position your settlers at the northern wall first. The southern wave comes faster and kills empty walls quicker than you think. I have seen players lose the entire battle in under two minutes because they built their defenses backward. Put the turret at the top of the hill, not at the bottom where raiders can just walk up to it and shoot it down. After the battle concludes, you get the ending cinematic with all three factions present. It is noticeably longer than the standard endings and includes extra dialogue from characters you might have forgotten about. If you have completed all the side quests for the various settlements, you will see those settlers appear in the crowd, which is a nice touch but not required for the ending to trigger.
The whole process from start to finish took me about 40 hours across two playthroughs. The first time I failed because I pushed the Minutemen too late. The second time I succeeded on the third attempt after figuring out the settler placement mechanic. It is not the most forgiving ending in the game, but it is definitely the most complete story-wise.